44 sloc
3 files
0 deps
9 dev deps
Runs test files that export a top level function to enable initialisation.
npm install module-testrunner
npx test test_files
const { run } = require('module-testrunner');
const options = { ... };
run(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.
module.exports = ({ test, assert }) => {
test('it passes', () => {
assert(true);
});
};
module.exports = ({ test, assert, context }) => args => {
test('initialises the app', () => {
const app = args.initialise();
assert(context.helpers.appInitialised(app));
});
};