Testem JavaScript Test Runner

3.20.0 · active · verified Sun Apr 19

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).

Common errors

Warnings

Install

Imports

Quickstart

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.

{
  "name": "my-testem-project",
  "version": "1.0.0",
  "description": "Basic Testem setup",
  "main": "index.js",
  "scripts": {
    "test": "npx testem"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "chai": "^5.0.0",
    "mocha": "^11.0.0",
    "testem": "^3.20.0"
  }
}

// testem.js
module.exports = {
  "framework": "mocha",
  "src_files": [
    "test/**/*.js"
  ],
  "launchers": {
    "HeadlessChrome": {
      "command": "google-chrome --headless --disable-gpu --remote-debugging-port=9222",
      "protocol": "browser"
    }
  },
  "launch_in_ci": [
    "HeadlessChrome"
  ],
  "launch_in_dev": [
    "HeadlessChrome",
    "Firefox"
  ]
};

// test/example.test.js
const { expect } = require('chai');

describe('Array', function() {
  it('should return -1 when the value is not present', function() {
    expect([1, 2, 3].indexOf(4)).to.equal(-1);
  });

  it('should return the correct index when present', function() {
    expect([1, 2, 3].indexOf(2)).to.equal(1);
  });
});

view raw JSON →