Skip to content

Commit 5aff3c2

Browse files
author
Malte W
committed
added karma
1 parent f13fee2 commit 5aff3c2

File tree

3 files changed

+48
-2
lines changed

3 files changed

+48
-2
lines changed

karma.conf.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/* eslint no-var: 0, no-unused-vars: 0 */
2+
var path = require('path');
3+
var webpack = require('webpack');
4+
5+
module.exports = function karmaConfig(config) {
6+
config.set({
7+
browsers: [ 'Chrome' ],
8+
singleRun: true,
9+
// autoWatch: true,
10+
frameworks: [ 'mocha' ],
11+
files: [ './test.js' ],
12+
preprocessors: {
13+
'./test.js': [ 'webpack', 'sourcemap' ]
14+
},
15+
reporters: [ 'mocha' ],
16+
webpack: {
17+
devtool: 'inline-source-map',
18+
resolve: {
19+
root: path.resolve(__dirname, './src')
20+
},
21+
module: {
22+
loaders: [{
23+
test: /\.js$/,
24+
loader: 'babel',
25+
exclude: /(node_modules)/
26+
}]
27+
}
28+
},
29+
// webpackMiddleware: {
30+
// noInfo: true,
31+
// watchOptions: { poll: 3000 }
32+
// }
33+
});
34+
};

package.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
"build": "babel src --out-dir lib",
99
"build:umd": "webpack src/index.js dist/react-custom-scrollbars.js && NODE_ENV=production webpack src/index.js dist/react-custom-scrollbars.min.js",
1010
"lint": "eslint src test examples",
11-
"test": "NODE_ENV=test mocha --compilers js:babel-register --recursive",
12-
"test:watch": "NODE_ENV=test mocha --compilers js:babel-register --recursive --watch",
11+
"test": "NODE_ENV=test karma start",
12+
"test:watch": "NODE_ENV=test karma start --auto-watch --no-single-run",
1313
"prepublish": "npm run lint && npm run test && npm run clean && npm run build"
1414
},
1515
"repository": {
@@ -44,6 +44,13 @@
4444
"eslint-config-airbnb": "^0.1.0",
4545
"eslint-plugin-react": "^3.5.1",
4646
"expect": "^1.6.0",
47+
"karma": "^0.13.10",
48+
"karma-chrome-launcher": "^0.2.1",
49+
"karma-cli": "^0.1.1",
50+
"karma-mocha": "^0.2.0",
51+
"karma-mocha-reporter": "^1.0.3",
52+
"karma-sourcemap-loader": "^0.3.6",
53+
"karma-webpack": "^1.6.0",
4754
"mocha": "^2.2.5",
4855
"react": "^0.14.3",
4956
"react-dom": "^0.14.3",

test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import expect from 'expect';
2+
window.expect = expect;
3+
4+
const context = require.context('./test', true, /.*\.js$/);
5+
context.keys().forEach(context);

0 commit comments

Comments
 (0)