JavaScript testing libraries

Updated Nov 2026

JavaScript testing libraries run automated checks against code, from a single function to a full user flow in a real browser. A test runner executes test files in Node.js or a browser and reports each failed assertion. These libraries let developers catch regressions before code reaches production.

Popularity

Vitest has the most monthly downloads in this comparison, at 680.0M.

LibraryMonthly downloadsStarsLast releaseLicense
Vitest
696.6M
17.4KNov 2026MIT
Playwright
642.0M
100.5KNov 2026Apache-2.0
Jest
237.5M
45.5KSep 2026MIT
Mocha
58.3M
22.9KOct 2026MIT
Cypress
29.7M
51.0KNov 2026MIT
uvu
27.1M
3.0KJul 2022MIT
Jasmine
24.7M
15.8KAug 2026MIT
Karma
14.7M
12.0KJul 2024MIT
Downloads: npm, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

Features compared

LibraryReal-browser supportAssertions includedFunction spies included
VitestVia pluginBuilt-inBuilt-in
PlaywrightBuilt-inBuilt-inUnsupported
JestVia pluginBuilt-inBuilt-in
MochaBuilt-inUnsupportedUnsupported
CypressBuilt-inBuilt-inBuilt-in
uvuBuilt-inBuilt-inUnsupported
JasmineBuilt-inBuilt-inBuilt-in
KarmaBuilt-inVia pluginVia plugin
Built-inVia pluginNot supported

Libraries and code examples

Runs tests using the Vite project configuration and plugins.

Downloads / mo
696.6M
Stars
17.4K
Last release
5.1.1
License
MIT

Strengths

  • Reuses existing Vite configuration. Use the same Vite plugins and configuration for tests.
  • Parallelizes across test files. Test files run across multiple workers by default.

Limitations

  • Coverage needs an extra package. Install the selected V8 or Istanbul coverage provider.
  • Browser mode changes spying. Export spying with vi.spyOn needs a different approach in Browser Mode.

Quickstart

From index.md
$ npm install --save-dev vitest@5.1.1
import { expect, test } from 'vitest'

export function sum(a, b) {
  return a + b
}

test('adds 1 + 2 to equal 3', () => {
  expect(sum(1, 2)).toBe(3)
})

Vitest examples

From open-source projects on GitHub

Playwright

Automates web browsers through a high-level API.

Downloads / mo
642.0M
Stars
100.5K
Last release
1.65.1
License
Apache-2.0

Quickstart

From writing-tests-js.md
$ npm install --save-dev @playwright/test@1.65.1
import { test, expect } from '@playwright/test';

test('has title', async ({ page }) => {
  await page.goto('https://playwright.dev/');

  // Expect a title "to contain" a substring.
  await expect(page).toHaveTitle(/Playwright/);
});

Provides a JavaScript testing framework with its own runner and assertions.

Downloads / mo
237.5M
Stars
45.5K
Last release
30.5.2
License
MIT

Strengths

  • Includes coverage collection. Collect coverage through the coverage flag without adding a separate runner.
  • Reruns tests after changes. Watch changed files or rerun the entire suite with watchAll.

Limitations

  • Babel skips type checking. Run TypeScript checks separately when using Babel to transform tests.

Quickstart

From GettingStarted.md
$ npm install --save-dev jest@30.5.2
function sum(a, b) {
  return a + b;
}
module.exports = sum;

test('adds 1 + 2 to equal 3', () => {
  expect(sum(1, 2)).toBe(3);
});

Jest examples

From open-source projects on GitHub

Runs tests in Node.js and browsers with configurable reporting and parallel execution.

Downloads / mo
58.3M
Stars
22.9K
Last release
12.0.3
License
MIT

Strengths

  • Supports programmatic runner setup. Add test files and run them through a configured Mocha instance.
  • Exports test results as JSON. Write the JSON report directly to a selected file.

Limitations

  • Mocks need a separate library. Add Sinon for spies and configurable function replacements.
  • Parallel mode rejects exclusive tests. Remove it.only and describe.only before running tests in parallel.

Quickstart

From programmatic-usage.mdx
$ npm install --save-dev mocha@12.0.3
// test/example.test.js
import assert from "node:assert";

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

Mocha examples

From open-source projects on GitHub

Tests front-end web apps in the browser.

Downloads / mo
29.7M
Stars
51.0K
Last release
16.3.0
License
MIT
$ npm install --save-dev cypress@16.3.0
describe('My First Test', () => {
  it('Visits the Kitchen Sink', () => {
    cy.visit('https://example.cypress.io')
  })
})

Cypress examples

From open-source projects on GitHub

Runs tests in Node.js and the browser.

Downloads / mo
27.1M
Stars
3.0K
Last release
0.5.6
License
MIT

Quickstart

From readme.md
$ npm install --save-dev uvu@0.5.6
import { test } from 'uvu';
import * as assert from 'uvu/assert';

test('Math.sqrt()', () => {
  assert.is(Math.sqrt(4), 2);
  assert.is(Math.sqrt(144), 12);
  assert.is(Math.sqrt(2), Math.SQRT2);
});

test.run();

Provides a testing framework for browsers and Node.js.

Downloads / mo
24.7M
Stars
15.8K
Last release
7.0.2
License
MIT

Quickstart

From your_first_suite.js
$ npm install --save-dev jasmine-core@7.0.2
<link rel="stylesheet" href="node_modules/jasmine-core/lib/jasmine-core/jasmine.css">
<script src="node_modules/jasmine-core/lib/jasmine-core/jasmine.js"></script>
<script src="node_modules/jasmine-core/lib/jasmine-core/jasmine-html.js"></script>
<script src="node_modules/jasmine-core/lib/jasmine-core/boot.js"></script>
<script>
describe("A suite", function() {
    it("contains a spec with an expectation", function() {
        expect(true).toBe(true);
    });
});
</script>

Jasmine examples

From open-source projects on GitHub

Runs JavaScript test suites.

Downloads / mo
14.7M
Stars
12.0K
Last release
6.4.4
License
MIT

Quickstart

From public-api.html
$ npm install --save-dev karma@6.4.4 karma-jasmine karma-chrome-launcher
const karma = require('karma')

karma.config.parseConfig(
  './karma.conf.cjs',
  { singleRun: true },
  { promiseConfig: true, throwErrors: true }
).then((config) => {
  const server = new karma.Server(config, (code) => { process.exitCode = code })
  return server.start()
})

Karma examples

From open-source projects on GitHub

FAQ

Vitest suits projects that already use Vite configuration and plugins. Jest suits codebases with an established Jest suite. Playwright suits end-to-end tests that drive real browsers.

Vitest is a test runner that reuses a project's Vite configuration and plugins. Test files go through the same transforms as the application code.

Jest is a JavaScript testing framework that bundles a test runner, assertions, and mocking in one package.

Playwright automates Chromium, Firefox, and WebKit from test code through a high-level API. Cypress runs front-end tests inside the browser alongside the app under test.

Vitest fits projects that build with Vite because it shares their configuration. Jest fits projects with an existing Jest setup and no Vite build.

Mocha runs tests with configurable reporters and pairs with a separate assertion library. Jest includes assertions and mocking in the same package.

For coding agents

Found your testing library? Help your agent use it.

Connect Exa so your coding agent can find the library’s documentation, check its API, and look up implementations while you build.

Run in your terminal

claude plugin install exa@claude-plugins-official