@rachel-barrett/test-js
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

test-js

This is a minimal javascript library for unit testing.

Example Usage

(This example uses typescript, and assumes you have ts-node as a dev dependency, but you could just as easily use javascript with node.)

Save the library to your project as a dev dependency, with:

npm install --save-dev @rachel-barrett/test-js

Create a test directory. Create an index.ts file in it, with contents:

//index.ts

import * as test from "@rachel-barrett/test-js";

import "./TestSuite1";

test.results();

Create a test suite file, also in the test directory e.g.

//TestSuite1.ts

import {group, test, assertEquals} from "@rachel-barrett/test-js";

group(module.filename)(() => {
    group("function foo should:")(() => {
        test("return succes when bar")(() => {
            const expected = 1;
            const actual = 2;

            console.log("log anything helpful for debugging");

            return assertEquals<number>({ expected, actual });
        });
    });
});

Add a test key to your package.json scripts key, that runs:

cd test; ts-node index.ts

Then you can run your tests with:

npm test

Package Sidebar

Install

npm i @rachel-barrett/test-js

Weekly Downloads

0

Version

2.0.0

License

ISC

Unpacked Size

5.76 kB

Total Files

4

Last publish

Collaborators

  • rachel-barrett