forked from TypeCellOS/BlockNote
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetupScript.ts
More file actions
33 lines (28 loc) · 828 Bytes
/
setupScript.ts
File metadata and controls
33 lines (28 loc) · 828 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import {
BrowserContext,
BrowserContextOptions,
test as base,
} from "@playwright/test";
export type TestOptions = {
mockID: number | undefined;
};
export const test = base.extend<TestOptions>({
browser: async ({ browser }, use) => {
const oldFunc = browser.newContext;
browser.newContext = async (options?: BrowserContextOptions) => {
const ret: BrowserContext = await oldFunc.call(browser, options);
await ret.addInitScript({
content: `window.__TEST_OPTIONS = window.__TEST_OPTIONS || {}`,
});
return ret;
};
await use(browser);
},
context: async ({ context }, use) => {
await context.addInitScript({
content: `window.__TEST_OPTIONS = window.__TEST_OPTIONS || {}`,
});
await use(context);
},
});
export { expect } from "@playwright/test";