Open JounQin opened 3 years ago
Seem like projects
doesnโt inherit from top level config, not sure if other config options have the same behavior too, probably yes.
probably Jest maintainers can tell if projects
can inherit root config options.
probably Jest maintainers can tell if
projects
can inherit root config options.
Unfortunately it does not. I ended up duplicating everything twice for my unit and integration tests setup. https://github.com/facebook/jest/issues/10991#issuecomment-1137699168
The only two options I could find working are
This is somewhat confusing to me, some baffling behavior:
collectCoverage
, coverageReporters
(as mentioned by @igorpupkinable), and verbose
need to be in the root config if they are to work when running jest from the root.preset
and transform
do not seem to be used from the root configI am finding to have this make sense I need to share common config (leveraging an import and spread operator or maybe this: https://github.com/facebook/jest/issues/10991#issuecomment-1185427440) between the root jest config and the sub-projects, so that I can run jest from the root or the sub-projects and have the same behavior. The main benefit I can see right now from using jest projects instead of something like npm workpaces and npm run test --workspaces=true
is the combination of the coverage reporting.
Either this feature is not working as intended, or the documentation is incorrect.
https://jestjs.io/docs/configuration#projects-arraystring--projectconfig
With a monorepo setup, I have a root jest.config.js
which includes
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
projects: ['<rootDir>/packages/**/jest.config.js'],
preset: 'ts-jest',
testEnvironment: 'node',
testPathIgnorePatterns: ['/node_modules/', '<rootDir>/dist/'],
};
Each package contains a jest.config.js
with these contents.
/** @type {import('jest').Config} */
module.exports = {
displayName: 'my-package',
preset: 'ts-jest',
testEnvironment: 'node'
};
However, testPathIgnorePatterns
is not being copied into the child context for each project, and files in /dist
are read by jest. If I add testPathIgnorePatterns
to the child jest.config.js
, then the files are properly ignored.
This issue is stale because it has been open for 1 year with no activity. Remove stale label or comment or this will be closed in 30 days.
Bump
๐ Bug Report
As title.
To Reproduce
Steps to reproduce the behavior:
https://github.com/markuplint/markuplint/blob/main/package.json#L62
move the two
transform
options into top leveltest cases will be unable to run any more.
Expected behavior
No error
Link to repl or repo (highly encouraged)
As above.
envinfo