Open-source project
argos-ci/jest-puppeteer avatar
argos-ci/jest-puppeteer

jest-puppeteer: A Jest preset that manages the browser for you

A Jest preset that runs end-to-end browser tests with Puppeteer and provides page assertions through expect-puppeteer.

3,542 stars283 forksTypeScriptMIT

At a glance

What is it?
jest-puppeteer is a Jest preset that wires Puppeteer into your test runner, exposing a global page object and handling browser lifecycle. It is a practical choice for teams that want end-to-end browser tests without writing custom Jest environments.
Who is it for?
Adopt jest-puppeteer if you are already on Jest and want a minimal path to browser-based end-to-end tests, especially if you also use expect-puppeteer matchers or Argos for visual regression. Skip it if you prefer Playwright's built-in test runner, need to run tests in parallel across multiple browsers with per-test isolation, or want to avoid the global page object.
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Activity is slowing. The repository last received commits 8 months ago.
What is it written in?
Mainly TypeScript, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on November 25, 2026, and from our analysis. They are not legal advice.

From daily snapshots

Star history

  • argos-ci/jest-puppeteer3,542 ★ · -4
Star history
Repository2026-08-132026-11-25
argos-ci/jest-puppeteer3.5k3.5k

-4 Stars in the last 104 days, measured from the daily GitHub snapshot. Compare with other projects

Editorial analysis

What jest-puppeteer actually does

jest-puppeteer is a Jest preset, not a standalone test framework. It solves the problem of wiring Puppeteer into Jest: you would otherwise write a custom test environment, manage browser launch and teardown, and figure out how to expose the page object. The preset handles that by providing a default environment that starts a browser, opens a page, and makes that page available as a global variable in each test file. It also ships a configuration file where you can declare a server to start before tests and stop after. The target user is a JavaScript or TypeScript developer who already uses Jest and wants end-to-end browser tests without learning a second test runner.

How the preset manages browser lifecycle

The README shows that jest-puppeteer replaces your testEnvironment. When you set preset to jest-puppeteer in jest.config.js, Jest uses the package's custom environment, which is called PuppeteerEnvironment. That environment is what creates the global page object. The README explicitly warns to remove any conflicting testEnvironment settings, which tells you the preset owns that part of Jest's configuration. The lifecycle is straightforward: before all tests, the environment launches a browser and opens a page; after tests, it tears down. For debugging, the README mentions a debug() function that pauses execution and opens the browser for manual inspection. This is a simple model: one browser, one page per test file, shared via globals. It does not describe per-test isolation or parallel browser instances, which is a limitation you should keep in mind.

Getting started: commands and configuration

Installation is three packages: npm install --save-dev jest-puppeteer puppeteer jest. Then set preset in your Jest config. The README gives a JSON example: {"preset": "jest-puppeteer"}. After that, a test file can use page directly, as in the Google example: beforeAll(async () => { await page.goto("https://google.com"); }); and then expect(page).toMatchTextContent(/Google/). For TypeScript, version 8.0.0 added native support. The README tells you to uninstall @types/jest-environment-puppeteer and @types/expect-puppeteer if you are on 10.1.2 or above, and to install @types/jest instead. It also notes that jest-puppeteer does not support @jest/globals, so you must use the global types from @types/jest. That is a concrete constraint that affects how you write imports in TypeScript.

Configuration options beyond the preset

The preset reads a jest-puppeteer.config.js file for browser and server options. The README shows two examples. One is automatic server management: module.exports = { server: { command: "node server.js", port: 4444 } }. That starts the server before the test run and stops it after, which removes the need for a separate globalSetup script. The other is customizing the launch: module.exports = { launch: { browser: "firefox", headless: process.env.HEADLESS !== "false" } }. This is notable because Puppeteer historically only supported Chrome, but the README claims Firefox is possible, likely through Puppeteer's Firefox support. The config also allows you to set up browser contexts, though the README does not elaborate. For custom test setup, you can use setupFilesAfterEnv to import expect-puppeteer globally, as in require("expect-puppeteer"). These options are real and come from the README.

expect-puppeteer: the matcher library that makes it usable

The README pairs jest-puppeteer with expect-puppeteer, a separate library that adds custom Jest matchers. Without it, you would write Puppeteer assertions manually, which is verbose. The README gives three examples: toMatchTextContent to assert text, toClick to simulate a click on a button with specific text, and toFillForm to fill a form by name. These matchers operate on the page object, so they fit naturally with the global page. The integration is loose: you import expect-puppeteer in your test file or via setupFilesAfterEnv. This is a design choice that keeps jest-puppeteer minimal while pushing assertion sugar into a companion package. If you do not install expect-puppeteer, you still get the browser management but lose the ergonomic matchers. The README also mentions Argos for visual testing, which is a separate service that can capture screenshots from Puppeteer tests, but it is not part of the preset itself.

