I use karma-systemjs to be able to test my ES6 code with karma. This way I don't have to transpile it before I can run tests (also written in ES6). Unfortunately I can't make use of karma-coverage due to an issue with ES6 instrumenter - isparta.
I've basically copied the usage example from here isparta@npm, and here karma-systemjs@github. I've also experimented with different versions of karma-coverage and isparta still with no avail.
Whatever I do I always get:
ERROR [preprocessor.coverage]: Line 1: Unexpected token
followed by:
Fatal error: Not a string or buffer
It looks like the instrumenter is not firing, and karma-coverage is trying to instrument ES6 without knowing what it is...
When I disable coverage preprocessor all the tests run just fine. I also use the same version of karma-coverage when I still test ES5 code.
Here's my karma.conf.js file:
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['jasmine', 'systemjs'],
// list of files / patterns to load in the browser
files: [
{pattern: 'app/**/*.js', included: false},
{pattern: 'test/**/*.js', included: false},
{pattern: 'jspm_packages/**/*.js', included: false}
],
exclude: [
'jspm_packages/**/*.test.js',
'jspm_packages/**/*.spec.js'
],
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
'app/**/*.js': [ 'coverage' ]
},
coverageReporter: {
reporters: [
{
type: 'text-summary'
}
],
instrumenters: {
isparta : require('isparta')
},
instrumenter: {
'app/**/*.js': 'isparta'
}
},
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: [
'spec',
'coverage'
],
// web server port
port: 9876,
// enable / disable colors in the output (reporters and logs)
colors: true,
// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,
// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,
// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['PhantomJS'],
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: true,
plugins: [
'karma-systemjs',
'karma-phantomjs-launcher',
'karma-jasmine',
'karma-spec-reporter',
'karma-coverage',
],
systemjs: {
// Path to your SystemJS configuration file
configFile: 'config.js',
// File patterns for your application code, dependencies, and test suites
serveFiles: [
'app/**/*.js',
'test/**/*.js',
'jspm_packages/**/*.js',
],
// Specify the suffix used for test suite file names. Defaults to .test.js, .spec.js, _test.js, and _spec.js
testFileSuffix: '.spec.js'
}
All relevant module versions I use:
karma@0.13.19,
karma-coverage@0.4.2,
karma-systemjs@0.7.2,
isparta@3.5.3,
babel@5.8.34
I run the tests using:
node.js@0.12.7Windows Server 2012 R2
Hi,
I use
karma-systemjs
to be able to test my ES6 code withkarma
. This way I don't have to transpile it before I can run tests (also written in ES6). Unfortunately I can't make use ofkarma-coverage
due to an issue with ES6 instrumenter -isparta
. I've basically copied the usage example from here isparta@npm, and here karma-systemjs@github. I've also experimented with different versions ofkarma-coverage
andisparta
still with no avail.Whatever I do I always get:
ERROR [preprocessor.coverage]: Line 1: Unexpected token
followed by:Fatal error: Not a string or buffer
It looks like the instrumenter is not firing, and
karma-coverage
is trying to instrument ES6 without knowing what it is... When I disablecoverage
preprocessor all the tests run just fine. I also use the same version ofkarma-coverage
when I still test ES5 code.Here's my
karma.conf.js
file:All relevant module versions I use:
karma@0.13.19
,karma-coverage@0.4.2
,karma-systemjs@0.7.2
,isparta@3.5.3
,babel@5.8.34
I run the tests using:
node.js@0.12.7
Windows Server 2012 R2
Any help is much appreciated.