Back to Gatsby

Add AVA

deprecated-packages/gatsby-recipes/recipes/ava.mdx

2.20.0926 B
Original Source

Add AVA

This recipe helps you setup AVA in your Gatsby site to test components and utilities.

This recipe:


Installs the ava package.

<NPMPackage name="ava" />

Adds some AVA test files for you to play with.

<File path="src/ava-example/sum.js" content="https://gist.githubusercontent.com/Slashgear/d14bc99dc2ca3f08351579d1eceb1b2e/raw/c368b1db22e44bf5c4a4814a008bbbf3aa5652a1/sum.js" />

<File path="src/ava-example/sum.test.js" content="https://gist.githubusercontent.com/Slashgear/48f654e5d42765f4adf0725ed1cf7de4/raw/831c58be0dd8c308dba1cc24f0d4c37855f6d0aa/sum.test.js" />


Adds a test & test:watch scripts to your package.json.

Then you can run npm run test — AVA will run your test!

While writing tests you can run npm run test:watch and tests will re-run as you edit them.

<NPMScript name="test" command="ava" />

<NPMScript name="test:watch" command="ava --watch" />