-
Notifications
You must be signed in to change notification settings - Fork 15
/
wallaby.js
39 lines (34 loc) · 1.23 KB
/
wallaby.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
/* eslint-env node */
module.exports = function () {
return {
files: [
'extension/*.js',
'tests/*.js',
{ pattern: 'tests/*.spec.js', ignore: true },
],
tests: ['tests/*.spec.js'],
env: {
type: 'node',
runner: 'node',
},
testFramework: 'jest',
setup: () => {
if (!global._vmPatched) {
const vm = require('vm');
const createContext = vm.createContext;
const runInNewContext = vm.Script.prototype.runInNewContext;
// eslint-disable-next-line no-undef
const wallabyGlobals = { $_$wp, $_$wpe, $_$w, $_$wf, $_$wv, $_$tracer };
vm.createContext = function () {
arguments[0] = Object.assign(arguments[0], wallabyGlobals);
return createContext.apply(this, arguments);
};
vm.Script.prototype.runInNewContext = function () {
arguments[0] = Object.assign(arguments[0], wallabyGlobals);
return runInNewContext.apply(this, arguments);
};
global._vmPatched = true;
}
},
};
};