douglasduteil / isparta

:skull: A code coverage tool for ES6 (babel/6to5)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Async functions get ignored for code coverage

queicherius opened this issue · comments

I am trying to test async functions. The tests work, but the function gets ignored in the code coverage.

Code:

async function foo () {
  return 'bar'
}

module.exports = foo

Test:

const expect = require('chai').expect
const module = require('../src/test.js')

describe('test', () => {
  it('generates code coverage', async () => {
    let c = await module()
    expect(c).to.equal('bar')
  })
})

Test command:

./node_modules/babel-cli/bin/babel-node.js ./node_modules/.bin/isparta cover --include-all-sources ./node_modules/.bin/_mocha -- tests/ --recursive

Result:

  • The test passes
  • It gets marked for 100% code coverage
  • 5 statements, 2 functions, 2 branches Ignored

screen shot 2016-01-30 at 21 00 37

Expected result:

  • The test passes
  • 100% code coverage
  • The function doesn't get ignored in the code coverage

Am I expecting something wrong when testing this?