Add mocha test bundling with webpack and test running
This commit is contained in:
@ -83,7 +83,7 @@ class RoboFile extends \Robo\Tasks {
|
|||||||
$this->_exec(join(' ', array(
|
$this->_exec(join(' ', array(
|
||||||
'./node_modules/mocha/bin/mocha',
|
'./node_modules/mocha/bin/mocha',
|
||||||
'-r tests/javascript/mochaTestHelper.js',
|
'-r tests/javascript/mochaTestHelper.js',
|
||||||
'tests/javascript/newsletter_editor/testBundle.js'
|
'tests/javascript/testBundles/**/*.js'
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
"chai": "2.2.0",
|
"chai": "2.2.0",
|
||||||
"chai-jq": "0.0.8",
|
"chai-jq": "0.0.8",
|
||||||
"grunt": "^0.4.5",
|
"grunt": "^0.4.5",
|
||||||
|
"jquery": "2.1.4",
|
||||||
"jsdom": "3.1.2",
|
"jsdom": "3.1.2",
|
||||||
"mocha": "2.2.1",
|
"mocha": "2.2.1",
|
||||||
"napa": "^1.2.0",
|
"napa": "^1.2.0",
|
||||||
|
@ -26,3 +26,5 @@ if (!global.document || !global.window) {
|
|||||||
return this.compareDocumentPosition(node) & 16;
|
return this.compareDocumentPosition(node) & 16;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
global.$ = global.jQuery = global.window.jQuery = require('../../node_modules/jquery/dist/jquery.js');
|
||||||
|
7
tests/javascript/newsletter_editor/testAjax.js
Normal file
7
tests/javascript/newsletter_editor/testAjax.js
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
define('testAjax', [ 'mailpoet', 'ajax'], function(MailPoet) {
|
||||||
|
describe('Ajax submodule', function() {
|
||||||
|
it('has a version', function() {
|
||||||
|
expect(MailPoet.Ajax.version).to.be.a('number');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
@ -1,8 +1,10 @@
|
|||||||
var path = require('path'),
|
var path = require('path'),
|
||||||
fs = require('fs');
|
fs = require('fs'),
|
||||||
|
_ = require('underscore'),
|
||||||
|
baseConfig;
|
||||||
|
|
||||||
// webpack.config.js
|
baseConfig = {
|
||||||
module.exports = {
|
name: 'main',
|
||||||
context: __dirname ,
|
context: __dirname ,
|
||||||
entry: {
|
entry: {
|
||||||
admin: './assets/js/admin.js',
|
admin: './assets/js/admin.js',
|
||||||
@ -46,3 +48,30 @@ module.exports = {
|
|||||||
'jquery': 'jQuery',
|
'jquery': 'jQuery',
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
module.exports = [
|
||||||
|
baseConfig,
|
||||||
|
|
||||||
|
// Configuration specific for testing
|
||||||
|
_.extend({}, baseConfig, {
|
||||||
|
name: 'test',
|
||||||
|
entry: {
|
||||||
|
testAjax: 'testAjax.js',
|
||||||
|
},
|
||||||
|
output: {
|
||||||
|
path: './tests/javascript/testBundles',
|
||||||
|
filename: '[name].js',
|
||||||
|
},
|
||||||
|
resolve: {
|
||||||
|
modulesDirectories: [
|
||||||
|
'node_modules',
|
||||||
|
'assets/js',
|
||||||
|
'tests/javascript/newsletter_editor'
|
||||||
|
],
|
||||||
|
fallback: path.join(__dirname, 'node_modules'),
|
||||||
|
alias: {
|
||||||
|
'handlebars': 'handlebars/runtime.js'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
})
|
||||||
|
];
|
||||||
|
Reference in New Issue
Block a user