UNPKG

678 BJavaScriptView Raw
1/* eslint-disable */
2const fs = require('fs')
3const os = require('os')
4const path = require('path')
5
6const DIR = process.env.DIR || path.join(os.tmpdir(), 'jest_puppeteer_global_setup')
7
8function rimraf(dirPath) {
9 function rmFile(entry) {
10 const entryPath = path.join(dirPath, entry)
11 if (fs.lstatSync(entryPath).isDirectory()) {
12 rimraf(entryPath)
13 } else {
14 fs.unlinkSync(entryPath)
15 }
16 }
17 if (fs.existsSync(dirPath)) {
18 fs.readdirSync(dirPath).forEach(rmFile)
19 fs.rmdirSync(dirPath)
20 }
21}
22
23module.exports = async function teardown() {
24 console.log('Teardown Puppeteer')
25 await global.SPDT_BROWSER.close()
26 rimraf(DIR)
27}
28/* eslint-enable */