Skip to content

Commit 2813f0b

Browse files
committed
support .babelrc in the test command
1 parent b3a09ca commit 2813f0b

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

scripts/test.js

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,28 @@
1-
// TODO need help for customization
1+
process.env.BABEL_ENV = 'test';
2+
process.env.NODE_ENV = 'test';
3+
process.env.PUBLIC_URL = '';
4+
5+
require('react-scripts/config/env');
6+
7+
const patchModule = require('./utils/cache');
8+
9+
const fs = require('fs-extra');
10+
const path = require('path');
11+
12+
const chalk = require('chalk');
13+
const appPath = require('react-scripts/config/paths').appPath;
14+
const webpackMonkeyPath = path.resolve(appPath, 'webpack.monkey.js');
15+
16+
require('react-scripts/config/jest/babelTransform.js')
17+
18+
if (fs.existsSync(webpackMonkeyPath)) {
19+
console.log(chalk.yellow('WARNING! .babelrc file is enabled!'));
20+
const babelJest = require('babel-jest');
21+
patchModule('react-scripts/config/jest/babelTransform.js', babelJest.createTransformer({
22+
presets: [require.resolve('babel-preset-react-app')],
23+
babelrc: true,
24+
configFile: false,
25+
}));
26+
}
27+
228
require('react-scripts/scripts/test');

0 commit comments

Comments
 (0)