@charmander/test

Basic test organization

Usage no npm install needed!

<script type="module">
  import charmanderTest from 'https://cdn.skypack.dev/@charmander/test';
</script>

README

Build status

Organizes and runs tests.

Usage

'use strict';

const assert = require('assert');
const test = require('@charmander/test')(module);

test('synchronous test, no return value', () => {
    assert(1 < 2);
});

test('asynchronous test, promise return value', async () => {
    const n = await Promise.resolve(2);
    assert(1 < n);
});

or

const describe = require('@charmander/test/describe')(module);

describe('thing', it => {
    it('behaves', () => {
        assert(1 < 2);
    });
});

Running node path/to/test-module.js will run tests in that module. Test modules export an array of test objects, which have a name property and a .run() method. .run() returns a promise that rejects with a test error or resolves with undefined.