analog: Can't test with `it/describe.each` and `fakeAsync`
Please provide the environment you discovered this bug in.
https://stackblitz.com/~/github.com/jahusa02/analog-vitest
Which area/package is the issue in?
vitest-angular
Description
When a testfile contains it/describe.each and fakeAsync the tests errors out.
I described the error in this Issue https://github.com/analogjs/analog/issues/841#issuecomment-2110296265|
When I use the patched function (e.g. not importing it via import { it } from 'vitest'), the it.each tests will fail.
TypeError: Cannot read properties of undefined (reading 'withContext')
❯ ../../../packages/vite-plugin-angular/setup-vitest.ts:247:31
❯ src/lib/+state/effects/add-pending-contract/add-pending-contract.effects.spec.ts:98:6
96| { formStateValid: false, contractId: 'foo', satznummer: null },
97| { formStateValid: false, contractId: null, satznummer: 'bar' },
98| ])(
| ^
99| 'should not post form values if ContractIds are %j',
100| ({ formStateValid, contractId, satznummer }) => {
❯ _ZoneDelegate.invoke ../../../node_modules/zone.js/fesm2015/zone.js:365:28
❯ ZoneImpl.run ../../../node_modules/zone.js/fesm2015/zone.js:111:43
❯ ../../../packages/vite-plugin-angular/setup-vitest.ts:41:21
When I importing it, the fakeAsync tests will fail with the mentioned Error: Expected to be running in 'ProxyZone', but it was not found., but the it.each will pass.
Please provide the exception or error you saw
Either
TypeError: Cannot read properties of undefined (reading 'withContext')
or
Error: Expected to be running in 'ProxyZone', but it was not found.
Other information
No response
I would be willing to submit a PR to fix this issue
- Yes
- No
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 4
- Comments: 16 (11 by maintainers)
I planned to do a release today, but will wait on the PR to land. You can also test the beta after its merged
We use
vmThreadsby default, but you can change it tothreadsorforksand test with thathttps://github.com/analogjs/analog/blob/beta/packages/vite-plugin-angular/src/lib/angular-vitest-plugin.ts#L14
https://vitest.dev/config/#pool
1.6.0 contains the fixes