Async functions get ignored for code coverage
queicherius opened this issue · comments
David Reess commented
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
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?