Limitations and failure modes

The most obvious limitation is the global page object. Since page is a global, every test file shares the same browser instance, and the README does not describe per-test isolation. If one test navigates away, another test in the same file might see the wrong state unless you use beforeAll or beforeEach to reset. The debug() function pauses execution, but the README advises increasing Jest's timeout to 300000 ms when using it, which suggests that without that change, tests will time out. Another failure mode is the preset's control over testEnvironment. If you have an existing Jest config with a custom environment, you must remove it, which could break other tests that rely on that environment. The README does not mention how to combine jest-puppeteer with jsdom or node environments. Also, the automatic server feature assumes a single command and port; if your server takes longer to start than Jest's default wait, you may need to handle that yourself. The TypeScript constraint about @jest/globals is a real gotcha: if your project already uses @jest/globals for types, you will need to switch.

Alternatives and how they differ

The main alternative is Playwright's test runner, @playwright/test. Playwright takes a different approach: it has its own test runner with built-in browser management, per-test isolation, and parallel workers. You do not need Jest at all. Playwright also supports multiple browsers out of the box, while jest-puppeteer's README only mentions Chrome and Firefox via launch options. Another alternative is to use Puppeteer directly with Jest but write your own globalSetup and globalTeardown scripts. That gives you full control over browser lifecycle but requires you to manage the page object yourself, which is exactly what jest-puppeteer automates. If you are already invested in Jest and want minimal setup, jest-puppeteer is the lighter path. If you want a runner that is designed for end-to-end testing from the start, Playwright's runner is more comprehensive. The choice depends on whether you want to stay in the Jest ecosystem or adopt a dedicated e2e tool.

Maintenance and license considerations

The repository is licensed under MIT, which means you can use it in commercial projects without restrictions beyond preserving the license notice. The last push was December 2024, and version 11.0.0 was released on that date, so the project appears actively maintained. The README mentions that TypeScript support has evolved across versions, with a note to uninstall old type packages if you are on 10.1.2 or above. That suggests that upgrading between major versions may require configuration changes, not just a version bump. The dependency on Puppeteer means you inherit Puppeteer's own upgrade cycle. When Puppeteer releases a new major version, jest-puppeteer may need to catch up. The README does not document a migration guide, so you should check the changelog before upgrading. The maintenance cost is moderate: you need to track jest-puppeteer releases and ensure compatibility with your Jest version, since the preset tightly couples to Jest's environment API.

Editorial conclusion

Adopt jest-puppeteer if you are already on Jest and want a minimal path to browser-based end-to-end tests, especially if you also use expect-puppeteer matchers or Argos for visual regression. Skip it if you prefer Playwright's built-in test runner, need to run tests in parallel across multiple browsers with per-test isolation, or want to avoid the global page object. Before committing, verify that the preset's environment management matches your Jest version, check whether the automatic server feature supports your process manager, and confirm that the TypeScript setup works with your tsconfig, since the project does not support @jest/globals.

Frequently asked questions

What is jest-puppeteer used for?

It is a Jest preset for end-to-end testing in a browser. Installing it gives every test file a global page object for driving the browser, plus matcher functions for asserting on text, clicking elements and filling forms.

How do I set up jest-puppeteer?

Install the preset, Puppeteer and Jest as dev dependencies, then add the preset to your Jest configuration. You must remove any testEnvironment setting you already have, because the preset manages the environment itself.

Does jest-puppeteer support TypeScript?

Natively from version 8.0.0. If you upgraded to 10.1.2 or later you should uninstall the two old community type stub packages, and the preset does not support Jest's newer per-file globals import, so the classic ambient types package is the documented path.

Can jest-puppeteer run Firefox instead of Chrome?

Yes, through the launch configuration, where the browser is set and headless mode is toggled from an environment variable. The same file also accepts browser options and context setup.

How do I debug a failing browser test in jest-puppeteer?

Call the preset's debug helper, which pauses execution and opens the browser for inspection. Because of the pause you also need to raise Jest's timeout, and the README suggests setting it to five minutes per file.

Official sources

  1. Official README
  2. Project repository
  3. Release notes
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/argos-ci-jest-puppeteer.svg)](https://hysenlabs.com/projects/argos-ci-jest-puppeteer)

Star history chart for your README

markdown
[![Star history](https://hysenlabs.com/chart/argos-ci-jest-puppeteer.svg)](https://hysenlabs.com/projects/argos-ci-jest-puppeteer)

Was this useful?