-
Notifications
You must be signed in to change notification settings - Fork 0
/
wallaby.config.js
134 lines (115 loc) · 2.91 KB
/
wallaby.config.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/**
* This file is managed by backtrack
*
* source: @backtrack/preset-jest
* namespace: wallaby
* namespace: wallabySetup
*
* DO NOT MODIFY
*/
'use strict';
const { Backtrack } = require('@backtrack/core');
const { configManager } = new Backtrack();
const ignore = [
'!**/node_modules/**',
'!**/dist/**',
'!**/build/**',
'!**/coverage/**',
'!**/.git/**',
'!**/.idea/**',
'!**/.vscode/**',
'!**/.cache/**',
'!**/.DS_Store/**',
'!**/flow-typed/**',
];
module.exports = (wallabyInitial) => {
/**
* Needed for monorepo
*/
process.env.NODE_PATH = require('path').join(
wallabyInitial.localProjectDir,
'../../node_modules',
);
const wallabyConfig = configManager({
namespace: 'wallaby',
config: {
files: [
...ignore,
{ pattern: '*', instrument: false },
{ pattern: '.*', instrument: false },
{ pattern: '**/__sandbox__/**/*', instrument: false },
{ pattern: '**/__sandbox__/**/.*', instrument: false },
'**/!(*.test).+(js|jsx|ts|tsx|mjs)',
{ pattern: '**/.*', instrument: false },
{ pattern: '**/!(*.test).*', instrument: false },
],
tests: [
...ignore,
'!**/__sandbox__/**',
'**/*.test.+(js|jsx|ts|tsx|mjs)',
],
compilers: {
'src/**/*.+(js|jsx)': wallabyInitial.compilers.babel(),
'**/*.+(ts|tsx)': wallabyInitial.compilers.babel(),
},
hints: {
ignoreCoverage: /ignore coverage/,
},
env: {
type: 'node',
runner: 'node',
},
testFramework: 'jest',
setup: configManager({
namespace: 'wallabySetup',
config: (wallabySetup) => {
/**
* link node_modules inside wallaby's temp dir
*
* https://github.com/wallabyjs/public/issues/1663#issuecomment-389717074
*/
const fs = require('fs');
const path = require('path');
const realModules = path.join(
wallabySetup.localProjectDir,
'node_modules',
);
const linkedModules = path.join(
wallabySetup.projectCacheDir,
'node_modules',
);
try {
fs.symlinkSync(realModules, linkedModules, 'dir');
// eslint-disable-next-line no-empty
} catch (error) {}
/**
* https://github.com/wallabyjs/public/issues/1268#issuecomment-323237993
*
* reset to expected wallaby process.cwd
*/
process.chdir(wallabySetup.projectCacheDir);
try {
require('core-js/stable');
} catch (e1) {
try {
require('@babel/polyfill');
// eslint-disable-next-line no-empty
} catch (e2) {}
}
process.env.NODE_ENV = 'test';
const jestConfig = require('./jest.config.js');
wallabySetup.testFramework.configure(jestConfig);
const setupFileExists = fs.existsSync('./wallaby.setup.js');
if (setupFileExists === true) {
/**
* Run custom wallaby setup script
*/
require('./wallaby.setup.js')(wallabySetup);
}
process.env.WALLABY = 'true';
},
}),
},
});
return wallabyConfig;
};