-
Notifications
You must be signed in to change notification settings - Fork 148
/
wallaby.js
62 lines (52 loc) · 1.77 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/* eslint-disable @typescript-eslint/no-var-requires */
module.exports = function () {
var pkg = require('./package.json');
var path = require('path');
process.env.BABEL_ENV = 'test';
process.env.NODE_ENV = 'test';
process.env.DEBUG_PRINT_LIMIT = 50000;
process.env.NODE_PATH +=
path.delimiter +
path.join(__dirname, 'node_modules') +
path.delimiter +
path.join(__dirname, 'node_modules/react-scripts/node_modules');
require('module').Module._initPaths();
return {
files: [
{ pattern: 'src/setupTests.ts', instrument: false },
'src/**/*.+(ts|tsx|jsx|json|snap|css|less|sass|scss|jpg|jpeg|gif|png|svg)',
'!src/**/*.spec.ts?(x)',
],
tests: ['src/**/*.spec.ts?(x)'],
filesWithNoCoverageCalculated: pkg.jest.collectCoverageFrom
.filter(f => f.startsWith('!<rootDir>/'))
.map(f => f.replace('!<rootDir>/', '')),
hints: {
ignoreCoverageForFile: /istanbul ignore file/,
},
env: {
type: 'node',
},
preprocessors: {
'**/*.js?(x)': file =>
require('@babel/core').transform(file.content, {
sourceMap: true,
compact: false,
filename: file.path,
presets: [require('babel-preset-jest'), 'react-app'],
}),
},
setup: wallaby => {
const jestConfig = require('react-scripts/scripts/utils/createJestConfig')(p =>
require.resolve('react-scripts/' + p),
);
delete jestConfig.testRunner;
delete jestConfig.testEnvironment;
jestConfig.rootDir = wallaby.localProjectDir;
jestConfig.modulePaths.push('<rootDir>/src/');
jestConfig.setupFilesAfterEnv = [wallaby.localProjectDir + 'src/setupTests.js'];
wallaby.testFramework.configure(jestConfig);
},
testFramework: 'jest',
};
};