forked from plone/volto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jest-extender-plugin.js
31 lines (30 loc) · 1022 Bytes
/
jest-extender-plugin.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
// Extends the Volto test configuration by injecting the keys in `jest.config.js`
const path = require('path');
const fs = require('fs');
const projectRootPath = path.resolve('.');
module.exports = {
modifyJestConfig({
jestConfig: config,
webpackObject,
options: { razzleOptions, pluginOptions },
paths,
}) {
// If the RAZZLE_JEST_CONFIG env var exists, use it as the file with the Jest config
// overrides
if (process.env.RAZZLE_JEST_CONFIG) {
if (
fs.existsSync(`${projectRootPath}/${process.env.RAZZLE_JEST_CONFIG}`)
) {
const jestConfig = require(`${projectRootPath}/${process.env.RAZZLE_JEST_CONFIG}`);
config = { ...config, ...jestConfig };
}
// if not, use the sensible default, `jest.config.js`
} else {
if (fs.existsSync(`${projectRootPath}/jest.config.js`)) {
const jestConfig = require(`${projectRootPath}/jest.config.js`);
config = { ...config, ...jestConfig };
}
}
return config;
},
};