skills17/test-result
This package commonly generates and converts test results.
It can be used to abstract logic for the different testing library helper packages.
Table of contents
Installation
npm install @skills17/test-result
Usage
First, create a new instance for every test run:
import { TestRun, Group, Strategy, Override } from '@skills17/test-result';
const run = new TestRun();
After that, you have to define and add all test groups:
run.addGroup(new Group('CountriesIndex.+', 1, Strategy.Add));
Once all groups have been added, you can start recording tests:
run.recordTest('CountriesIndexAll', false, true);
After that, points and everything else will get calculated automatically.
To get an overview of available getters and other functions, take a look at the class implementations.
Specific test overrides
If specific tests should award more points or have to pass in order that the whole group passes,
overrides can be defined on a group.
group.addOverride(new Override('CountriesIndexJson', true, 0));
Converting to JSON
The whole test run can simply be converted to JSON by passing the object to the JSON.stringify
function:
JSON.stringify(run);
License
MIT