Set up tests - uhop/tape-six GitHub Wiki
Configuring tests
To determine what tests to run and how to access them the test harness uses the following algorithm:
- In the current directory it tries to read
tape6.json
file. - If it is not present, it tries to read
tape6
section ofpackage.json
file. - Otherwise it assumes the default value:
{"tests": ["/tests/test-*.*js"]}
.
When the configuration snippet is found, it is used to configure the test harness:
- A type-related subsection is read. It can be one of the following:
node
,deno
,bun
, orbrowser
depending on the type of the test harness. It is a list of test patterns. - A
tests
subsection is read. It is a list of test patterns. It is added to the list of patterns retrieved previously. - A browser reads the
importmap
section. It is used to configure the browser test harness.
importmap
is the standard import map used in browser tests.
See importmap for more details.
Example of tape6.json
or the tape6
section of package.json
:
{
"tests": [
"/tests/test-*.*js"
],
"importmap": {
"imports": {
"tape-six": "../index.js",
"tape-six/": "../src/"
}
}
}
The example above is taken from package.json
of tape-six
.
Example of tape6
section of package.json
with tests for different environments:
{
"tape6": {
"node": ["/tests/node/test-*.js", "/node/tests/test-*.js"],
"deno": ["/tests/deno/test-*.js", "/deno/tests/test-*.js"],
"tests": ["/tests/test-*.js"],
"importmap": {
"imports": {
"tape-six": "/node_modules/tape-six/index.js",
"tape-six/": "/node_modules/tape-six/src/"
}
}
}
}