| 877 | |
| 878 | describe('BasePage.evaluateWithArgs scoping', () => { |
| 879 | class EvalCapturePage extends BasePage { |
| 880 | scripts: string[] = []; |
| 881 | async goto(): Promise<void> {} |
| 882 | async evaluate<T = unknown>(js: string): Promise<T>; |
| 883 | async evaluate<Args extends unknown[], T>(fn: BrowserEvaluateFunction<Args, T>, ...args: Args): Promise<Awaited<T>>; |
| 884 | async evaluate(input: string | BrowserEvaluateFunction<unknown[], unknown>): Promise<unknown> { |
| 885 | const code = typeof input === 'string' ? input : input.toString(); |
| 886 | this.scripts.push(code); |
| 887 | if (typeof input !== 'string') return null; |
| 888 | return globalThis.eval(input); |
| 889 | } |
| 890 | async getCookies(): Promise<[]> { return []; } |
| 891 | async screenshot(): Promise<string> { return ''; } |
| 892 | async tabs(): Promise<unknown[]> { return []; } |
| 893 | async selectTab(): Promise<void> {} |
| 894 | } |
| 895 | |
| 896 | it('wraps declarations in a lexical block to avoid global const redeclaration', async () => { |
| 897 | const page = new EvalCapturePage(); |
nothing calls this directly
no outgoing calls
no test coverage detected