forked from DimensionDev/Maskbook
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjest-puppeteer.config.js
57 lines (50 loc) · 1.65 KB
/
jest-puppeteer.config.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
const { join } = require('path')
const { readdirSync, existsSync, lstatSync, unlinkSync, rmdirSync } = require('fs')
// load envs
require('dotenv').config({
path: join(__dirname, '.env', `e2e-${process.env.NODE_ENV}`),
})
// clean user data
function deleteFolderRecursive(dirPath) {
if (!existsSync(dirPath)) {
return
}
readdirSync(dirPath).forEach((file) => {
const curPath = join(dirPath, file)
if (lstatSync(curPath).isDirectory()) {
deleteFolderRecursive(curPath)
} else {
unlinkSync(curPath)
}
})
rmdirSync(dirPath)
}
deleteFolderRecursive(
join(
process.env.E2E_ALICE_USER_DATA_DIR,
`./Default/IndexedDB/chrome-extension_${process.env.E2E_EXT_ID}_0.indexeddb.leveldb`,
),
)
deleteFolderRecursive(
join(process.env.E2E_ALICE_USER_DATA_DIR, 'Default', 'Local Extension Settings', process.env.E2E_EXT_ID),
)
module.exports = {
launch: {
dumpio: true,
headless: false,
// more: https://github.com/puppeteer/puppeteer/issues/1649#issuecomment-354046341
executablePath: process.env.CHROMIUM_PATH,
// more: https://peter.sh/experiments/chromium-command-line-switches/
args: [
'--no-sandbox',
'--disable-infobars',
'--disable-setuid-sandbox',
`--disable-extensions-except=${process.env.E2E_EXT_DIR}`,
`--load-extension=${process.env.E2E_EXT_DIR}`,
`--user-data-dir=${process.env.E2E_ALICE_USER_DATA_DIR}`,
`--user-agent=${process.env.E2E_USER_AGENT}`,
],
},
browser: 'chromium',
browserContext: 'default',
}