Jest: Lerna mono-repository root jest doesn't read packages local config

Created on 12 Dec 2019  路  2Comments  路  Source: facebook/jest

馃悰 Bug Report

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.

To Reproduce

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);

Expected behavior

jest should read the packages local jest.setup.js when setting projects option.

Link to repl or repo (highly encouraged)

https://github.com/ivangabriele/jest-lerna-reproducible-issue

envinfo

  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
Bug Report Needs Repro Needs Triage

Most helpful comment

@ivangabriele any news from this?

All 2 comments

@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.

Was this page helpful?
0 / 5 - 0 ratings