Test Runner Module
Node professionals may now develop project tests without having to rely on third-party packages or libraries. This is one of the most important enhancements included in this edition.
It allows experts to write JavaScript tests and present the results in TAP format. When a disc image is generated from a data storage tape prepared for ZX spectrum systems or C64 computers, it is referred to as TAP format. To go there, type:
Import test from ‘Node:test’;
Here is an example of it:
test('top level test', async (d) => {
await d.test('subtest 1', () => {
assert.strictEqual(1, 1);
});
await d.test('subtest 2', () => {
assert.strictEqual(2, 2);
});
});
The test runner module is only available when using the node: prefix. Note that the node: prefix indicates the loading of a core module. If the prefix is left out, importing ‘test’ would attempt to load a userland module.