-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathjest-env.js
More file actions
39 lines (31 loc) · 958 Bytes
/
jest-env.js
File metadata and controls
39 lines (31 loc) · 958 Bytes
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
/*
* @Author: huyu
* @Date: 2020-04-29 18:06:53
* @Last Modified by: huyu
* @Last Modified time: 2020-04-30 17:58:08
*/
// jest ui env
// 做一些初始操作和全局配置
import 'regenerator-runtime/runtime' // 在此引入避免在每个测试文件中引入
const fs = require('fs')
// 存放日志和截图的文件夹,配置在jest-ui.config.js中
const LOG_DIR = global.LOG_DIR
// url前缀
const urlPrefix = 'http://localhost:8888/#'
// 默认超时时间
const timeout = 5000
function checkDir() {
if (!fs.existsSync(LOG_DIR)) {
fs.mkdirSync(LOG_DIR)
}
}
checkDir()
// 全局配置
global.__LOG_DIR__ = LOG_DIR // 日志目录
global.__URL_PREFIX__ = urlPrefix // url前缀
global.__TIMEOUT__ = timeout // 全局超时时间
jest.setTimeout(120000) // jest总超时时间
// 所有测试文件执行前执行一次,保存一些全局变量
global.beforeAll(async () => {
// await page.setDefaultTimeout(timeout)
});