-
-
Notifications
You must be signed in to change notification settings - Fork 279
fix(vite-plugin-angular): prevent context loss for "each" tests #1190
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
Conversation
✅ Deploy Preview for analog-docs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for analog-blog ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for analog-app ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for analog-ng-app ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Thanks @gultyayev! Will you apply the change here also? https://github.com/analogjs/analog/blob/beta/packages/vitest-angular/setup-zone.ts |
Sure. However, I just realised that somehow my fix works only when a test is run via WebStorm 🤔 If I run Now I feel even more related to the Gif |
Oh, interesting 🤔 |
That's correct. This assumes you're using the patched globals |
Is there a way for us to also patch the imports? |
Maybe, but I'd stay clear of doing that for now. |
I can see two points for improvements now:
I guess I could raise two separate MRs to followup. |
That would be helpful, thanks |
Thanks! @allcontributors add @gultyayev for code |
I've put up a pull request to add @gultyayev! 🎉 |
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
Which package are you modifying?
What is the current behavior?
Currently, when zones are wrapping the test function the context is lost causing an error "Cannot read
withContext()
of undefined".Closes #1115
What is the new behavior?
The original fn contains the mentioned
withContext()
method. I added reference to the initial method to the bounding function in order to preserve context.Does this PR introduce a breaking change?
Other information
I'm not sure how to properly test this change. I did not find tests for
setup-vitest
. I also failed to test this package usingnpm link
as it failed complainingThe original fix was found by tinkering the
setup-vitest.js
file from node_modules from the repro in the issue. I applied the same changes to the .ts file.[optional] What gif best describes this PR or how it makes you feel?