Configure karma.js to work with react and ES6 Configure karma.js to work with react and ES6 reactjs reactjs

Configure karma.js to work with react and ES6


I believe you just need to add the react file's path to the list of preprocessor files. This is because the react file is also using the commonjs format just like your app's files, and when that file gets loaded in chrome, unlike node, the browser has no notion of where the "module" object came from. Updated excerpt from your code below.

        // list of files / patterns to load in the browser        files: [          'node_modules/karma-babel-preprocessor/node_modules/babel-core/browser-polyfill.js',          'node_modules/react/react.js',          'lib/**/*.js',          'test/**/*.js'        ],        preprocessors: {          // you can probably leave off babel here.          'node_modules/react/react.js': ['babel', 'commonjs'],          'lib/**/*.cjsx': ['cjsx'],          'test/**/*.cjsx': ['cjsx'],          'lib/**/*.js': ['babel', 'commonjs'],          'test/**/*.js': ['babel', 'commonjs']        },