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
|
// Karma configuration
|
||||||
// Generated on Mon Aug 10 2015 05:47:13 GMT-0600 (MDT)
|
// 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
|
// list of files / patterns to load in the browser
|
||||||
files: [
|
files: [entry],
|
||||||
'test/**/*Spec.js',
|
|
||||||
'js/helpers.js',
|
|
||||||
'js/view.js',
|
|
||||||
'js/controller.js'
|
|
||||||
],
|
|
||||||
|
|
||||||
|
|
||||||
// list of files to exclude
|
// list of files to exclude
|
||||||
@ -28,8 +29,9 @@ module.exports = function (config) {
|
|||||||
|
|
||||||
// preprocess matching files before serving them to the browser
|
// preprocess matching files before serving them to the browser
|
||||||
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
|
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
|
||||||
preprocessors: {},
|
preprocessors: preprocessors,
|
||||||
|
webpack: webpackConfig,
|
||||||
|
webpackMiddleware: {noInfo: true},
|
||||||
|
|
||||||
// test results reporter to use
|
// test results reporter to use
|
||||||
// possible values: 'dots', 'progress'
|
// possible values: 'dots', 'progress'
|
||||||
@ -61,6 +63,12 @@ module.exports = function (config) {
|
|||||||
|
|
||||||
// Continuous Integration mode
|
// Continuous Integration mode
|
||||||
// if true, Karma captures browsers, runs the tests and exits
|
// 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": {
|
"devDependencies": {
|
||||||
"babel": "5.8.21",
|
"babel": "5.8.21",
|
||||||
"babel-core": "5.8.21",
|
"babel-core": "5.8.22",
|
||||||
"babel-loader": "5.3.2",
|
"babel-loader": "5.3.2",
|
||||||
"css-loader": "0.15.6",
|
"css-loader": "0.15.6",
|
||||||
"jasmine-core": "2.3.4",
|
"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",
|
"style-loader": "0.12.3",
|
||||||
"webpack": "1.11.0",
|
"webpack": "1.11.0",
|
||||||
"webpack-dev-server": "1.10.1"
|
"webpack-dev-server": "1.10.1"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "karma start",
|
"test": "NODE_ENV=test karma start",
|
||||||
"test:single": "karma start --single-run",
|
"test:single": "NODE_ENV=test karma start --single-run",
|
||||||
"start": "webpack-dev-server"
|
"start": "webpack-dev-server",
|
||||||
|
"build": "webpack"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
/*global app, jasmine, describe, it, beforeEach, expect */
|
/*global app, jasmine, describe, it, beforeEach, expect */
|
||||||
|
require('../js/controller');
|
||||||
|
|
||||||
describe('controller', function () {
|
describe('controller', function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
var path = require('path');
|
var path = require('path');
|
||||||
|
|
||||||
module.exports = {
|
var config = {
|
||||||
entry: './app.js',
|
entry: './app.js',
|
||||||
output: {
|
output: {
|
||||||
filename: 'bundle.js',
|
filename: 'bundle.js',
|
||||||
@ -9,11 +9,18 @@ module.exports = {
|
|||||||
context: here('js'),
|
context: here('js'),
|
||||||
module: {
|
module: {
|
||||||
loaders: [
|
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) {
|
function here(d) {
|
||||||
return d ? path.join(__dirname, d) : __dirname;
|
return d ? path.join(__dirname, d) : __dirname;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user