Skip to content

Commit 7e56327

Browse files
committed
refactor: it is not a mock
1 parent ad69d24 commit 7e56327

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function mapArgument(argument: any, index: number): any {
1515
: argument
1616
}
1717

18-
const mockFnToExecuteInPage = `
18+
const delegateFnToExecuteInPage = `
1919
function evaluateInPage(container, fnName, ...args) {
2020
${domLibraryAsString}
2121
@@ -59,9 +59,9 @@ function createDelegateFor(
5959
): (...args: any[]) => Promise<DOMReturnType> {
6060
return async function(...args: any[]): Promise<DOMReturnType> {
6161
// @ts-ignore
62-
const containerHandle: ElementHandle = contextFn ? contextFn(...args) : this
62+
const containerHandle: ElementHandle = contextFn ? contextFn.apply(this, args) : this
6363
// @ts-ignore
64-
const evaluateFn: EvaluateFn = {toString: () => mockFnToExecuteInPage}
64+
const evaluateFn: EvaluateFn = {toString: () => delegateFnToExecuteInPage}
6565

6666
// Convert RegExp to a special format since they don't serialize well
6767
let argsToForward = args.map(arg => (arg instanceof RegExp ? {regex: arg.source} : arg))

0 commit comments

Comments
 (0)