Load jest-puppeteer.config.js from <rootDir>
See original GitHub issueš Feature Proposal
When I place my Jest config in a sub-directory my tests actually have a new <rootDir>
, but the jest-puppeteer.config.js
is still loaded from the root of my project.
- jest-puppeteer.config.js
- tests/jest.config.js
$ jest --config tests/jest.config.js
It would be nice however, if I could do this by default.
- tests/jest-puppeteer.config.js
- tests/jest.config.js
$ jest --config tests/jest.config.js
Motivation
IMHO it is more natural to respect the <rootDir>
of Jest and easier to learn/to ādo rightā. Currently I can set JEST_PUPPETEER_CONFIG
, but this is something I need to look up and it is also less āshareableā.
An alternative to get rid of JEST_PUPPETEER_CONFIG
in the case you donāt wanāt to respect <rootDir>
by default would be to make it configurable similar to how ts-jest
handles the tsconfig.json
:
module.exports = {
globals: {
'jest-puppeteer': {
config: '<rootDir>/jest-puppeteer.config.js'
}
}
};
That is still something I need to look up, but at least it is easier to share and I can use <rootDir>
.
Example
If you donāt place your Jest configs in sub-directories everything still works like usual:
- jest-puppeteer.config.js
- jest.config.js
$ jest
If you do place your Jest configs in sub-directories, you can place the corresponding jest-puppeteer.config.js
in the same directory without the need to add custom environment variables.
- tests/jest-puppeteer.config.js
- tests/jest.config.js
$ jest --config tests/jest.config.js
Pitch
Why does this feature belong in the SVGR ecosystem?
What is the SVGR ecosystem?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:7
- Comments:8 (2 by maintainers)
Top GitHub Comments
Right now, you can make jest-puppeteer load jest-puppeteer.config.js from the same directory as jest.config.js by putting this in your jest.config.js:
(Iād love it if this wasnāt necessary and was the default behavior.)
@gregberge https://github.com/smooth-code/jest-puppeteer#jest-puppeteerconfigjs specifically says:
Considering ārootā is often used as ārootDirā in Jest config and also if you use the āprojectsā property, it would be nice to at least use <rootDir> in the code where it is called.
I understand you might want to get rid of jest-puppeteer.config.js but as the issue was submitted a year ago, maybe this could be considered anyway as it makes it more natural than using the env var?