Because JS unit testing shouldn't be complicated.
Features
- A dead-simple setup because you just want to test your code.
- Familiar test definition methods because they make sense.
- Plain assertion methods because code.is.not.text.
- Predictable naming because you're tired of looking at docs.
- ES5 support because you're not always babelifying everything.
- Browser and node support because your project could be anything.
- Concise output with diffs because you just want to see what went wrong.
- Global, require, and import support because that part is up to you.
- Baked in performance testing because perf matters.
Install
Browser
To get up and running in the browser, link the included CSS/JS:
Then link your source files and tests:
The tests will run and output in the browser:
Node
In node, simply execute the script provided:
Or in npm versions below 5.2.0:
The tests will run and output in the console:
By default the runner will find tests like
test/userTest.js
,
test/tests/user.js
,
spec/userSpec.js
spec/specs/user.js
etc.
You can also add it to your
package.json
file to run with
npm test
:
Usage
- Define tests with familiar describe and it blocks:
- Test your code with readable assertion methods:
- Focus or skip tests or suites with a single character:
- Return a promise to wait for code to run:
- Or with async/await:
- Run support code with standard before/after methods:
Other Features
- All code blocks run synchronously unless they return a promise.
- Easy browser configuration with data attributes.
- Nestable suites to help organize your tests.
- Fold mode to output nesting at different levels of detail.
- Runner watches directories and re-runs tests in node.
- Test randomization and features to help track down race conditions.
- Older IE support with polyfills.
- Custom assertions.