dimanche 28 juin 2015

Karma-browserify transformations are not done

I've got some problem with karma configuration. The project is being developed using React and Browserify, react components are written using .jsx syntax and project is build with gulp.

Building works fine, but I want to cover ui components with unit tests using karma, jasmine and React.TestUtils.

Also, I use karma-browserify plugin. Generally, it works fine. When i do require('some-module') im my test files, module is imported.

But transformations are not done, when I import some module written in JSX syntax, I get an error:

ERROR [framework.browserify]: bundle error
ERROR [framework.browserify]: Error: Parsing file /path/to/project/src/ui/js/base/icon.jsx: Unexpected token (12:6)

What is wrong in my karma config, why transformations are missed?

module.exports = function (karma) {
  karma.set({
    basePath: './',

    frameworks: ['browserify', 'jasmine'],

    files: ['./**/*.test.js'],

    preprocessors: {
      './**/*.test.js': ['browserify']
    },

    browserify: {
      debug: true,
      transform: ['reactify']
    },

    reporters: ['progress'],

    port: 9876,

    colors: true,

    logLevel: karma.LOG_INFO,

    autoWatch: false,

    browsers: ['Chrome'],

    singleRun: true
  });
};

P.S. I use xubuntu 14.10, node 0.12.4.

Gulp transformation task for browser works fine, it was build like this example

P.P.S. Thanks for your help in advance.

Aucun commentaire:

Enregistrer un commentaire