The definitive source of the best
JavaScript libraries, frameworks, and plugins.

  • ×

    :x: :heavy_check_mark: A beautifully simple and capable test runner
    Filed under 

    • 🔾34%Overall
    • 504
    • 2.7 days
    • 🕩24
    • 👥2



    • User-friendly - zero-config, no API to learn, simple conventions
    • Extremely lighweight - 40 LOC and no dependencies
    • Super fast - with almost zero abstractions, xv is as fast as Node

    Used in lowdb, steno and other awesome projects. Supports ESM and TypeScript.


    npm install xv --save-dev


    Create a test file and use Node's built-in assert module:

    // src/add.test.js
    import { strict as assert } from 'assert'
    export function testAdd() {
      assert.equal(1 + 2, 3)

    Edit package.json:

      "scripts": {
        "test": "xv src"

    Run all test files:

    npm test

    Run a single test file:

    npx xv src/add.test.js


    When provided a directory, xv will look for files named *.test.js or test.js and run exported functions sequentially.


    To use xv with TypeScript, compile your .ts files and run xv directly on compiled .js. This has the benefit of testing code that is really published.

    For example, assuming your compiled files are in lib/, edit package.json to run xv after tsc:

      "scripts": {
        "test": "tsc && xv lib"

    If you're publishing to npm, edit package.jsonto exclude compiled test files:

      "files": [

    You can run npm publish --dry to check that it's working (nothing is going to be published with the --dry option).

    Show All