question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug]: Getting ReferenceError when using decorators

See original GitHub issue

Version

12.2.2

Steps to reproduce

  1. Clone my repo at https://github.com/philippesc/ng-jest-issue
  2. yarn install
  3. yarn test
  4. You should see the error come up

Expected behavior

I expect that no error comes up as the test should work properly.

Actual behavior

This is what comes up:

ReferenceError: app_state_model_1 is not defined

   5 | export class AppSelectors {
   6 |   @Selector([AppState])
>  7 |   static appName(state: AppStateModel): string {
     |                         ^
   8 |     return state.name;
   9 |   }
  10 | }

  at Object.<anonymous> (src/app/store/app/app.selectors.ts:7:25)
  at Object.<anonymous> (src/app/services/some-nice-service/some-nice-service.spec.ts:3:1)

Additional context

This error came up in the context of migration to Angular 14 but it seems to be related to this package.

Environment

System:
  OS: macOS 12.6
  CPU: (10) arm64 Apple M1 Max
Binaries:
  Node: 16.13.1 - /usr/local/bin/node
  Yarn: 1.22.17 - /usr/local/bin/yarn
  npm: 8.3.0 - /usr/local/bin/npm
npmPackages:
  jest: 28.1.1 => 28.1.1

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:11
  • Comments:7

github_iconTop GitHub Comments

2reactions
valiant-codecommented, Nov 18, 2022

For me jest-preset-angular 12.0.0 works but 12.2.0 runs into this issue with decorators.

2reactions
valiant-codecommented, Nov 8, 2022

Looks like this was discussed in #1199 as well.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[Bug]: type-only imports cause ReferenceError #1199 - GitHub
This bug is caused by the fact that, the Language Service is in a Jest worker doesn't have enough information to transform Angular...
Read more >
Angular: 7.2.1 ES6 class ReferenceError : Cannot access 'X ...
In my case, it wasn't any circular dependency, it was a bug in an array that I export and use inside one of...
Read more >
Incorrect unresolved reference error with list comprehensions ...
PY-18157 Unresolved reference in list comprehension inside a decorator keyword ... There is easier way to get this bug, I think it is...
Read more >
swc cannot access before initialization - You.com | The search ...
The problem only exists when using decorators。 exports.default = _class1; ^ ReferenceError: Cannot access '_class1' before initialization at Object.
Read more >
@babel/plugin-syntax-decorators | Yarn - Package Manager
@babel/plugin-syntax-decorators ... Allow parsing of decorators. babel-plugin ... :eyeglasses: [Spec Compliance]; :rocket: [New Feature]; :bug: [Bug Fix] ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found