douglasduteil / isparta

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

I get "isparta instrumenter doesn't seem to run - [preprocessor.coverage]: Line 1: Unexpected token" while using karma-coverage

op1ekun opened this issue · comments

Hi,

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.7
Windows Server 2012 R2

Any help is much appreciated.