provideMockActions doesn't work as intended under vitest environment and cannot produce Actions
if inject is declared after effect method
#4708
Labels
Actions
if inject is declared after effect method
#4708
Which @ngrx/* package(s) are the source of the bug?
effects
Minimal reproduction of the bug/regression with instructions
We have a very simple effect:
Tested with:
This works actually. We obtain the proper result.
BUT, if we just do this:
So basically, put the private at the bottom. It then fails:
Please note we did try to use TestBed directly or even instantiate the Effect manually (and removing it from providers of course) with the exact same results. As example:
We also tested with subscribes in the test itself with same error.
Expected behavior
Order of private / public method should not have an impact on how tests are handled.
Versions of NgRx, Angular, Node, affected browser(s) and operating system(s)
NGRX: 19.0.1
NX: 20.4.4
Angular: ~19.1.6
Node: 20.17.0
Macos, windows, ubuntu
@analogjs/vite-plugin-angular: ~1.13.1,
@analogjs/vitest-angular: ~1.13.1,
vitest: 3.0.6
Other information
You can try it easily: create a nx project with angular and vitest. Just drop the files there, run tests.
As a counter-example to isolate issue and see if issue was caused by vitest or other, we did:
with test like
And then test succeeds, the order of inject is fine. We also tried without spectator and Tesbed it's also ok.
Here is our vitest config:
Our test-setup:
I would be willing to submit a PR to fix this issue
The text was updated successfully, but these errors were encountered: