-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
jest.config.js extension errors in a typescript monorepo #11399
Comments
Have you tried to extend jest config using |
This appears... to work. Thank you for the concrete example. So many of the things I'm using this for were explicitly listed as not working by a prior issue (with no correction) so I had wrongly assumed this use-case would present the same problems, but lo-and-behold many (all?) of them have since been fixed. Thanks! I left some comments here #3564 (comment) that apply to this conversation (but, maybe moreso to that one). |
So, I implemented this and it works for every package in our monorepo... except one. I can't seem to figure out why. Jest returns:
For that one package (in To demo this you can clone the repo, run If this is not related to the present GitHub issue, lemme know and I'll open up another issue for whatever is going on with this here. |
I think the code sandbox example isn’t updated with your failed scenario. |
I wish I could, but I don't know of a way to strictly reproduce this with codesandbox. You can, however, reproduce it by cloning insomnia (https://github.com/Kong/insomnia/tree/develop) and looking at the jest-config in Uncomment line 3 to see the problem in action. You may need to run |
I solved the issue I was having. Only too 10 days short of a year to see why. So I have a project structure like this
and in my Well today I noticed (while debugging what has been a very painful jest 27 (now attempted jest 28) upgrade) that if I do How could that be??? Well, I looked into it a little deeper and I noticed another line in my as it turns out. It looks like the rootDir can affect the path resolution of the preset. Mystery solved. I'll add a PR to the documentation to make this a little clearer. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
🐛 Bug Report
In the context of a TypeScript monorepo, TypeScript throws error
ts(6059)
when extending jest configs as recommended.To Reproduce
see this codesandbox to view the error:
https://codesandbox.io/s/nostalgic-architecture-k5eob?file=/packages/client/jest.config.js:187-206
Expected behavior
no error when extending jest configs
Link to repl or repo (highly encouraged)
see this codesandbox to view the error:
https://codesandbox.io/s/nostalgic-architecture-k5eob?file=/packages/client/jest.config.js:187-206
envinfo
see this codesandbox to view the error:
https://codesandbox.io/s/nostalgic-architecture-k5eob?file=/packages/client/jest.config.js:187-206
Problem
In TypeScript monorepo projects, extending the
jest.config.js
likeWhere both
tsconfig.json
s look likeThe following error occurs in the client jest config
Workaround (hacky)
The only way I have found to work around this is to exploit an exception to the rules regarding
rootDir
that was made for json files (microsoft/TypeScript#9858 (comment)) and write the config like this:Other things I tried
I looked at every jest.config.js in this project to see if there's any other way, but non replicate this scenario.
I read through #10991 and #3564 and others but didn't see someone reporting this error.
Proposed Solution
What I am requesting is that instead of the above, I could simply write:
Prior Art
The text was updated successfully, but these errors were encountered: