rsnext/test/jest-global-teardown.js
JJ Kasper 7b933f675a Optimize test setup (#8644)
* Tweak test set-up

* Update azure config

* Add cleaning test files and windows handling

* Limit windows test to one at a time

* Tweak test settings

* Update tests splitting

* remove custom concurrency for azure

* Test Azure var

* Update Azure config

* bump

* Simplify cleaning up
2019-09-10 13:11:55 -04:00

26 lines
613 B
JavaScript

'use strict'
let globalTeardown = () => {}
const browser = global.bsBrowser
if (process.env.BROWSERSTACK) {
globalTeardown = () => global.browserStackLocal.killAllProcesses(() => {})
}
module.exports = async () => {
if (browser) {
// Close all remaining browser windows
try {
const windows = await browser.windowHandles()
for (const window of windows) {
if (!window) continue
await browser.window(window)
await browser.origClose()
await browser.quit()
await globalTeardown()
}
} catch (_) {}
} else {
await globalTeardown()
}
}