• Stars
    star
    832
  • Rank 54,811 (Top 2 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 3 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

🙅‍♀️ ✌️ fastest test runner


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.

More Repositories

1

json-server

Get a full fake REST API with zero coding in less than 30 seconds (seriously)
JavaScript
72,441
star
2

husky

Git hooks made easy 🐶 woof!
JavaScript
32,250
star
3

lowdb

Simple and fast JSON database
JavaScript
21,308
star
4

hotel

🏩 A simple process manager for developers. Start apps from your browser and access them using local domains
JavaScript
9,975
star
5

jsonplaceholder

A simple online fake REST API server
HTML
5,017
star
6

tlapse

📷 Create a timelapse of your web development... or just automatically take screenshots of your hard work ;)
JavaScript
2,024
star
7

mistcss

💧 Write atomic components using only CSS! (JS-from-CSS™)
JavaScript
788
star
8

pegasus

Load JSON while still loading other scripts
JavaScript
703
star
9

katon

(use hotel instead)
JavaScript
684
star
10

steno

Super fast async file writer with atomic write ⚡
JavaScript
678
star
11

react-fake-props

🔮 Magically generate fake props for your React tests
JavaScript
627
star
12

fetchival

Easy window.fetch requests
JavaScript
520
star
13

lodash-id

Makes it easy to manipulate id-based resources with lodash or lowdb
JavaScript
472
star
14

react-lodash

⚛️ 🔧 Lodash as React components
JavaScript
356
star
15

stop-server

📱 Shut down your computer with your phone
JavaScript
349
star
16

demo

A demo repository for My JSON Server (Alpha)
334
star
17

pinst

🍺 dev only postinstall hooks (package.json)
JavaScript
258
star
18

please-upgrade-node

💁 Show a message to your users to upgrade Node instead of a stacktrace
JavaScript
239
star
19

jsop

JSON file reader/writer (powered by Object.observe)
JavaScript
207
star
20

husky-4-to-8

Quickly migrate your hooks from husky v4 to husky@latest
JavaScript
131
star
21

user-startup

Auto start commands when you log in (cross-platform)
JavaScript
125
star
22

cult

cult monitors gulpfile changes and reloads gulp
JavaScript
119
star
23

bg.nvim

Automatically sync your terminal background with your colorscheme 🎆
Lua
97
star
24

logan

Mini template system for the console and colors
JavaScript
81
star
25

minihost

Easily start and access servers
JavaScript
46
star
26

ghwn

Get desktop notifications for new issues, comments, stars... (no installation required)
HTML
42
star
27

shoutjs

Make your ShellJS commands explicit and get a beautiful output
JavaScript
30
star
28

homerun

Turn npm package scripts into CLI commands
JavaScript
23
star
29

server-ready

Know when a server is ready to receive requests
JavaScript
20
star
30

husky-init

JavaScript
20
star
31

backbone-pegasus

Load models and collections data while loading Backbone
JavaScript
20
star
32

server-ready-cli

Run commands only when a server is available
JavaScript
19
star
33

eslint-config

JavaScript
8
star
34

typicode.github.io

HTML
8
star