Collecting test metadata in CircleCI with Ava

Ava does a nice job producing pretty reports, but perhaps you want CircleCI to show you reports in it’s Test Summary section. The CircleCI documentation covers how to collect test metadata with Mocha, but makes no mention of how to do it with Ava. Here’s how:

Ava supports the TAP format. This allows us to use the tap-xunit reporter to produce xUnit (JUnit) XML—which is what CircleCI is looking for.

First we install our dependencies:

yarn add ava tap-xunit --dev

(Exchange yarn for npm if yarn is too hipster for your taste. No problem.)

Then add the following section to your circle.yml file:

test:
override:
- mkdir -p $CIRCLE_TEST_REPORTS/reports
- ava --tap | tap-xunit > $CIRCLE_TEST_REPORTS/reports/ava.xml

Having done this (and presumably git pushed), CircleCI will now collect test metadata.

Bonus

You can include metadata from ESLint, too! ESLint comes with a JUnit formatter, so we can easily add a test step in our circle.yml:

test:
override:
- mkdir -p $CIRCLE_TEST_REPORTS/reports
- eslint --format junit src/ > $CIRCLE_TEST_REPORTS/reports/eslint.xml
- ava --tap | tap-xunit > $CIRCLE_TEST_REPORTS/reports/ava.xml
I always forget to use failsauce.