This is a reproduction repository for https://stackoverflow.com/q/73307975/7987318
To reproduce the bug follow these steps:
npm install
npm run test
npm run single-test-fail
See that when running npm run test
the tests pass, and when running npm run single-test-fail
the test fails with the following error:
FAIL src/app/components/hello.component.spec.ts
HelloComponent
✕ should render component correctly with other name (66 ms)
○ skipped should render component correctly with Joe
● HelloComponent › should render component correctly with other name
expect(received).toMatchSnapshot()
Snapshot name: `HelloComponent should render component correctly with other name 1`
- Snapshot - 1
+ Received + 1
@@ -1,7 +1,7 @@
<mock-render
- __ngContext__={[Function Number]}
+ __ngContext__="0"
>
<hello>
<h1>
Hello Jane!
</h1>
15 | it('should render component correctly with other name', () => {
16 | const fixture = MockRender(HelloComponent, {name: 'Jane'});
> 17 | expect(fixture).toMatchSnapshot()
| ^
18 | });
19 | });
20 |
at src/app/components/hello.component.spec.ts:17:21
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!