jest-environment-puppeteer
Advanced tools
Comparing version 8.0.6 to 9.0.0
@@ -123,3 +123,3 @@ 'use strict'; | ||
} catch (error) { | ||
switch(error.code){ | ||
/* eslint-disable no-fallthrough */ switch(error.code){ | ||
case jestDevServer.ERROR_TIMEOUT: | ||
@@ -144,3 +144,3 @@ { | ||
} | ||
} | ||
/* eslint-enable no-fallthrough */ } | ||
} | ||
@@ -147,0 +147,0 @@ }; |
@@ -0,1 +1,2 @@ | ||
import { JestEnvironmentConfig, EnvironmentContext } from '@jest/environment'; | ||
import NodeEnvironment from 'jest-environment-node'; | ||
@@ -58,2 +59,4 @@ import { ConnectOptions, PuppeteerLaunchOptions, Browser, Page, BrowserContext } from 'puppeteer'; | ||
declare class PuppeteerEnvironment extends NodeEnvironment { | ||
global: StrictGlobal & NodeEnvironment["global"]; | ||
constructor(config: JestEnvironmentConfig, _context: EnvironmentContext); | ||
setTimeout(timeout: number): void; | ||
@@ -60,0 +63,0 @@ setup(): Promise<void>; |
@@ -226,12 +226,6 @@ 'use strict'; | ||
class PuppeteerEnvironment extends NodeEnvironment__default.default { | ||
// Jest is not available here, so we have to reverse engineer | ||
// the setTimeout function, see https://github.com/facebook/jest/blob/ffe2352c781703b427fab10777043fb76d0d4267/packages/jest-runtime/src/index.ts#L2331 | ||
setTimeout(timeout) { | ||
this.global[testTimeoutSymbol] = timeout; | ||
} | ||
async setup() { | ||
const config = await readConfig(); | ||
const global = this.global; | ||
global.puppeteerConfig = config; | ||
global.jestPuppeteer = { | ||
constructor(config, _context){ | ||
super(config, _context); | ||
this.global.puppeteerConfig = {}; | ||
this.global.jestPuppeteer = { | ||
debug: async ()=>{ | ||
@@ -241,3 +235,3 @@ // Set timeout to 4 days | ||
// Run a debugger (in case Puppeteer has been launched with `{ devtools: true }`) | ||
await getPage(global).evaluate(()=>{ | ||
await getPage(this.global).evaluate(()=>{ | ||
debugger; | ||
@@ -248,15 +242,22 @@ }); | ||
resetPage: async ()=>{ | ||
await closePage(global); | ||
await openPage(global); | ||
await closePage(this.global); | ||
await openPage(this.global); | ||
}, | ||
resetBrowser: async ()=>{ | ||
await closeAll(global); | ||
await initAll(global); | ||
await closeAll(this.global); | ||
await initAll(this.global); | ||
} | ||
}; | ||
await initAll(global); | ||
} | ||
// Jest is not available here, so we have to reverse engineer | ||
// the setTimeout function, see https://github.com/facebook/jest/blob/ffe2352c781703b427fab10777043fb76d0d4267/packages/jest-runtime/src/index.ts#L2331 | ||
setTimeout(timeout) { | ||
this.global[testTimeoutSymbol] = timeout; | ||
} | ||
async setup() { | ||
this.global.puppeteerConfig = await readConfig(); | ||
await initAll(this.global); | ||
} | ||
async teardown() { | ||
const global = this.global; | ||
await closeAll(global); | ||
await closeAll(this.global); | ||
} | ||
@@ -263,0 +264,0 @@ } |
{ | ||
"name": "jest-environment-puppeteer", | ||
"description": "Puppeteer environment for Jest.", | ||
"version": "8.0.6", | ||
"version": "9.0.0", | ||
"type": "commonjs", | ||
@@ -27,3 +27,3 @@ "main": "./dist/index.js", | ||
"engines": { | ||
"node": ">=14.0.0" | ||
"node": ">=16" | ||
}, | ||
@@ -47,15 +47,15 @@ "keywords": [ | ||
"@jest/globals": "29.5.0", | ||
"@types/jest": "^29.4.0", | ||
"rollup": "^3.18.0", | ||
"rollup-plugin-dts": "^5.2.0", | ||
"rollup-plugin-swc3": "^0.8.0" | ||
"@types/jest": "^29.5.1", | ||
"rollup": "^3.23.0", | ||
"rollup-plugin-dts": "^5.3.0", | ||
"rollup-plugin-swc3": "^0.8.1" | ||
}, | ||
"dependencies": { | ||
"chalk": "^4.1.2", | ||
"cosmiconfig": "^8.1.0", | ||
"deepmerge": "^4.3.0", | ||
"jest-dev-server": "^8.0.5", | ||
"cosmiconfig": "^8.1.3", | ||
"deepmerge": "^4.3.1", | ||
"jest-dev-server": "^9.0.0", | ||
"jest-environment-node": "^29.5.0" | ||
}, | ||
"gitHead": "f756dc3ee3dae34a0a5c1855598f54c45fea9441" | ||
"gitHead": "e13d1ddce8f557405419b37cc2f6f37b4fe45212" | ||
} |
@@ -164,3 +164,3 @@ # jest-environment-puppeteer | ||
dumpio: true, | ||
headless: process.env.HEADLESS !== "false", | ||
headless: process.env.HEADLESS !== "false" ? "new" : false, | ||
}, | ||
@@ -167,0 +167,0 @@ server: { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24576
473
+ Addedjest-dev-server@9.0.2(transitive)
+ Addedsignal-exit@4.1.0(transitive)
+ Addedspawnd@9.0.2(transitive)
- Removedjest-dev-server@8.0.5(transitive)
- Removedsignal-exit@3.0.7(transitive)
- Removedspawnd@8.0.5(transitive)
Updatedcosmiconfig@^8.1.3
Updateddeepmerge@^4.3.1
Updatedjest-dev-server@^9.0.0