Skip to content

How to call Ava runner/reporter to get test stats. #2787

Answered by richardeschloss
gouravjeet asked this question in Q&A
Discussion options

You must be logged in to vote

A very simple concrete example in case one else lands on this page:

import { spawn } from 'child_process'
import reporter from 'tap-json'

function runTest (file) {
  const ava = spawn('npx', [
    'ava',
    file
  ])
  ava.stdout
    .pipe(reporter())
    .on('data', (report) => {
      console.log(report)
      /* Output */
      /* {
        stats: { asserts: 1, passes: 1, failures: 0 },
        asserts: [
          {
            number: 1,
            comment: null,
            name: 'Module: adds plugin',
            ok: true,
            extra: {}
          }
        ]
      } */
    })
}

runTest('test/module.js')

Seems like TAP is the way to go because of all the reporters it alr…

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
3 replies
@gouravjeet
Comment options

@anthumchris
Comment options

@novemberborn
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by novemberborn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants