forked from uber/baseweb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jest.e2e.setup.js
40 lines (36 loc) · 978 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
/*
Copyright (c) 2018-2020 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');
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,
);
};