Skip to content

Commit 532e25b

Browse files
committed
fix: strip any Playwright-related prefix from element errors
1 parent 9f81ba6 commit 532e25b

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

lib/index.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,9 @@ async function processQuery(handles: IHandleSet): Promise<DOMReturnType> {
9898
const handle = await containerHandle.evaluateHandle(evaluateFn, [fnName, ...argsToForward])
9999
return await covertToElementHandle(handle, fnName.includes('All'))
100100
} catch (err) {
101-
err.message = err.message.replace('[fnName]', `[${fnName}]`)
101+
err.message = err.message
102+
.replace(/^.*(?=TestingLibraryElementError:)/, '')
103+
.replace('[fnName]', `[${fnName}]`)
102104
err.stack = err.stack.replace('[fnName]', `[${fnName}]`)
103105
throw err
104106
}

test/__snapshots__/extend.test.ts.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
exports[`lib/extend.ts should handle the LabelText methods 1`] = `"<input id=\\"label-text-input\\" type=\\"text\\">"`;
44
55
exports[`lib/extend.ts should handle the get* method failures 1`] = `
6-
"Evaluation failed: TestingLibraryElementError: Unable to find an element with the title: missing.
6+
"TestingLibraryElementError: Unable to find an element with the title: missing.
77
88
<div
99
id=\\"scoped\\"

0 commit comments

Comments
 (0)