GithubHelp home page GithubHelp logo

tchigher / uvu Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lukeed/uvu

0.0 0.0 0.0 217 KB

uvu is an extremely fast and lightweight test runner for Node.js and the browser

License: MIT License

JavaScript 100.00%

uvu's Introduction

uvu
uvu is an extremely fast and lightweight test runner for Node.js and the browser
Ultimate Velocity, Unleashed

example with suites

Features

  • Super lightweight
  • Extremely performant
  • Individually executable test files
  • Supports async/await tests
  • Supports native ES Modules
  • Browser-Compatible
  • Familiar API

Install

$ npm install --save-dev uvu

Usage

Check out /examples for 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.js

View the uvu CLI documentation

Assertions

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!

API

Module: uvu

View uvu API documentation

The main entry from which you will import the test or suite methods.

Module: uvu/assert

View uvu/assert API documentation

A collection of assertion methods to use within your tests. Please note that:

  • these are browser compatible
  • these are completely optional

Benchmarks

via the /bench directory 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.

~> "jest"  took  1,630ms  (861  ms)
~> "mocha" took    215ms  (  3  ms)
~> "tape"  took    132ms  (  ???  )
~> "uvu"   took     74ms  (  1.4ms)

License

MIT ยฉ Luke Edwards

uvu's People

Contributors

hyanmandian avatar lukeed avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.