![](/img/trans.png)
[英]Integration of Karma test cases in Jenkins which is configured to run ansible script
[英]Karma not run test cases
我在Karma中使用requirejs
來加載模塊,它運行正常。 當我將requirejs
更改為webpack
,業力不會運行測試用例。 我用mocha
, sinon
, chai
作為我的測試框架。
├── src
| ├── js
| └── a.js
├── test
| ├── spec
| └── test_a.js
這是我的karma.conf.js
:
var webpackConfig = require("../webpack.config");
module.exports = function(config) {
config.set({
basePath: '../',
frameworks: ['mocha', 'chai', 'sinon'],
files: [
'test/**/test_*.js'
],
preprocessors: {
'test/**/test_*.js': ['webpack']
},
webpack: webpackConfig,
proxies: {
'/data/': '/base/test/data/'
},
exclude: [],
client: {
mocha: {
reporter: 'html',
ui: 'bdd'
}
},
reporters: ['progress'],
port: 9876,
colors: true,
logLevel: config.LOG_DEBUG,
autoWatch: false,
browsers: ['PhantomJS', 'Chrome'],
singleRun: false,
concurrency: Infinity
})
}
我的webpack.config.js
是:
var webpack = require('webpack');
var path = require('path');
module.exports = {
context: path.join(__dirname, 'src'),
entry: {
bundle1: './initializer.js'
},
output: {
path: path.join(__dirname, 'src'),
filename: '[name].js'
},
resolve: {
extensions: ['', '.js'],
modulesDirectories: ["./src", "node_modules"]
},
devtool: 'inline-source-map',
module: {
loaders: []
}
}
我的test_a.js
是:
require([
'jquery',
'src/js/a'
], function($, A) { // $ and A load successfully
describe('A', function() {
beforeEach(function() {
//****
});
afterEach(function() {
//****
});
describe('#on()', function() { // will come to this line
it('should ....', function() { //will come to this line too
assert.ok(1 > 0, "A is working"); // never run into the function
});
});
}
}
在我的測試文件中更改require
以define
后,它現在正在工作。 似乎webpack
將使用require
來加載Commonjs模塊作為默認值。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.