Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use this plugin with karma? #8

Closed
geekyme opened this issue May 29, 2015 · 4 comments
Closed

How to use this plugin with karma? #8

geekyme opened this issue May 29, 2015 · 4 comments

Comments

@geekyme
Copy link

geekyme commented May 29, 2015

my config:

module.exports = function(config) {
  config.set({

    // 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'],


    // list of files / patterns to load in the browser
    files: [
      // we use this pattern to load test files
      // see https://github.com/webpack/karma-webpack/issues/23
      'tests/tests_index.js'
    ],


    // list of files to exclude
    exclude: [
    ],


    // preprocess matching files before serving them to the browser
    // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
    preprocessors: {
        'tests/tests_index.js': [ 'webpack', 'sourcemap' ]
    },

    webpack: { 
      devtool: 'cheap-source-map', 
      module: {
        loaders: [
          { test: /\.js$/, exclude: /node_modules/, loaders: ["babel?plugins=babel-plugin-rewire"] } // loaders can take parameters as a querystring
        ]
      }
    },

    webpackServer: {
      noInfo: true //please don't spam the console when running in karma!
    },


    // test results reporter to use
    // possible values: 'dots', 'progress'
    // available reporters: https://npmjs.org/browse/keyword/karma-reporter
    reporters: ['dots','html'],


    // 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: ['Chrome'],


    // Continuous Integration mode
    // if true, Karma captures browsers, runs the tests and exits
    singleRun: false,

  });
};

when i do that, then i get the following error:

  Uncaught TypeError: Object.assign is not a function
  at /blah/tests/tests_index.js:953

The error goes away if i remove plugins=babel-plugin-rewire from loaders: ["babel?plugins=babel-plugin-rewire"]

@geekyme
Copy link
Author

geekyme commented May 29, 2015

Turns out I had to enable babel runtime http://babeljs.io/docs/usage/runtime/. might want to document that in readme. :)

@geekyme geekyme closed this as completed May 29, 2015
@Jpunt
Copy link

Jpunt commented Jun 19, 2015

@geekyme: Where and how did you enable the babel runtime?

@Jpunt
Copy link

Jpunt commented Jun 19, 2015

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants