jest-preset-angular: [Bug]: Using toMatchInlineSnapshot fails in spec files that use decorators like @Component
Version
10.0.1
Steps to reproduce
- Clone repository from: https://github.com/abierbaum/jest-preset-angular/
- git checkout decorators_bug_example
- cd examples/example-app-v12
- yarn install
- yarn test --updateSnapshot
note: you can see the change here: https://github.com/abierbaum/jest-preset-angular/commit/d68f3396a11303bcd11d70a2658fed39283bb426
It simply adds:
- A component for the purpose of using a decorator
- A call in the spec to
expect(fixture).toMatchInlineSnapshot()
Expected behavior
I would expect the snapshot in the modified example spec to complete and update the inline snapshot.
Actual behavior
It fails to complete. My best guess is that something in the chain is rerunning the spec but without the correct typescript transformations in place.
$ jest --updateSnapshot
ngcc-jest-processor: running ngcc
FAIL src/app/app.component.spec.ts
● Test suite failed to run
SyntaxError: /home/Source/jest-preset-angular/examples/example-app-v12/src/app/app.component.spec.ts: Support for the experimental syntax 'decorators-legacy' isn't currently enabled (9:1):
7 |
8 |
> 9 | @Component({
| ^
10 | selector: 'test-comp',
11 | template: `
12 | <div>Testing</div>
at Object._raise (node_modules/@babel/parser/src/parser/error.js:134:45)
Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 1.194 s
Ran all test suites.
error Command failed with exit code 1.
Additional context
No response
Environment
System:
OS: Linux 5.8 Ubuntu 20.04.3 LTS (Focal Fossa)
CPU: (12) x64 AMD Ryzen 5 5600X 6-Core Processor
Binaries:
Node: 12.22.5 - /usr/bin/node
Yarn: 1.22.5 - /usr/bin/yarn
npm: 6.14.14 - /usr/bin/npm
npmPackages:
jest: ^27.2.4 => 27.2.4
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 1
- Comments: 16
@ahnpnl Thank you so much for you support and investigation!!! I think I have a workaround for now and it looks like you are tracking or creating a bug for jest itself on this issue. Thank you for all your work on this project and ts-jest. It is greatly appreciated.
You can use this one https://github.com/ahnpnl/ts-jest-babel-example to create a reproduce scenario