Running tests
kscript test with no paths runs every test file in the current project: the folder of the nearest kscript.json, or the current folder if there isn't one. Folders whose names start with ., and node_modules, bin and obj, are skipped. You may also name folders and files, or pick tests by name:
| Command | What it does |
|---|---|
kscript test | The project's tests a change can affect. |
kscript test --all | Every test in the project. |
kscript test --failed | Only the tests that failed last time. |
kscript test --changed | The tests your uncommitted changes can affect. |
kscript test --changed master | The tests this branch's changes can affect. |
kscript test --watch | Run the affected tests each time you save. |
kscript test tests/cart tests/api.test.kscript | A folder and a file. |
kscript test --filter "cart › adds" | Only tests whose full name contains the text (any case) |
kscript test --timeout 30 | Seconds per test (0: no limit) |
kscript test --junit test-results.xml | Also write a JUnit XML report. |
kscript tests/cart.test.kscript runs one file too.
Colours are used when the output is a terminal; set NO_COLOR to turn them off or FORCE_COLOR to keep them. Ctrl+C stops the run after the current test.
--junit writes the results in the JUnit XML format that GitHub Actions reporters, GitLab, Jenkins and Azure Pipelines can show. A failed check is a <failure>, another error is an <error>, and a file that couldn't run is reported as an <error> on a test named (load).