https://github.com/mattriley/node-module-testrunner
Runs test files that export a top level function to enable initialisation.
https://github.com/mattriley/node-module-testrunner
javascript nodejs npm-package test-runner testing-tool
Last synced: 3 months ago
JSON representation
Runs test files that export a top level function to enable initialisation.
- Host: GitHub
- URL: https://github.com/mattriley/node-module-testrunner
- Owner: mattriley
- Created: 2023-06-29T23:50:33.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-09-21T12:28:47.000Z (over 1 year ago)
- Last Synced: 2025-01-31T14:19:14.912Z (4 months ago)
- Topics: javascript, nodejs, npm-package, test-runner, testing-tool
- Language: JavaScript
- Homepage:
- Size: 709 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README-TEMPLATE.md
Awesome Lists containing this project
README
<%- lib.renderOpening() %>
## Install
<%- await lib.renderCode('npm install module-testrunner', 'sh', 'https://www.npmjs.com/package/module-testrunner') %>
## Usage
### CLI
```js
npx test test_files
```### API
```js
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 loading `main` from `package.json` or `./index.js`.
- `test`: Function that runs a test. Default: Result of loading `node:test`.
- `assert`: Assertion library. Default: Result of loading `node:assert`.
- `context`: Additional context object to make accessible to each test.## Example
### Basic
```js
module.exports = ({ test, assert }) => {test('it passes', () => {
assert(true);
});};
```### Advanced
```js
module.exports = ({ test, assert, context }) => args => {test('initialises the app', () => {
const app = args.initialise();
assert(context.helpers.appInitialised(app));
});};
```