Xv

🙅‍♀️ ✌️ A tiny test runner focused on simplicity and speed
Alternatives To Xv
Project NameStarsDownloadsRepos Using ThisPackages Using ThisMost Recent CommitTotal ReleasesLatest ReleaseOpen IssuesLicenseLanguage
Nodebestpractices87,387
21 hours ago36cc-by-sa-4.0JavaScript
:white_check_mark: The Node.js best practices list (March 2023)
Puppeteer82,40412,12810,9322 hours ago761September 22, 2022257apache-2.0TypeScript
Headless Chrome Node.js API
Mocha21,954
a day ago286mitJavaScript
☕️ simple, flexible, fun javascript test framework for node.js & the browser
Javascript Testing Best Practices21,034
9 days ago55mitJavaScript
📗🌐 🚢 Comprehensive and exhaustive JavaScript & Node.js testing best practices (December 2022)
Ava20,28444,27929,3052 days ago104September 04, 202289mitJavaScript
Node.js test runner that lets you develop with confidence 🚀
Keycloak15,351215262an hour ago105September 14, 20221,804apache-2.0Java
Open Source Identity and Access Management For Modern Applications and Services
Nightwatch11,33715,8452,9103 hours ago279September 17, 2022208mitJavaScript
End-to-end testing framework written in Node.js and using the W3C Webdriver API
Color Thief11,32173523 days ago7July 06, 202066mitJavaScript
Grab the color palette from an image using just Javascript. Works in the browser and in Node.
Kind11,3062803 hours ago163September 22, 2022179apache-2.0Go
Kubernetes IN Docker - local clusters for testing Kubernetes
Volkswagen10,935553 years ago15October 16, 201558mitJavaScript
:see_no_evil: Volkswagen detects when your tests are being run in a CI server, and makes them pass.
Alternatives To Xv
Select To Compare


Alternative Project Comparisons
Readme


xv

Node.js CI install size

A tiny (~80 lines of TypeScript) test runner focused on simplicity and speed

$ xv ./src
src/add.test.js: 0.103ms
src/sub.test.js: 0.064ms

Extracted from lowdb. One of the fastest test runner according to this benchmark.

Why

If you've used other test runners, you probably have spent a significant amount of time reading docs, configuring, maintaining and debugging them.

By being extremely simple, xv gets out of your way and lets you be productive faster. In fact, the whole project documentation fits in this page ;)

Install

npm install xv --save-dev

Usage

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

// src/add.test.js
import assert from 'node:assert/strict'
import add from './add.js'

// This is plain Node code, there's no xv API
export function testAdd() {
  assert.equal(add(1, 2), 3)
}

Edit package.json:

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

Run tests:

npm test                # run all test files in ./src
npx xv src/add.test.js  # run a single test file

Convention

By default, xv will look for files named: *.test.js, test.js, *.test.ts and test.ts

TypeScript

With TypeScript + ts-node

npm install ts-node --save-dev
{
  "scripts": {
    "test": "xv --loader=ts-node/esm src"
  }
}

With TypeScript only

Compile your .ts files using tsc and run xv on compiled .js files.

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.json to exclude compiled test files:

{
  "files": [
    "lib",
    "!lib/**/*.test.js",
    "!lib/**/test.js"
  ]
}

Common JS

// src/add.test.js
const assert = require('assert').strict;
const add = require('./add')

exports.testAdd = function() {
  assert.equal(add(1, 2), 3)
}

Watch mode

xv doesn't have a watch mode. If the feature is needed, it's recommended to use tools like watchexec or chokidar-cli to re-run xv when there are changes.

Popular Testing Projects
Popular Nodejs Projects
Popular Software Quality Categories
Related Searches

Get A Weekly Email With Trending Projects For These Categories
No Spam. Unsubscribe easily at any time.
Javascript
Typescript
Node
Testing
Jest
Tdd
Mocha
Ava