When globally testing a (lerna) mono-repository using a simple root jest.config.js:
module.exports = {
projects: ["<rootDir>/packages/*/jest.config.js"]
};
jest doesn't seem to read the packages local jest.config.js when it's run at the root. It works as expected when run in each package.
A minimal example repo is available there to reproduce the issue.
/jest.config.js
module.exports = {
projects: ["<rootDir>/packages/*/jest.config.js"]
};
/packages/web/jest.config.js
const pack = require("./package");
console.log(123);
module.exports = {
displayName: pack.name,
setupFilesAfterEnv: ["<rootDir>/tests/jest.setup.js"],
snapshotSerializers: ["jest-emotion"]
};
/packages/web/tests/jest.setup.js
import { matchers } from "jest-emotion";
expect.extend(matchers);
jest should read the packages local jest.setup.js when setting projects option.
https://github.com/ivangabriele/jest-lerna-reproducible-issue
System:
OS: Windows 10 10.0.18362
CPU: (48) x64 AMD Ryzen Threadripper 2970WX 24-Core Processor
Binaries:
Node: 12.13.1 - C:\Program Files\nodejs\node.EXE
Yarn: 1.19.2 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 6.12.1 - C:\Program Files\nodejs\npm.CMD
npmPackages:
jest: 24.9.0 => 24.9.0
@ivangabriele any news from this?
Boilerplates I've seen seem to define the test command in each package, with a jest config based on the root one. The behaviour you describe would be more consistent with npm or TypeScript for instance.
Most helpful comment
@ivangabriele any news from this?