I want to build a small test library with a similar api to bdd frameworks like jest but globals, runner or assertion library.
- Bring your own runner.
- Bring your own assertions.
This is possible because of projects like the web test runner which allows for custom frameworks to be used.
I don't need all the options provided by mocha
and jest
at least not at the moment.
The goals are:
- Tests can be run in any ES module environment. Browser, deno, node (with
{"type": "module"}
). - Support snapshots in
@web/test-runner
. Perhaps a method that can attach a snapshot method to the assertion library being used, that can identify the current test and add it to the snapshot list. - By default tests run concurrently, but a test / suite can be marked as serial to run sequentially.
Things I want in the future:
- Mark tests / suites as expecting failure. This can be used to make a test fail and show up in the console, but not fail the test suite.
For now the interface should be based on the expected output for @web/test-runner-core
interface TestResultError {
message: string;
name?: string;
stack?: string;
expected?: string;
actual?: string;
}
interface TestSuiteResult {
name: string;
/**
* Each suite represents a context.
*/
suites: TestSuiteResult[];
tests: TestResult[];
}
interface TestResult {
name: string;
passed: boolean;
skipped: boolean;
duration?: number;
error?: TestResultError;
}
/**
* The results that are reported back to the test runner.
*/
interface TestSession {
/**
* Did the test session pass?
*/
passed?: boolean;
/**
* The list of errors if any.
*/
errors: TestResultError[];
/**
* All the test results.
*/
testResults?: TestSuiteResult;
}