ember-cli-code-coverage
ember-cli-code-coverage copied to clipboard
Doesn't work with inline babel sourceMaps (ember-cli 2.14.1)
If you enable babel sourceMaps in your ember-cli-build.js
and run COVERAGE=true ember serve/test
you get bunch of errors:
Unable to cover: app/app.js . Newer JS features may need Babel instumentation to work. Try setting useBabelInstrumenter to true in your config/coverage.js.
TypeError: Cannot read property 'sections' of null
at new SourceMapConsumer (/<app_dir>/node_modules/source-map/lib/source-map-consumer.js:20:19)
at Instrumenter.instrumentSync (/<app_dir>/node_modules/ember-cli-code-coverage/lib/babel-istanbul-instrumenter.js:45:20)
at CoverageInstrumenter.processString (/<app_dir>/node_modules/ember-cli-code-coverage/lib/coverage-instrumenter.js:112:25)
at CoverageInstrumenter.processFile (/<app_dir>/node_modules/broccoli-filter/index.js:165:31)
at asyncProcessFile (/<app_dir>/node_modules/broccoli-filter/index.js:122:21)
at tryCatch (/<app_dir>/node_modules/rsvp/dist/rsvp.js:525:12)
at invokeCallback (/<app_dir>/node_modules/rsvp/dist/rsvp.js:538:13)
at /<app_dir>/node_modules/rsvp/dist/rsvp.js:606:14
at flush (/<app_dir>/node_modules/rsvp/dist/rsvp.js:2415:5)
at _combinedTickCallback (internal/process/next_tick.js:131:7)
at process._tickCallback (internal/process/next_tick.js:180:9)
Unable to cover: app/resolver.js . Newer JS features may need Babel instumentation to work. Try setting useBabelInstrumenter to true in your config/coverage.js.
TypeError: Cannot read property 'sections' of null
at new SourceMapConsumer (/<app_dir>/node_modules/source-map/lib/source-map-consumer.js:20:19)
at Instrumenter.instrumentSync (/<app_dir>/node_modules/ember-cli-code-coverage/lib/babel-istanbul-instrumenter.js:45:20)
at CoverageInstrumenter.processString (/<app_dir>/node_modules/ember-cli-code-coverage/lib/coverage-instrumenter.js:112:25)
at CoverageInstrumenter.processFile (/<app_dir>/node_modules/broccoli-filter/index.js:165:31)
at asyncProcessFile (/<app_dir>/node_modules/broccoli-filter/index.js:122:21)
at tryCatch (/<app_dir>/node_modules/rsvp/dist/rsvp.js:525:12)
at invokeCallback (/<app_dir>/node_modules/rsvp/dist/rsvp.js:538:13)
at /<app_dir>/node_modules/rsvp/dist/rsvp.js:606:14
at flush (/<app_dir>/node_modules/rsvp/dist/rsvp.js:2415:5)
at _combinedTickCallback (internal/process/next_tick.js:131:7)
at process._tickCallback (internal/process/next_tick.js:180:9)
Unable to cover: app/router.js . Newer JS features may need Babel instumentation to work. Try setting useBabelInstrumenter to true in your config/coverage.js.
TypeError: Cannot read property 'sections' of null
at new SourceMapConsumer (/<app_dir>/node_modules/source-map/lib/source-map-consumer.js:20:19)
at Instrumenter.instrumentSync (/<app_dir>/node_modules/ember-cli-code-coverage/lib/babel-istanbul-instrumenter.js:45:20)
at CoverageInstrumenter.processString (/<app_dir>/node_modules/ember-cli-code-coverage/lib/coverage-instrumenter.js:112:25)
at CoverageInstrumenter.processFile (/<app_dir>/node_modules/broccoli-filter/index.js:165:31)
at asyncProcessFile (/<app_dir>/node_modules/broccoli-filter/index.js:122:21)
at tryCatch (/<app_dir>/node_modules/rsvp/dist/rsvp.js:525:12)
at invokeCallback (/<app_dir>/node_modules/rsvp/dist/rsvp.js:538:13)
at /<app_dir>/node_modules/rsvp/dist/rsvp.js:606:14
at flush (/<app_dir>/node_modules/rsvp/dist/rsvp.js:2415:5)
at _combinedTickCallback (internal/process/next_tick.js:131:7)
at process._tickCallback (internal/process/next_tick.js:180:9)
Unable to cover: app/templates/application.hbs . Newer JS features may need Babel instumentation to work. Try setting useBabelInstrumenter to true in your config/coverage.js.
TypeError: Cannot read property 'sections' of null
at new SourceMapConsumer (/<app_dir>/node_modules/source-map/lib/source-map-consumer.js:20:19)
at Instrumenter.instrumentSync (/<app_dir>/node_modules/ember-cli-code-coverage/lib/babel-istanbul-instrumenter.js:45:20)
at CoverageInstrumenter.processString (/<app_dir>/node_modules/ember-cli-code-coverage/lib/coverage-instrumenter.js:112:25)
at CoverageInstrumenter.processFile (/<app_dir>/node_modules/broccoli-filter/index.js:165:31)
at asyncProcessFile (/<app_dir>/node_modules/broccoli-filter/index.js:122:21)
at tryCatch (/<app_dir>/node_modules/rsvp/dist/rsvp.js:525:12)
at invokeCallback (/<app_dir>/node_modules/rsvp/dist/rsvp.js:538:13)
at /<app_dir>/node_modules/rsvp/dist/rsvp.js:606:14
at flush (/<app_dir>/node_modules/rsvp/dist/rsvp.js:2415:5)
at _combinedTickCallback (internal/process/next_tick.js:131:7)
at process._tickCallback (internal/process/next_tick.js:180:9)
Just in case, to enable babel sourcemaps, in you ember-cli-build.js:
const EmberApp = require('ember-cli/lib/broccoli/ember-app');
module.exports = function(defaults) {
let app = new EmberApp(defaults, {
babel: {
sourceMaps: 'inline'
}
});
return app.toTree();
};
obviously config/coverage.js
file exists and useBabelInstrumenter
is set to true, once you remove sourceMaps line, coverage works as expected.
Has the same problem with:
options.babel = {
includePolyfill: true
};
or:
options['ember-cli-babel'] = {
includePolyfill: true
};
useBabelInstrumenter
is also true
using [email protected]
I'm running into the same issue when enabling sourceMaps: 'inline' on babel... anyone have more knowledge on how to resolve this?
@erichonkanen Have you tried the latest beta of ember-cli-code-coverage?
@kategengler I did try but I got a different error, something about name
is undefined or something.. I ended up getting around it by doing babel: { sourceMaps: !process.env.COVERAGE ? 'inline' : false }
@erichonkanen are you able to share any code where you were getting the different error? I would expect this problem to be resolved in the latest beta.
@rwwagner90 I got a similar error (cannot read property name was undefined
). The stacktrace pointed to this line where addon
was undefined.
In my package.json
, inside ember-addon
> paths
array, I had an in-repo addon path that didn't actually exist. Removing that fixed the issue. 🙂