-
Notifications
You must be signed in to change notification settings - Fork 99
/
Copy pathbdd-setup.ts
38 lines (31 loc) · 944 Bytes
/
bdd-setup.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
import { ChromiumBrowser, chromium } from '@playwright/test';
import {
After,
AfterAll,
Before,
BeforeAll,
setWorldConstructor,
setDefaultTimeout,
} from '@cucumber/cucumber';
import { env } from 'node:process';
import { CustomWorld } from './custom-world';
import { ICustomWorld } from './bdd.type';
setDefaultTimeout(30 * 1000);
setWorldConstructor(CustomWorld);
let browser: ChromiumBrowser;
BeforeAll(async function beforeAll() {
browser = await chromium.launch({ headless: !!env.CI });
});
Before({ timeout: 60 * 1000 }, async function before(this: ICustomWorld) {
this.handlersConfig = {};
this.testContext = { data: {} };
this.context = await browser.newContext({ locale: 'fr_FR' });
this.page = await this.context.newPage();
});
After(async function after(this: ICustomWorld) {
await this.page?.close();
await this.context?.close();
});
AfterAll(async function afterAll() {
await browser.close();
});