GithubHelp home page GithubHelp logo

test's Introduction

@webb/test

Tiny, simple test runner

Install

npm i @webb/test -D

Usage

import { test } from "@webb/test"; // use the named export...
import Test from "@webb/test";     // or, the default and name it whatever you want

const myTest = test("Name of your test");

myTest("Add user", async() => {
  const user = await app.addUser("[email protected]");
  assert.equals(user.name, "Test");
})

myTest("Reject duplicate emails", async() => {
  await assert.rejects(async() => {
    await app.addUser("[email protected]");
  });
});

myTest.run();

API

test(testName, fun);

testName

Type: string

fun

Type: function

Runs a function that contains the expectations to test. The first argument is the test name, which is shown when the test function fails.

test.only(testName, fun);

testName

Type: string

fun

Type: function

Run only these tests and ignore the rest.

// Test the actively developed function
test.only("add team", async() => {
  const team = await app.addTeam("Acme Inc.");
});

test.before(fun);

fun

Type: function

Run the given function before all the supplied tests.

// Remove all data prior to each run
test.before(async() => {
  await app.cluster.clearAll();
});

test.after(fun);

fun

Type: function

Run the given function when there is a failure or after all the tests have passed.

test.skip(testName?, fun?);

testName

Type: string

fun

Type: function

Skip the given function. Useful for omitting tests temporarily.

// Ignore slow, broken, or incomplete functions
test.skip("invite a friend", async() => {
  // TODO
});

test.run()

Run all the supplied tests.

Tests

# Run all tests, sequentially
npm test

# Test dependencies for latest versions
npm run test:dependencies

# Lint "src" directory
npm run test:lint

# Test this module
npm run test:lint-assert

test's People

Contributors

netopwibby avatar

Watchers

James Cloos avatar  avatar  avatar

test's Issues

npm ERR! Invalid Version

This package's versioning follows ChronVer. npm versioning follows SemVer.

Until npm adds support for other versioning systems, or provides flags to ignore SemVer, you should wildcard this package's version in your package.json, like so:

{
  "dependencies": {
    "@webb/test": "*"
  }
}

If weirdness happens in your project, you may need to delete node_modules and npm i again.

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.