1234567891011121314151617181920212223242526272829303132333435363738394041 |
- const NodeEnvironment = require('jest-environment-node');
- const getBrowser = require('./getBrowser');
- class PuppeteerEnvironment extends NodeEnvironment {
-
-
- setTimeout(timeout) {
- if (this.global.jasmine) {
-
- this.global.jasmine.DEFAULT_TIMEOUT_INTERVAL = timeout;
- } else {
- this.global[Symbol.for('TEST_TIMEOUT_SYMBOL')] = timeout;
- }
- }
- async setup() {
- const browser = await getBrowser();
- const page = await browser.newPage();
- this.global.browser = browser;
- this.global.page = page;
- }
- async teardown() {
- const { page, browser } = this.global;
- if (page) {
- await page.close();
- }
- if (browser) {
- await browser.disconnect();
- }
- if (browser) {
- await browser.close();
- }
- }
- }
- module.exports = PuppeteerEnvironment;
|