(
context: BrowserContext,
extensionId: string,
scriptFile: string,
targetUrl: string,
timeoutMs: number,
options?: { patchCode?: (code: string) => string }
)
| 38 | |
| 39 | /** Run a test script from example/tests/ on the target page and collect console results */ |
| 40 | export async function runTestScript( |
| 41 | context: BrowserContext, |
| 42 | extensionId: string, |
| 43 | scriptFile: string, |
| 44 | targetUrl: string, |
| 45 | timeoutMs: number, |
| 46 | options?: { patchCode?: (code: string) => string } |
| 47 | ): Promise<{ passed: number; failed: number; logs: string[] }> { |
| 48 | let code = fs.readFileSync(path.join(__dirname, `../example/tests/${scriptFile}`), "utf-8"); |
| 49 | code = patchScriptCode(code); |
| 50 | code = options?.patchCode ? options.patchCode(code) : code; |
| 51 | return runInlineTestScript(context, extensionId, code, targetUrl, timeoutMs); |
| 52 | } |
| 53 | |
| 54 | /** Run inline script code on the target page and collect console results */ |
| 55 | export async function runInlineTestScript( |
nothing calls this directly
no test coverage detected