Package Exports
- aqa
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (aqa) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
aqa
Dependency-less Test Runner for Node.js
aqa is a light-weight and a quick alternative to ava, with a similar API.
Installation
npm i aqaUsage
Simple single-file usage
your.tests.js:
const test = require('aqa')
test('Test ourself', t => {
t.is(1 + 1, 2);
t.not(1 + 1, 3);
t.true(1 === 1);
t.false(1 === 2);
})node your.tests.js
Integration
To run multiple tests and integrate CI testing with your package, you need to change your package.json's test in the scripts section to "aqa":
"scripts": {
"test": "aqa"
},Then, to run all your tests: npm run test
All files anywhere in your package's directory (and subdirectories) that match *.test.js or *.tests.js will be ran.
Watch mode
To automatically run tests whenever you modify your files, aqa has a watch mode. If you desire this functionality, add a new script to your package.json:
"scripts": {
"test": "aqa",
"test:watch": "aqa --watch"
},To start the watch script, run npm run test:watch.
Assertion
These assertion methods are currently supported:
t.is(actual, expected)
Asserts that actual is equal to expected.
t.not(actual, notEpected)
Asserts that actual is not equal to notEpected.
t.true(value)
Asserts that value is true.
t.false(value)
Asserts that value is false.
t.throws(fn, opts?)
Asserts that fn throws an exception.
function uhOh() {
throw new Error("Uh oh.");
}
t.throws(_ => {
uhOh();
})You can also check for specific types of exception. If the exception does not match it, the test will fail:
t.throws(_ => {
uhOh();
}, { instanceOf: TypeError })t.throwsAsync(fn, opts?)
The asynchronous version of t.throws(). Note the addition of async/await.
test('Async test', async t => {
await t.throwsAsync(async _ => {
await uhOhAsync();
})
})You can also check for specific types of exception. If the exception does not match it, the test will fail:
await t.throws(async _ => {
await uhOhAsync();
}, { instanceOf: TypeError })Work in progress:
- Configuration (globs, paths, etc.)