Skip to content

Instantly share code, notes, and snippets.

@Js-Brecht
Last active August 9, 2019 23:37
Show Gist options
  • Save Js-Brecht/84ad06ac851af23ea84829fac4dd4fe2 to your computer and use it in GitHub Desktop.
Save Js-Brecht/84ad06ac851af23ea84829fac4dd4fe2 to your computer and use it in GitHub Desktop.
Pulling @craco/craco merged config for jest
const path = require('path');
const reactScriptsPath = path.resolve(path.join('node_modules', 'react-scripts'));
const craPaths = require('react-scripts/config/paths');
const { overrideJest } = require("@craco/craco/lib/features/test/jest");
const { loadCracoConfig } = require("@craco/craco/lib/config");
const { getCraPaths } = require("@craco/craco/lib/cra");
const { removeJestConflictingCustomArgs } = require("@craco/craco/lib/args");
const context = {
env: process.env.NODE_ENV,
};
const cracoConfig = loadCracoConfig(context);
context.paths = getCraPaths(cracoConfig);
overrideJest(cracoConfig, context);
removeJestConflictingCustomArgs();
const createJestConfig = require('react-scripts/scripts/utils/createJestConfig.js');
const config = createJestConfig(
(relativePath) => path.resolve(reactScriptsPath, relativePath),
path.resolve(craPaths.appSrc, ".."),
false
);
module.exports = config;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment