Using the AVA test runner
AVA is a modern test runner for Node.js. It stands out because of its ability to embrace new JavaScript language features and cutting-edge properties of Node.js, such as process isolation. In this way, AVA executes tests very quickly and reliably.
To use AVA, you need to install the ava
package from npm:
$ npm install ava --save-dev
This allows you to use the ava
command-line utility. Ideally, run it with npx
as we did with the other tools:
$ npx ava
While Mocha and Jest could also be installed globally, AVA only works in projects as a local dependency. As this is the better setup anyway, there should be no practical downside from this constraint.
As mentioned, AVA is built quite closely on Node.js – following its conventions and rules wherever possible. In this regard, AVA also allows us quite quickly to adapt ESM instead of CommonJS. By modifying package.json
for the project, we get immediate support for using ESM in our tests, too...