Skip to content

Commit

Permalink
chore: resetup wallabyjs for babel
Browse files Browse the repository at this point in the history
  • Loading branch information
maksimr committed Jun 26, 2016
1 parent 3b56f63 commit d3c132f
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 23 deletions.
13 changes: 11 additions & 2 deletions lib/middleware/karma.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ var createKarmaMiddleware = function (
serveStaticFile,
serveFile,
injector,
/* config.basePath */ basePath,
/* config.urlRoot */ urlRoot
basePath,
urlRoot
) {
return function (request, response, next) {
// These config values should be up to date on every request
Expand Down Expand Up @@ -232,5 +232,14 @@ var createKarmaMiddleware = function (
}
}

createKarmaMiddleware.$inject = [
'filesPromise',
'serveStaticFile',
'serveFile',
'injector',
'config.basePath',
'config.urlRoot'
]

// PUBLIC API
exports.create = createKarmaMiddleware
65 changes: 44 additions & 21 deletions wallaby.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
module.exports = function () {
const babel = require('babel-core')

module.exports = function (wallaby) {
return {
files: [
{
Expand All @@ -9,41 +11,62 @@ module.exports = function () {
pattern: 'config.tpl.js',
instrument: false
},
{
pattern: 'test/unit/certificates/server.key',
instrument: false
},
{
pattern: 'test/unit/certificates/server.crt',
instrument: false
},
{
pattern: 'test/unit/**/*.spec.js',
ignore: true
},
'lib/**/*.js',
'test/unit/**/*.js',
'test/unit/mocha-globals.coffee'
'test/unit/mocha-globals.js'
],

tests: [
'test/unit/**/*.spec.coffee'
'test/unit/**/*.spec.js'
],

compilers: {
'**/*.js': wallaby.compilers.babel({
babel: babel
})
},

bootstrap: function (w) {
var path = require('path');
var mocha = w.testFramework;
var path = require('path')
var mocha = w.testFramework

mocha.suite.on('pre-require', function () {

// always passing wallaby.js globals to mocks.loadFile
var mocks = require('mocks');
var loadFile = mocks.loadFile;
var mocks = require('mocks')
var loadFile = mocks.loadFile
mocks.loadFile = function (filePath, mocks, globals, mockNested) {
mocks = mocks || {};
globals = globals || {};
globals.$_$wp = global.$_$wp;
globals.$_$w = global.$_$w;
globals.$_$wf = global.$_$wf;
globals.$_$tracer = global.$_$tracer;
return loadFile(filePath, mocks, globals, mockNested);
};
mocks = mocks || {}
globals = globals || {}
globals.$_$wp = global.$_$wp || {}
globals.$_$wpe = global.$_$wpe || {}
globals.$_$w = global.$_$w || {}
globals.$_$wf = global.$_$wf || {}
globals.$_$tracer = global.$_$tracer || {}
return loadFile(filePath, mocks, globals, mockNested)
}

// loading mocha-globals for each run
require(path.join(process.cwd(), 'test/unit/mocha-globals'));
});
require(path.join(process.cwd(), 'test/unit/mocha-globals'))
})
},

env: {
type: 'node'
type: 'node',
params: {
runner: '--harmony --harmony_arrow_functions'
}
}
};
};
}
}

0 comments on commit d3c132f

Please sign in to comment.