Ultimate Velocity, Unleashed
- Super lightweight
- Extremely performant
- Individually executable test files
- Supports
async/awaittests - Supports native ES Modules
- Browser-Compatible
- Familiar API
$ npm install --save-dev uvu
Check out
/examplesfor a list of working demos!
// tests/demo.js
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('JSON', () => {
const input = {
foo: 'hello',
bar: 'world'
};
const output = JSON.stringify(input);
assert.snapshot(output, `{"foo":"hello","bar":"world"}`);
assert.equal(JSON.parse(output), input, 'matches original');
});
test.run();Then execute this test file:
# via `uvu` cli, for all `/tests/**` files
$ uvu -r esm tests
# via `node` directly, for file isolation
$ node -r esm tests/demo.jsNote: The
-r esmis for legacy Node.js versions. Learn More
The uvu/assert module is completely optional.
In fact, you may use any assertion library, including Node's native assert module! This works because uvu relies on thrown Errors to detect failures. Implicitly, this also means that any uncaught exceptions and/or unhandled Promise rejections will result in a failure, which is what you want!
The main entry from which you will import the test or suite methods.
A collection of assertion methods to use within your tests. Please note that:
- these are browser compatible
- these are completely optional
via the
/benchdirectory with Node v10.21.0
Below you'll find each test runner with two timing values:
- the
took ___value is the total process execution time – from startup to termination - the parenthesis value (
(___)) is the self-reported execution time, if known
Each test runner's stdout is printed to the console to verify all assertions pass.
Said output is excluded below for brevity.
~> "ava" took 594ms ( ??? )
~> "jest" took 962ms (356 ms)
~> "mocha" took 209ms ( 4 ms)
~> "tape" took 122ms ( ??? )
~> "uvu" took 72ms ( 1.3ms)
MIT © Luke Edwards