forked from facebook/fbt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjest.config.js
133 lines (129 loc) · 3.55 KB
/
jest.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
/**
* Copyright 2004-present Facebook. All Rights Reserved.
*
* @format
* @noflow
* @emails oncall+i18n_fbt_js
*/
const path = require('path');
const process = require('process');
const runtimePaths = [
'<rootDir>/runtime/shared',
'<rootDir>/runtime/shared/FbtNumber',
'<rootDir>/runtime/nonfb',
'<rootDir>/runtime/nonfb/mocks',
];
const globalConfig = {
setupFiles: ['fbjs-scripts/jest/environment.js'],
testMatch: ['**/__tests__/**/*-test.js'],
timers: 'fake',
transform: {
'\\.js$': '<rootDir>/jest-preprocessor.js',
},
moduleNameMapper: {
'^FBLocaleToLang$': '<rootDir>/runtime/nonfb/FBLocaleToLang',
},
skipNodeResolution: true,
testEnvironment: 'node',
};
// We need to use absolute paths in order to use this jest config from other working directories.
// See D28405950 for more info.
const toAbsolutePath = (...args) => path.resolve(__dirname, ...args);
module.exports = {
rootDir: __dirname,
projects: [
{
displayName: 'babel-plugin-fbt',
roots: ['<rootDir>/packages/babel-plugin-fbt/dist'],
snapshotResolver:
'<rootDir>/packages/babel-plugin-fbt/jest.snapshotResolver.js',
},
{
displayName: 'babel-plugin-fbt-runtime',
roots: ['<rootDir>/packages/babel-plugin-fbt-runtime'],
},
process.env.BABEL_PLUGIN_STANDALONE_TEST
? {
displayName: 'babel-plugin-standalone',
roots: [`<rootDir>/packages/babel-plugin-standalone`],
}
: null,
{
displayName: 'fbt-runtime',
roots: ['<rootDir>/packages/fbt/lib'],
modulePaths: ['<rootDir>/packages/fbt/lib'],
},
{
displayName: 'gulp-rewrite-flowtyped-modules',
roots: ['<rootDir>/packages/gulp-rewrite-flowtyped-modules'],
},
{
displayName: 'gulp-strip-docblock-pragmas',
roots: ['<rootDir>/packages/gulp-strip-docblock-pragmas'],
},
{
displayName: 'fb-tiger-hash',
roots: ['<rootDir>/packages/fb-tiger-hash'],
transform: {
'\\.js$': [
'<rootDir>/jest-preprocessor.js',
{
plugins: [
toAbsolutePath('node_modules', '@babel/plugin-syntax-bigint'),
],
},
],
},
},
{
displayName: 'top-level',
roots: ['__tests__'],
},
{
displayName: 'demo-app',
setupFiles: [
'fbjs-scripts/jest/environment.js',
'<rootDir>/demo-app/run_all.js',
],
roots: ['<rootDir>/demo-app'],
modulePaths: [
'<rootDir>/demo-app/src',
'<rootDir>/demo-app/src/example',
].concat(runtimePaths),
transformIgnorePatterns: [
'/node_modules/',
'<rootDir>/demo-app/run_all\\.js',
],
moduleNameMapper: {
...globalConfig.moduleNameMapper,
'\\.(css)$': '<rootDir>/demo-app/jest/css.js',
},
timers: 'fake',
transform: {
'\\.js$': [
'<rootDir>/jest-preprocessor.js',
{
plugins: [
[
toAbsolutePath('node_modules', 'babel-plugin-fbt'),
{
fbtCommonPath: toAbsolutePath(
'demo-app',
'common_strings.json',
),
fbtEnumPath: toAbsolutePath(
'demo-app',
'.enum_manifest.json',
),
},
],
toAbsolutePath('node_modules', 'babel-plugin-fbt-runtime'),
],
},
],
},
},
]
.filter(Boolean)
.map(project => ({...globalConfig, ...project})),
};