-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Error when executing test with jest and jest-circus as testRunner #3243
Comments
This is not an NgRx issue, as we don't control testing configuration. From the GitHub repo, I don't see where your Jest config is setup properly. Check the examples here https://github.com/thymikee/jest-preset-angular/tree/main/examples |
ok, actually i did check the example, this error occur only when I add |
I posted an issue in jest-preset-angular repo (thymikee/jest-preset-angular#1187). My config seems to be ok.
|
if I disable |
@brandonroberts I think this is a NgRx package issue. In angular V13 In So the 1er test of the component pass successfully, all the following will failed |
maybe we could use if (typeof afterEach === 'function') {
afterEach(() => {
try {
const testBed = getTestBed() as any;
const shouldTearDown = testBed.shouldTearDownTestingModule();
if (!shouldTearDown) {
const mockStore: MockStore | undefined = TestBed.inject(MockStore);
if (mockStore) {
mockStore.resetSelectors();
}
}
// eslint-disable-next-line no-empty
} catch { }
});
} |
Sorry, but I'm a bit confused. |
Sorry I made a mistake in the reproduction, to run jest :
|
I was facing the same problem and figured out that it was related to the destroyAfterEach property. My questions here are:
|
I think it should be fixed as Or maybe it should be mentionned in NgRx doc that |
Yes I think we should support this without explicitly disabling the cleanup. It looks like from the example above it can be detected whether to do it. |
I can confirm this. Just migrated semi-sized (~350 projects) Nrwl monorepo to version 13 and got bunch of failing tests. |
@brandonroberts I can propose a PR if you'd like based on this #3243 (comment) ? |
@cedricduffournet yep. We'll need a test to verify this also. I was under the impression that this would be opt-in but I must have misread it. Here is an article from @LayZeeDK about the performance impact of the teardown https://dev.to/this-is-angular/improving-angular-tests-by-enabling-angular-testing-module-teardown-38kh |
@brandonroberts there is no error in NgRx repo because it use |
Yea, if we're using any jasmine-specific APIs for testing the example-app, those would have be migrated but that seems reasonable to me. |
The table towards the end of the article tries to sum up the settings and reads that Angular testing module teardown is opt-out as of Angular 13.0: |
Minimal reproduction of the bug/regression with instructions:
I am not sure than this issue is related to ngrx, angular or jest package. My apologize if I am in the wrong place
The following error occur in all tests with provideMockStore added to providers
If i set
jest-jasmine2
astestRunner
in jest config, I don't have any error.I did not have this issue in version 12 of angular and ngrx
Expected behavior:
Test should pass without error
Versions of NgRx, Angular, Node, affected browser(s) and operating system(s):
Angular 13, ngrx 13.0.0
The text was updated successfully, but these errors were encountered: