module-testrunner
v0.21.0
Published
Runs test files that export a top level function to enable initialisation.
Downloads
5
Readme
Module Testrunner
Runs test files that export a top level function to enable initialisation.
Table of Contents
Install
https://www.npmjs.com/package/module-testrunner
npm install module-testrunner
Usage
CLI
npx test test_files
API
const { run } = require('module-testrunner');
const options = { ... };
run(options);
Options
files
: Array of test file paths.args
: Array of custom test arguments. Default: Result of loadingmain
frompackage.json
or./index.js
.test
: Function that runs a test. Default: Result of loadingnode:test
.assert
: Assertion library. Default: Result of loadingnode:assert
.context
: Additional context object to make accessible to each test.
Example
Basic
module.exports = ({ test, assert }) => {
test('it passes', () => {
assert(true);
});
};
Advanced
module.exports = ({ test, assert, context }) => args => {
test('initialises the app', () => {
const app = args.initialise();
assert(context.helpers.appInitialised(app));
});
};