Add mocha test bundling with webpack and test running

This commit is contained in:
Tautvidas Sipavičius
2015-08-13 14:11:10 +03:00
parent e01316f9f3
commit 7a43980f32
5 changed files with 43 additions and 4 deletions

View File

@ -83,7 +83,7 @@ class RoboFile extends \Robo\Tasks {
$this->_exec(join(' ', array(
'./node_modules/mocha/bin/mocha',
'-r tests/javascript/mochaTestHelper.js',
'tests/javascript/newsletter_editor/testBundle.js'
'tests/javascript/testBundles/**/*.js'
)));
}

View File

@ -29,6 +29,7 @@
"chai": "2.2.0",
"chai-jq": "0.0.8",
"grunt": "^0.4.5",
"jquery": "2.1.4",
"jsdom": "3.1.2",
"mocha": "2.2.1",
"napa": "^1.2.0",

View File

@ -26,3 +26,5 @@ if (!global.document || !global.window) {
return this.compareDocumentPosition(node) & 16;
};
}
global.$ = global.jQuery = global.window.jQuery = require('../../node_modules/jquery/dist/jquery.js');

View 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');
});
});
});

View File

@ -1,8 +1,10 @@
var path = require('path'),
fs = require('fs');
fs = require('fs'),
_ = require('underscore'),
baseConfig;
// webpack.config.js
module.exports = {
baseConfig = {
name: 'main',
context: __dirname ,
entry: {
admin: './assets/js/admin.js',
@ -46,3 +48,30 @@ module.exports = {
'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'
}
},
})
];