beforeEach with waitForAsync fails when trying to compile a component #125
Replies: 3 comments
-
I've revisited this and I can't remember why, but I've misunderstood why my tests fail. It's still because of the @Component({ template: `{{ mutation.result$ | async | json }}` })
class AppComponent implements OnInit {
mutation = inject(UseMutation)(() => of('hello world'));
ngOnInit() {
this.mutation.mutate('id')
}
}
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({declarations: [AppComponent] });
TestBed.compileComponents();
}));
it('should work 1', () => {
const component = TestBed.createComponent(AppComponent);
component.detectChanges()
});
it('should work 2', () => {
const component = TestBed.createComponent(AppComponent);
component.detectChanges()
}); Which is why I think it might be similar to #82 |
Beta Was this translation helpful? Give feedback.
-
@cuddlecake did you found a fix in the meantime? So what is happening here exactly? From what i can see is, that The logical reason then would be to clear all caches (with BTW, i tried to apply the "fix" i used in #82 by adding |
Beta Was this translation helpful? Give feedback.
-
I didn't find or search for a fix, since I couldn't introduce this library at work yet. And I don't feel like explaining the nuances of |
Beta Was this translation helpful? Give feedback.
-
Which @ngneat/query-* package(s) are the source of the bug?
query
Is this a regression?
No
Description
When trying to create a component and initially calling
detectChanges
as would be usually done:All tests in the file will fail due to jest timeout.
It also doesn't matter if I attempt to detect changes outside of the
beforeEach
hook, because then only the first test will succeed, while all subsequent tests will fail.Please provide a link to a minimal reproduction of the bug
https://github.com/cuddlecake/query/blob/main/packages/ng-query/src/lib/tests/component.spec.ts
Please provide the exception or error you saw
No response
Please provide the environment you discovered this bug in
No response
Anything else?
My minimal reproduction is as minimal as it gets, but I first stumbled on this when I tried to introduce
@ngneat/query
in my app with a proper use case, involving an HTTP Request.Do you want to create a pull request?
No
Beta Was this translation helpful? Give feedback.
All reactions