Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function buildJestConfig(config: d.Config) {
const jestDefaults = require('jest-config').defaults;
const validJestConfigKeys = Object.keys(jestDefaults);
const jestConfig: d.JestConfig = {};
Object.keys(config.testing).forEach(key => {
if (validJestConfigKeys.includes(key)) {
(jestConfig as any)[key] = (config.testing as any)[key];
}
});
jestConfig.rootDir = config.rootDir;
if (Array.isArray(config.testing.reporters)) {
jestConfig.reporters = config.testing.reporters;
}
return JSON.stringify(jestConfig);