forked from boranton/testcafe-workshop
🌟 Tests working with webpack
This commit is contained in:
parent
d19a4c151f
commit
c0be042b9f
@ -1,3 +1,9 @@
|
||||
var path = require('path');
|
||||
var webpackConfig = require('./webpack.config');
|
||||
var entry = path.resolve(webpackConfig.context, webpackConfig.entry);
|
||||
var preprocessors = {};
|
||||
preprocessors[entry] = ['webpack'];
|
||||
|
||||
// Karma configuration
|
||||
// Generated on Mon Aug 10 2015 05:47:13 GMT-0600 (MDT)
|
||||
|
||||
@ -14,12 +20,7 @@ module.exports = function (config) {
|
||||
|
||||
|
||||
// list of files / patterns to load in the browser
|
||||
files: [
|
||||
'test/**/*Spec.js',
|
||||
'js/helpers.js',
|
||||
'js/view.js',
|
||||
'js/controller.js'
|
||||
],
|
||||
files: [entry],
|
||||
|
||||
|
||||
// list of files to exclude
|
||||
@ -28,8 +29,9 @@ module.exports = function (config) {
|
||||
|
||||
// preprocess matching files before serving them to the browser
|
||||
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
|
||||
preprocessors: {},
|
||||
|
||||
preprocessors: preprocessors,
|
||||
webpack: webpackConfig,
|
||||
webpackMiddleware: {noInfo: true},
|
||||
|
||||
// test results reporter to use
|
||||
// possible values: 'dots', 'progress'
|
||||
@ -61,6 +63,12 @@ module.exports = function (config) {
|
||||
|
||||
// Continuous Integration mode
|
||||
// if true, Karma captures browsers, runs the tests and exits
|
||||
singleRun: false
|
||||
singleRun: false,
|
||||
|
||||
plugins: [
|
||||
require('karma-webpack'),
|
||||
'karma-jasmine',
|
||||
'karma-chrome-launcher'
|
||||
]
|
||||
});
|
||||
};
|
||||
|
||||
13
package.json
13
package.json
@ -6,17 +6,22 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel": "5.8.21",
|
||||
"babel-core": "5.8.21",
|
||||
"babel-core": "5.8.22",
|
||||
"babel-loader": "5.3.2",
|
||||
"css-loader": "0.15.6",
|
||||
"jasmine-core": "2.3.4",
|
||||
"karma": "0.13.8",
|
||||
"karma-chrome-launcher": "0.2.0",
|
||||
"karma-jasmine": "0.3.6",
|
||||
"karma-webpack": "1.7.0",
|
||||
"style-loader": "0.12.3",
|
||||
"webpack": "1.11.0",
|
||||
"webpack-dev-server": "1.10.1"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "karma start",
|
||||
"test:single": "karma start --single-run",
|
||||
"start": "webpack-dev-server"
|
||||
"test": "NODE_ENV=test karma start",
|
||||
"test:single": "NODE_ENV=test karma start --single-run",
|
||||
"start": "webpack-dev-server",
|
||||
"build": "webpack"
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
/*global app, jasmine, describe, it, beforeEach, expect */
|
||||
require('../js/controller');
|
||||
|
||||
describe('controller', function () {
|
||||
'use strict';
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
var path = require('path');
|
||||
|
||||
module.exports = {
|
||||
var config = {
|
||||
entry: './app.js',
|
||||
output: {
|
||||
filename: 'bundle.js',
|
||||
@ -9,11 +9,18 @@ module.exports = {
|
||||
context: here('js'),
|
||||
module: {
|
||||
loaders: [
|
||||
{test: /\.css$/, loaders: ['style', 'css']}
|
||||
{test: /\.css$/, loader: 'style!css'}
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
if (process.env.NODE_ENV === 'test') {
|
||||
config.entry = './ControllerSpec.js';
|
||||
config.context = here('test');
|
||||
}
|
||||
|
||||
module.exports = config;
|
||||
|
||||
function here(d) {
|
||||
return d ? path.join(__dirname, d) : __dirname;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user