Content-Length: 282566 | pFad | http://github.com/angular/angular/pull/61380

45 feat(zone.js): Allow fakeAsync to be used outside of ProxyZone with warning by atscott · Pull Request #61380 · angular/angular · GitHub
Skip to content

Conversation

atscott
Copy link
Contributor

@atscott atscott commented May 15, 2025

As an alternative to monkey patching vitest, this change updates fakeAsync to allow uses outside of a ProxyZone. This would mean that the fakeAsync closure may not capture all timers and microtasks if it invokes things created in a zone that was already forked (e.g. creating a component in a beforeEach):

// This is the zone which will be used for running individual tests.
// It will be a proxy zone, so that the tests function can retroactively install
// different zones.
// Example:
// - In beforeEach() do childZone = Zone.current.fork(...);
// - In it() try to do fakeAsync(). The issue is that because the beforeEach forked the
// zone outside of fakeAsync it will be able to escape the fakeAsync rules.
// - Because ProxyZone is parent fo `childZone` fakeAsync can retroactively add
// fakeAsync behavior to the childZone.

@angular-robot angular-robot bot added detected: feature PR contains a feature commit area: zones Issues related to zone.js labels May 15, 2025
@ngbot ngbot bot added this to the Backlog milestone May 15, 2025
@atscott atscott force-pushed the fakeAsyncWithoutProxyPatch branch 3 times, most recently from ba3bfe4 to 70fee47 Compare May 15, 2025 22:38
atscott added 2 commits May 20, 2025 13:52
…arning

As an alternative to monkey patching vitest, this change updates
`fakeAsync` to allow uses outside of a `ProxyZone`. This would mean that
the `fakeAsync` closure may not capture all timers and microtasks if it
invokes things created in a zone that was already forked (e.g. creating
a component in a beforeEach:
https://github.com/angular/angular/blob/2699dd65558d70fadeac1e9b420841f3dfc3a059/packages/zone.js/lib/jasmine/jasmine.ts#L363-L371)
@atscott atscott force-pushed the fakeAsyncWithoutProxyPatch branch 2 times, most recently from 50eb4d6 to 0fa762b Compare May 21, 2025 18:39
@atscott atscott force-pushed the fakeAsyncWithoutProxyPatch branch from 0fa762b to f159894 Compare May 21, 2025 18:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: zones Issues related to zone.js detected: feature PR contains a feature commit
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/angular/angular/pull/61380

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy