forked from uber/baseweb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jest.e2e.setup.js
43 lines (38 loc) · 1017 Bytes
/
jest.e2e.setup.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
/*
Copyright (c) Uber Technologies, Inc.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
*/
/* eslint-disable flowtype/require-valid-file-annotation */
/*eslint-env node*/
const mkdirp = require('mkdirp');
jest.setTimeout(20 * 1000);
jest.retryTimes(10);
global.it = async function (name, func, timeout) {
return await test(
name,
async () => {
try {
await func();
} catch (e) {
mkdirp.sync('__artifacts__');
try {
await page.screenshot({
type: 'png',
path: `__artifacts__/${name}.png`,
});
} catch (er) {
console.log('There was an issue taking a test failure screenshot.');
console.log(er);
}
if (process.env.CI) {
console.log(
`\u001B]1338;url="artifact://__artifacts__/${name}.png";alt="Screenshot"\u0007`
);
}
throw e;
}
},
timeout
);
};