jest 'setupFiles' with <rootDir> breaks libs/apps tests
See original GitHub issuePrerequisites
- I am running the latest version
- I checked the documentation (nx.dev) and found no answer
- I checked to make sure that this issue has not already been filed
- I’m reporting the issue to the correct repository (not related to React, Angular or any dependency)
Expected Behavior
Properly resolve rootDir
when setupFiles
are being used for jest config
Current Behavior
Let’s say my root jest.config.js
is using setupFiles
for various reasons like
const rootConfig = {
rootDir: '.',
setupFiles: ['<rootDir>/test/jest/global.js']
}
now if we wanna run test for particular package which uses root as a preset, setupFiles are not found as jest sets root dir to that particular directory from where are those test executed (so instead of having root ../..
- workspace root, it’s ./libs/my-lib
Failure Information (for bugs)
● Validation Error:
Module <rootDir>/test/jest/global.js in the setupFiles option was not found.
<rootDir> is: /Users/hotell/Projects/devel/workspace/tools
Issue Analytics
- State:
- Created 4 years ago
- Reactions:4
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Configuring Jest
Indicates whether the coverage information should be collected while executing the test. Because this retrofits all executed files with coverage ...
Read more >Top 5 jest-config Code Examples - Snyk
Learn more about how to use jest-config, based on jest-config code examples created from the most popular ways it is used in public...
Read more >Jest globalSetup option not working - Stack Overflow
I'm trying to make a function called loadFixtures available to all Jest tests. I have the following line ...
Read more >Setting up Jest + React-Testing-Library - DEV Community
The setupFiles is executed before the test framework is installed in the environment. For our case, it is especially important, because it will ......
Read more >2021年05月_weixin_39942191的博客_CSDN博客
jest 'setupFiles' with <rootDir> breaks libs/apps tests. 2021-01-12. docs: is there any way how to copy files when building libs/apps via glob. 2021-01-12 ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Just discovered Nx’s Jest builder options: https://nx.dev/web/api/jest/builders/jest#jest
Adding the
setupFile
property to the project angular.json seems like the best solution for our use case:We’re still stuck with referencing the setup file in each individual project, but at least it’s all in one file (angular.json) instead of spread across all of our project-level Jest configs.
Sorry. The issue was marked by mistake. I removed the label.