Gathering detailed insights and metrics for jest-environment-puppeteer-jsdom
Gathering detailed insights and metrics for jest-environment-puppeteer-jsdom
Gathering detailed insights and metrics for jest-environment-puppeteer-jsdom
Gathering detailed insights and metrics for jest-environment-puppeteer-jsdom
npm install jest-environment-puppeteer-jsdom
Typescript
Module System
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
3 Stars
2 Commits
1 Forks
1 Watchers
15 Branches
1 Contributors
Updated on Feb 15, 2022
Latest Version
6.0.0
Package Id
jest-environment-puppeteer-jsdom@6.0.0
Unpacked Size
35.30 kB
Size
9.02 kB
File Count
10
NPM Version
6.14.11
Node Version
12.16.1
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
Run your tests using Jest & Puppeteer 🎪✨
npm install jest-environment-puppeteer puppeteer
Update your Jest configuration:
1{ 2 "globalSetup": "jest-environment-puppeteer/setup", 3 "globalTeardown": "jest-environment-puppeteer/teardown", 4 "testEnvironment": "jest-environment-puppeteer" 5}
Use Puppeteer in your tests:
1describe('Google', () => { 2 beforeAll(async () => { 3 await page.goto('https://google.com') 4 }) 5 6 it('should display "google" text on page', async () => { 7 const text = await page.evaluate(() => document.body.textContent) 8 expect(text).toContain('google') 9 }) 10})
global.browser
Give access to the Puppeteer Browser.
1it('should open a new page', async () => { 2 const page = await browser.newPage() 3 await page.goto('https://google.com') 4})
global.page
Give access to a Puppeteer Page opened at start (you will use it most of time).
1it('should fill an input', async () => { 2 await page.type('#myinput', 'Hello') 3})
global.context
Give access to a browser context that is instantiated when the browser is launched. You can control whether each test has its own isolated browser context using the browserContext
option in your jest-puppeteer.config.js
.
global.jestPuppeteer.debug()
Put test in debug mode.
debugger
instruction to Chromium, if Puppeteer has been launched with { devtools: true }
it will stop1it('should put test in debug mode', async () => { 2 await jestPuppeteer.debug() 3})
global.jestPuppeteer.resetPage()
Reset global.page
1beforeEach(async () => { 2 await jestPuppeteer.resetPage() 3})
global.jestPuppeteer.resetBrowser()
Reset global.browser, global.context, and global.page
1beforeEach(async () => { 2 await jestPuppeteer.resetBrowser() 3})
jest-puppeteer.config.js
You can specify a jest-puppeteer.config.js
at the root of the project or define a custom path using JEST_PUPPETEER_CONFIG
environment variable. It should export a config object or a Promise for a config object.
launch
<[object]> All Puppeteer launch options can be specified in config. Since it is JavaScript, you can use all stuff you need, including environment.connect
<[object]> All Puppeteer connect options can be specified in config. This is an alternative to launch
config, allowing you to connect to an already running instance of Chrome.browserContext
<[string]>. By default, the browser context (cookies, localStorage, etc) is shared between all tests. The following options are available for browserContext
:
default
Each test starts a tab, so all tests share the same context.incognito
Each tests starts an incognito window, so all tests have a separate, isolated context. Useful when running tests that could interfere with one another. (Example: testing multiple users on the same app at once with login, transactions, etc.)exitOnPageError
<[boolean]> Exits page on any global error message thrown. Defaults to true
.server
<[Object]> Server options allowed by jest-dev-server1// jest-puppeteer.config.js 2module.exports = { 3 launch: { 4 dumpio: true, 5 headless: process.env.HEADLESS !== 'false', 6 }, 7 server: { 8 command: 'node server.js', 9 port: 4444, 10 launchTimeout: 10000, 11 debug: true, 12 }, 13}
This example uses an already running instance of Chrome by passing the active web socket endpoint to connect
. This is useful, for example, when you want to connect to Chrome running in the cloud.
1// jest-puppeteer.config.js 2const fetch = require('node-fetch') 3const dockerHost = 'http://localhost:9222' 4 5async function getConfig() { 6 const response = await fetch(`${dockerHost}/json/version`) 7 const browserWSEndpoint = (await response.json()).webSocketDebuggerUrl 8 return { 9 connect: { 10 browserWSEndpoint, 11 }, 12 server: { 13 command: 'node server.js', 14 port: 3000, 15 launchTimeout: 10000, 16 debug: true, 17 }, 18 } 19} 20 21module.exports = getConfig()
Thanks to Fumihiro Xue for his great Jest example.
MIT
No vulnerabilities found.
Reason
license file detected
Details
Reason
no binaries found in the repo
Reason
no SAST tool detected
Details
Reason
Found 0/2 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
project is not fuzzed
Details
Reason
43 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More