This repository has been archived by the owner on Jul 28, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
wallaby.conf.js
69 lines (63 loc) · 2.22 KB
/
wallaby.conf.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*globals __dirname */
'use strict';
var babel = require ('babel-core');
var fs = require ('fs');
var path = require ('path');
var babelConfig = JSON.parse (fs.readFileSync (path.join (__dirname, '.babelrc')));
babelConfig.babel = babel;
module.exports = function (wallaby) {
return {
files: [
{pattern: 'test/test-helper.js'},
{pattern: 'src/**/*.js'}
],
tests: [
{pattern: 'src.test/**/*.js'},
],
compilers: {
'**/*.js*': wallaby.compilers.babel (babelConfig)
},
debug: true,
env: {
type: 'node'
},
bootstrap: function (wallaby) {
// See http://wallabyjs.com/docs/config/bootstrap.html
var path = require ('path');
var sep = path.sep;
console.log ('Setup wallaby');
// Ensure that we can require self (just like what module 'require-self'
// does), but remapping by default the path to './src' rather than './lib'
// as specified by package "main".
// See https://github.com/wallabyjs/public/issues/453
var packageConfig = require (path.join (wallaby.localProjectDir, 'package.json'));
var packageName = packageConfig.name;
var modulePrototype = require ('module').Module.prototype;
if (!modulePrototype._originalRequire) {
modulePrototype._originalRequire = modulePrototype.require;
modulePrototype.require = function (filePath) {
if (filePath === packageName) {
return modulePrototype._originalRequire.call (this, path.join (wallaby.projectCacheDir, 'src'));
} else {
return modulePrototype._originalRequire.call (this, filePath);
}
};
}
// Remove react from the require.cache, or else some code might not get
// executed when editing the source code.
// See https://github.com/wallabyjs/public/issues/321
Object.keys (require.cache)
.forEach (function (k) {
if (k.indexOf (sep + 'react' + sep) > -1) {
delete require.cache[k];
}
});
// Include the test helper, which sets up the document and window objects
// as globals:
require ('./test/test-helper');
},
teardown: function () {
console.log ('Teardown wallaby');
}
};
};