guybedford / chomp

'JS Make' - parallel task runner for the frontend ecosystem with a JS extension system.
https://chompbuild.com
Apache License 2.0
143 stars 7 forks source link

feat: unit testing pattern #56

Closed guybedford closed 2 years ago

guybedford commented 2 years ago

This creates a pattern for defining tasks as unit tests, using interpolation to iterate over the tests, even though there is no task target - a really nice way to setup testing in a codebase!

Example:

[[task]]
name = "test:unit"
dep = "unit/#.js"
run = "node $DEP"

With this pattern chomp test:unit is a full unit test runner, and displays ticks and crosses since all tasks are already based on being either an error or a success. By default unit tests will run in parallel, and setting serial = true will run unit tests serially. All within the same simple task system.

guybedford commented 2 years ago

Sample output:

🞂 unit/testa.js
🞂 unit/testb.js
√ unit/testa.js [39.9074ms]
√ unit/testb.js [38.9873ms]
√ :test:unit