{"id":12136,"library":"testem","title":"Testem JavaScript Test Runner","description":"Testem is a robust, framework-agnostic JavaScript test runner designed to execute unit, integration, and end-to-end tests across various real desktop browsers (such as Chrome, Firefox, Safari, and Edge) and Node.js environments. It supports popular testing frameworks like Jasmine, QUnit, and Mocha, and offers extensibility for custom test adapters, making it suitable for a wide range of project needs. Currently at version `3.20.0`, Testem is actively maintained with a regular release cadence, featuring recent updates like the switch to `chokidar` for more reliable file watching and dropping support for older Node.js versions. Its key differentiators include running tests directly in actual browser engines for accurate user environment simulation and streamlined workflows for both Test-Driven Development (TDD) and Continuous Integration (CI).","status":"active","version":"3.20.0","language":"javascript","source_language":"en","source_url":"git://github.com/testem/testem","tags":["javascript","testing","unittest","browser"],"install":[{"cmd":"npm install testem","lang":"bash","label":"npm"},{"cmd":"yarn add testem","lang":"bash","label":"yarn"},{"cmd":"pnpm add testem","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Internal dependency for watching file changes, replaced 'fireworm' in v3.20.0. Potential for missed events in certain environments.","package":"chokidar","optional":false},{"reason":"Runtime environment. Testem requires Node.js version `>=20.19.0 || ^22.12.0 || >=24.0.0` as of v3.18.0.","package":"Node.js","optional":false}],"imports":[{"note":"Testem is primarily a command-line interface tool. It is typically invoked directly from the terminal or via `npm run` scripts. `npx testem` ensures you run the locally installed version.","wrong":"import testem from 'testem';","symbol":"testem (CLI)","correct":"npx testem"},{"note":"Testem automatically loads `testem.js` or `testem.cjs` from the project root for configuration. Since `v3.16.0`, `testem.cjs` is supported for use in `type=\"module\"` (ESM) Node.js projects, allowing CommonJS configuration in an ESM context.","symbol":"testem.js / testem.cjs (Configuration)","correct":"// project-root/testem.js\nmodule.exports = { /* ... */ };"},{"note":"While not the primary use case, Testem can be `require()`d for advanced programmatic integration, such as within custom launcher scripts or specialized CI environments. It typically expects CommonJS for this usage.","wrong":"import testem from 'testem';","symbol":"Programmatic API","correct":"const testem = require('testem');"}],"quickstart":{"code":"{\n  \"name\": \"my-testem-project\",\n  \"version\": \"1.0.0\",\n  \"description\": \"Basic Testem setup\",\n  \"main\": \"index.js\",\n  \"scripts\": {\n    \"test\": \"npx testem\"\n  },\n  \"keywords\": [],\n  \"author\": \"\",\n  \"license\": \"ISC\",\n  \"devDependencies\": {\n    \"chai\": \"^5.0.0\",\n    \"mocha\": \"^11.0.0\",\n    \"testem\": \"^3.20.0\"\n  }\n}\n\n// testem.js\nmodule.exports = {\n  \"framework\": \"mocha\",\n  \"src_files\": [\n    \"test/**/*.js\"\n  ],\n  \"launchers\": {\n    \"HeadlessChrome\": {\n      \"command\": \"google-chrome --headless --disable-gpu --remote-debugging-port=9222\",\n      \"protocol\": \"browser\"\n    }\n  },\n  \"launch_in_ci\": [\n    \"HeadlessChrome\"\n  ],\n  \"launch_in_dev\": [\n    \"HeadlessChrome\",\n    \"Firefox\"\n  ]\n};\n\n// test/example.test.js\nconst { expect } = require('chai');\n\ndescribe('Array', function() {\n  it('should return -1 when the value is not present', function() {\n    expect([1, 2, 3].indexOf(4)).to.equal(-1);\n  });\n\n  it('should return the correct index when present', function() {\n    expect([1, 2, 3].indexOf(2)).to.equal(1);\n  });\n});\n","lang":"javascript","description":"This quickstart demonstrates how to set up Testem with Mocha and Chai, including a basic `testem.js` configuration to run tests in a headless Chrome browser. It shows the `package.json` script for easy execution."},"warnings":[{"fix":"Upgrade Node.js to a supported version (20.19.0, 22.12.0, or 24.0.0+).","message":"Testem dropped support for Node.js versions older than 20. Users running on Node.js < 20 will encounter errors.","severity":"breaking","affected_versions":">=3.18.0"},{"fix":"If you observe missed change events, try setting the environment variable `CHOKIDAR_USE_POLLING=1` before running Testem (e.g., `CHOKIDAR_USE_POLLING=1 npx testem`).","message":"In `v3.20.0`, Testem switched from `fireworm` to `chokidar` for file watching. While this resolves some long-standing issues, there's a risk of missed change events in certain environments.","severity":"gotcha","affected_versions":">=3.20.0"},{"fix":"For new projects, prefer evergreen browsers (Chrome, Firefox, Safari, Edge) or Node.js for testing. Migrate existing tests away from IE and PhantomJS where possible.","message":"Internet Explorer and PhantomJS are now documented as deprecated test targets. While still supported, maintaining compatibility through transpilation and polyfills is expected to become more difficult over time.","severity":"deprecated","affected_versions":">=3.14.0"},{"fix":"Review custom build steps or configurations if you encounter new bundling-related errors after upgrading. Ensure your setup is compatible with `esbuild`'s bundling characteristics.","message":"Testem replaced `browserify` with `esbuild` for internal bundling in `v3.19.1`. While primarily an internal change, projects with highly customized configurations that implicitly relied on `browserify`'s specific behaviors might experience unexpected issues.","severity":"breaking","affected_versions":">=3.19.1"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Upgrade your Node.js installation to version 20.19.0, 22.12.0, 24.0.0, or later.","cause":"Running Testem on an unsupported Node.js version (e.g., Node 18).","error":"Error: Testem requires Node.js version 20.x, 22.x, or 24.x or higher."},{"fix":"Run Testem with the `CHOKIDAR_USE_POLLING=1` environment variable, e.g., `CHOKIDAR_USE_POLLING=1 npx testem`.","cause":"The new `chokidar` file watcher might be missing events in your environment, especially on network drives or with certain OS configurations.","error":"Testem is not detecting file changes and not re-running tests automatically."},{"fix":"For ESM projects, rename your configuration file to `testem.cjs` and ensure it uses CommonJS `require()` and `module.exports` syntax. Alternatively, if keeping `testem.js`, ensure it is pure CommonJS.","cause":"Your project's `package.json` specifies `\"type\": \"module\"` (ESM), but `testem.js` is a CommonJS module and Testem loads it as such. An `import` statement in `testem.js` will cause this error.","error":"SyntaxError: Cannot use import statement outside a module (when using testem.js)"}],"ecosystem":"npm"}