-
-
Save azangru/9dfde16eb351090c40c33d8214e51985 to your computer and use it in GitHub Desktop.
Karma + Mocha + Webpack
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var webpack = require('webpack'); | |
module.exports = function (config) { | |
config.set({ | |
browsers: [ 'PhantomJS' ], //run in Phantom | |
autoWatch: false, | |
singleRun: true, //just run once by default | |
frameworks: [ 'mocha', 'chai', 'sinon', 'chai-sinon' ], // test frameworks | |
port: 9876, | |
colors: true, | |
logLevel: config.LOG_INFO, | |
files: [ | |
'tests.webpack.js' //just load this file | |
], | |
preprocessors: { | |
'tests.webpack.js': [ 'webpack', 'sourcemap' ] //preprocess with webpack and our sourcemap loader | |
}, | |
reporters: [ 'mocha' ], //report results in this format | |
webpack: { | |
devtool: 'inline-source-map', | |
module: { | |
loaders: [ | |
{ test: /\.js$/, loader: 'babel-loader' } | |
] | |
} | |
}, | |
webpackServer: { | |
noInfo: true | |
}, | |
plugins: [ | |
'karma-mocha', | |
'karma-webpack', | |
'karma-sourcemap-loader', | |
'karma-mocha-reporter', | |
'karma-phantomjs-launcher', | |
'karma-chai', | |
'karma-sinon', | |
'karma-chai-sinon' | |
] | |
}); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "test", | |
"version": "1.0.0", | |
"description": "Why you no work?", | |
"main": "index.js", | |
"scripts": { | |
"test-karma": "./node_modules/.bin/karma start ./karma.conf.js", | |
"start": "webpack --watch", | |
"build": "webpack" | |
}, | |
"author": "", | |
"license": "ISC", | |
"dependencies": { | |
}, | |
"devDependencies": { | |
"babel-core": "^6.9.1", | |
"babel-loader": "^6.2.4", | |
"babel-plugin-module-alias": "^1.5.0", | |
"babel-preset-es2015": "^6.9.0", | |
"bundle-loader": "^0.5.4", | |
"chai": "^3.5.0", | |
"css-loader": "^0.23.1", | |
"karma": "^1.0.0", | |
"karma-chai": "^0.1.0", | |
"karma-chai-sinon": "^0.1.5", | |
"karma-chrome-launcher": "^1.0.1", | |
"karma-mocha": "^1.0.1", | |
"karma-mocha-reporter": "^2.0.4", | |
"karma-phantomjs-launcher": "^1.0.1", | |
"karma-sinon": "^1.0.5", | |
"karma-sourcemap-loader": "^0.3.7", | |
"karma-webpack": "^1.7.0", | |
"mocha": "^2.5.3", | |
"phantomjs": "^2.1.7", | |
"phantomjs-polyfill": "0.0.2", | |
"sinon": "^1.17.4", | |
"sinon-chai": "^2.8.0", | |
"webpack": "^1.13.1" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// My initial intention was to have this file require all the rest of the test files as described here: | |
// https://www.codementor.io/reactjs/tutorial/test-reactjs-components-karma-webpack but for now I am treating it just | |
// as an individual test file | |
import chai from 'chai'; | |
var expect = chai.expect; | |
console.log('I am running'); // don't even have this output in the console | |
describe('basic', function (){ | |
it('works', function () { | |
expect(true).to.equal(true); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment