Skip to content
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

Multiple projects - file resolution caching is shared though seperate resolvers can be specified #6724

Closed
lukeapage opened this issue Jul 20, 2018 · 9 comments

Comments

@lukeapage
Copy link
Contributor

lukeapage commented Jul 20, 2018

🐛 Bug Report

When using projects, the resolver caches between those projects even if different resolver's are specified.

To Reproduce

Steps to reproduce the behavior:

  1. have 2 projects
  2. have the resolvers in each project resolve to different files e.g. test.a.js and test.b.js
  3. have a test file in each project that requires the same file e.g. 'test.js' which you want resolved to .a and .b
  4. run the projects together - the first resolution gets cached
  5. run the projects seperately - each project gets a different resolution

Expected behavior

I would expect that since projects can specify resolvers per project, that jest would not cache between them

I will try working on a PR since this is a feature I need.

In our codebase we compile multiple variants of our app and we use a string in the import statements to differentiate between the apps. I want to make it so that spec.a.js and spec.b.js resolve with preference to .a. and .b. respectively.. and apart from this hurdle it seems to work..

@thymikee
Copy link
Collaborator

thymikee commented Jul 20, 2018

Accidentally closed wrong issue, sorry!

@thymikee thymikee marked this as a duplicate of #5741 Jul 20, 2018
@thymikee thymikee reopened this Jul 20, 2018
@lukeapage
Copy link
Contributor Author

no problem. Now I've started to try and fix it I am not convinced jest is wrong any more!

@thymikee
Copy link
Collaborator

Cool, thanks for following up!

@lukeapage lukeapage reopened this Jul 20, 2018
@lukeapage
Copy link
Contributor Author

From what I can tell, it seems like when runInBand is off, jest can confuse resolvers between projects.. ? But I'm pretty convinced its a jest problem, its just intermittant.

@lukeapage
Copy link
Contributor Author

resolvers are cached by config.name here: https://github.com/facebook/jest/blob/master/packages/jest-runner/src/test_worker.js#L61
but config.name doesn't change for different projects...

@lukeapage
Copy link
Contributor Author

setting name on the project is a work-around - it overrides the GUID it gets from somewhere so it cache breaks correctly.
It should calculate the "name" guid based on each project, not one for all projects. If I work out where in jest it does this I will make a PR

@thymikee
Copy link
Collaborator

We have a WIP PR on something similar already, but we didn't settle on implementation yet. Feel free to check out and find some inspiration: #5862

@lukeapage
Copy link
Contributor Author

yep its a exact duplicate of #5597 thanks

@github-actions
Copy link

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.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants