I've started working with React and Redux and I'd like to write tests for it using Karma with Mocha and PhantomJS2. I'm using the sources here as base: http://ift.tt/1TNQfBi . I basically want to run the tests there in Karma using Phantom instead of using node and the "npm test".
I've set up and installed the required packages for karma:
package.json
"scripts": {
"test:karma": "karma start",
},
"karma": "^0.13.21",
"karma-babel-preprocessor": "^6.0.1",
"karma-mocha": "^0.2.2",
"karma-phantomjs2-launcher": "^0.5.0",
"phantomjs2": "^2.2.0",
And I've tried to figure out how to build my karma.config.js but I don't seem to get my tests to run and this is where I need the help.
karma.config.js
module.exports = function(config) {
process.env.PHANTOMJS_BIN = './node_modules/phantomjs2/lib/phantom/bin';
config.set({
basePath: './',
frameworks: ['mocha'],
plugins: [ 'karma-mocha', 'karma-phantomjs2-launcher', 'karma-babel-preprocessor' ],
files: [
"components/Counter.js",
"test/components/Counter.spec.js"
],
preprocessors: {
"components/Counter.js": ["babel"],
"test/components/Counter.spec.js": ["babel"]
},
babelPreprocessor: {
options: {
"presets": ["es2015", "react"],
}
},
reporters: ['progress'],
browsers: ['PhantomJS2'],
port: 9099,
runnerPort: 9100,
urlRoot: '/',
colors: true,
logLevel: config.LOG_INFO,
autoWatch: false,
singleRun: false,
concurrency: Infinity
})
}
Aucun commentaire:
Enregistrer un commentaire