Skip to content
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]: jest-preset-angular fails with Typescript 4.8 #1732

Closed
Coly010 opened this issue Aug 26, 2022 · 1 comment · Fixed by #1739
Closed

[Bug]: jest-preset-angular fails with Typescript 4.8 #1732

Coly010 opened this issue Aug 26, 2022 · 1 comment · Fixed by #1739
Labels
🐛 Bug Confirmed Bug is confirmed

Comments

@Coly010
Copy link
Contributor

Coly010 commented Aug 26, 2022

Version

12.2.0

Steps to reproduce

  1. Clone my repo at https://github.com/Coly010/jest-preset-angular-ts-4.8-repro
  2. yarn install
  3. npx jest

Expected behavior

Tests should pass correctly

Actual behavior

Tests fail with the following error:

● AppComponent › should render title

    Component 'AppComponent' is not resolved:
     - templateUrl: ./app.component.html
     - styleUrls: ["./app.component.css"]
    Did you run and wait for 'resolveComponentResources()'?

Additional context

With Angular 14.2.0 having been released, they have added support for TS 4.8.2.

However, when using TS 4.8.2 with jest-preset-angular 12.2.0, it results in test failures due to unresolved components.

It's worth noting that jest-preset-angular 12.2.0 works correctly with TS 4.7.2.

Environment

System:
    OS: macOS 12.1
    CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
  Binaries:
    Node: 16.14.0 - ~/.nvm/versions/node/v16.14.0/bin/node
    Yarn: 1.22.17 - ~/.nvm/versions/node/v16.14.0/bin/yarn
    npm: 8.3.1 - ~/.nvm/versions/node/v16.14.0/bin/npm
  npmPackages:
    jest: ^29.0.1 => 29.0.1


---
Angular CLI: 14.2.0
Node: 16.14.0
Package Manager: npm 8.3.1
OS: darwin x64

Angular: 14.2.0
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1402.0
@angular-devkit/build-angular   14.2.0
@angular-devkit/core            14.2.0
@angular-devkit/schematics      14.2.0
@schematics/angular             14.2.0
rxjs                            7.5.6
typescript                      4.8.2
@ahnpnl
Copy link
Collaborator

ahnpnl commented Aug 28, 2022

Thanks for the report. FYI it is related to a breaking change in 4.8 about https://devblogs.microsoft.com/typescript/announcing-typescript-4-8/#decorators-are-placed-on-modifiers-on-typescripts-syntax-trees This impacts our AST transformer. However, Angular CLI team already had the change so it's not an issue to replicate the change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Bug Confirmed Bug is confirmed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants