-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.job.js
119 lines (87 loc) · 2.36 KB
/
app.job.js
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
const { test, expect } = require('@playwright/test');
const Util = require('../../lib/util.js');
const EC = require('eight-colors');
let config;
// single page for all tests
let page;
test.beforeAll(async ({ browserName, browser }, TestInfo) => {
console.log(EC.magenta('Before app tests:'), browserName);
config = TestInfo.config.metadata;
page = await browser.newPage();
await page.context().addInitScript({
path: config.clientPath
});
});
test.afterAll(async () => {
await page.close();
console.log(EC.magenta('After app tests'));
});
test('open a page from config url', async () => {
const url = config.url;
console.log(`goto: ${url}`);
await page.goto(url);
await Util.delay(1000);
const $dom = await page.$('.author');
expect($dom).toBeTruthy();
const text = await $dom.textContent();
expect(text.trim()).toBe('cenfun');
});
test('before describe', () => {
// test() can only be called in a test file
// no test in test
// test('inside', () => {
// });
});
test('@flaky case', ({ browserName }, testInfo) => {
expect(testInfo.retry).toBe(1);
});
test.describe('two tests', () => {
test('one', async () => {
// ...
});
test.describe('two tests', () => {
test('one', async () => {
// ...
});
test('@failed case', () => {
console.log('stdout: failed case log', config);
console.error('stderr: failed case error');
expect('passed').toBe('failed');
});
test('fail - not yet ready', () => {
test.fail();
console.log('failed');
});
test('fixme - not yet ready', () => {
test.fixme();
console.log('fixme');
});
test('two', async () => {
// ...
});
});
test('@skipped test', () => {
test.skip();
console.log('skipped');
});
test.skip('@skipped case', () => {
expect('skipped').toBe('skipped');
});
test('two', async () => {
// ...
});
});
test.describe('two tests1', () => {
test('one', async () => {
// ...
});
test('timeout case', async () => {
test.setTimeout(3000);
await Util.delay(10 * 1000);
});
test('two', async () => {
// ...
});
});
test('after describe', () => {
});