-
-
Notifications
You must be signed in to change notification settings - Fork 85
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
Bug: Test fails if executed independently '__ngContext__={[Function Number]}' vs '__ngContext__="0"' #3811
Comments
Hi @jones1008, thank you for the report. However, it looks like an issue in Angular or jest, but not in import {HelloComponent} from "./hello.component";
import {TestBed} from "@angular/core/testing";
describe('HelloComponent', () => {
beforeEach(() => TestBed.configureTestingModule({
declarations: [HelloComponent],
}).compileComponents());
it('should render component correctly with Joe', () => {
const fixture = TestBed.createComponent(HelloComponent);
fixture.componentInstance.name = 'Joe';
fixture.detectChanges();
expect(fixture).toMatchSnapshot()
});
it('should render component correctly with other name', () => {
const fixture = TestBed.createComponent(HelloComponent);
fixture.componentInstance.name = 'Jane';
fixture.detectChanges();
expect(fixture).toMatchSnapshot()
});
}); It looks like, the very first call of I would suggest to report the issue to Angular / jest, not sure which of them convert the number to an object. |
I assume the problem is that in their code they detect I would expect that |
It looks like, I found a way to remove Could you check if it works well in your project? |
@satanTime Yes this works! Does it make sense to ship this fix? Do we need Also when you ship this, all the snapshot tests that were setup with ng-mocks will fail. So is this a breaking change? |
Nice! I'm glad to hear that. I wouldn't expect a need of I'll ship it as it is with a note that |
Great! Thanks for the quick answers and fix! |
…te anymore help-me-mom#3811 NOTE: If you use jest snapshots it might require to update them and remove the `__ngContext__` attribute from `mock-render` nodes.
…te anymore help-me-mom#3811 NOTE: If you use jest snapshots it might require to update them and remove the `__ngContext__` attribute from `mock-render` nodes.
v14.3.0 has been released and contains a fix for the issue. Feel free to reopen the issue or to submit a new one if you meet any problems. |
Description of the bug
from https://stackoverflow.com/q/73307975/7987318:
An example of the bug
reproduction steps
First clone my reproduction repo: https://github.com/jones1008/ng-mocks-snapshot-test-bug
To reproduce the bug follow these steps:
See that when running
npm run test
the tests pass, and when runningnpm run single-test-fail
the test fails with the following error:Notes:
npm run single-test-fail
executesjest -t 'HelloComponent should render component correctly with other name'
and therefore the second test in thehello-component.spec.ts
filenpm run single-test-fail
executesjest -t 'HelloComponent should render component correctly with Joe'
and therefore the first test in thehello-component.spec.ts
file. Strangely this test passes!npm run test
The text was updated successfully, but these errors were encountered: