-
Notifications
You must be signed in to change notification settings - Fork 0
/
fixtures.ts
73 lines (57 loc) · 1.74 KB
/
fixtures.ts
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import { test as base, chromium, type BrowserContext } from '@playwright/test';
import { initialSetup } from '@synthetixio/synpress/commands/metamask';
import { setExpectInstance } from '@synthetixio/synpress/commands/playwright';
import { resetState } from '@synthetixio/synpress/commands/synpress';
import { prepareMetamask } from '@synthetixio/synpress/helpers';
import { createDevNet } from './tenderly';
import { config } from 'dotenv';
config();
const { RPC_URL } = process.env;
export const test = base.extend<{
context: BrowserContext;
}>({
// eslint-disable-next-line no-empty-pattern
context: async ({}, use) => {
// required for synpress as it shares same expect instance as playwright
await setExpectInstance(expect);
// download metamask
const metamaskPath = await prepareMetamask(
process.env.METAMASK_VERSION ?? '10.25.0',
);
// prepare browser args
const browserArgs = [
`--disable-extensions-except=${metamaskPath}`,
`--load-extension=${metamaskPath}`,
'--remote-debugging-port=9222',
];
if (process.env.CI) {
browserArgs.push('--disable-gpu');
}
if (process.env.HEADLESS_MODE) {
browserArgs.push('--headless=new');
}
// launch browser
const context = await chromium.launchPersistentContext('', {
headless: false,
args: browserArgs,
});
// wait for metamask
await context.pages()[0].waitForTimeout(3000);
// setup metamask
await initialSetup(chromium, {
secretWordsOrPrivateKey: process.env.WALLET_PRIVATE_KEY,
network: {
name: 'mainnet',
chainId: 1,
rpcUrl: RPC_URL,
symbol: 'ETH',
},
password: 'password',
enableAdvancedSettings: true,
});
await use(context);
await context.close();
await resetState();
},
});
export const expect = test.expect;