Morse is a simple, easy, fast unit test runner for JavaScript / TypeScript.
- No extra command
- No complex document
- Tiny architecture
- High speed operation by parallel test execution
- Easy-to-read test results
- Async function support
- Zero runtime dependencies
- Easy to extend because it is based on the default functions of JS
Morse provides only a minimal test environment.
You can install from npm
command.
npm install --save-dev morse-unit-test
Tests can be run on any directory or file. Tests are defined as functions in objects.
Tests can use regular functions as well as asynchronous functions using async / await
.
// import { doTest } from 'Morse';
const Morse = require('Morse');
const tests = {
'Test to be failed': (assert) => {
assert(2, 1); // failed
// assert(false) // Same as above
},
'Test to be passed': (assert) => {
assert(2, 1+1); // passed
// assert(true) // Same as above
},
'Test async function': async () => {
const result = await someAsyncFunction();
assert(result !== undefined);
}
}
Morse.doTest(tests);
Currently, the order of testing is not guaranteed. In particular, when performing tests using async / await
, the order may change.
Execute directly with the node
command.
node yourTest.js
The results are displayed in the console.
There are 4 types of assertion results:
PASSED (.)
Test completed without any problems.FAILED (F)
test result did not match expected value.ERROR (E)
An exception occurred during the test operation.UNSAFE (U)
The test completed successfully, but no assertions were performed.