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

Cannot find @sentry/angular-ivy module in Jest tests when using Angular 17.x #9628

Closed
3 tasks done
NoNameProvided opened this issue Nov 21, 2023 · 2 comments
Closed
3 tasks done
Labels
Package: angular Issues related to the Sentry Angular SDK Type: Bug

Comments

@NoNameProvided
Copy link

NoNameProvided commented Nov 21, 2023

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/angular-ivy

SDK Version

7.81.1

Framework Version

17.0.4

Link to Sentry event

No response

SDK Setup

No response

Steps to Reproduce

  1. I have updated our project to the latest Angular 17.x version
  2. I have updated Sentry to the latest version that requires Angular
  3. I have tried to run the tests and I received a module not found error.

We are using @angular-builders/jest to run our tests via Jest (the problem surfaces with default configuration).

Steps to reproduce:

  • generate a new Angular project
  • configure @angular-builders/jest following readme
  • import sentry in the app component
  • create a test that imports the app component
  • run the test and observe that Jest fails with a module not found import error

Expected Result

Jest tests continue to work without a problem.

Actual Result

Every test fails that references a file that imports Sentry in any way with the following message:

Cannot find module '@sentry/angular-ivy' from '<my-app>/path-to-file-where-sentry-is-imported.ts'

I think the root cause of this problem is the same as reported in this issue:

Tests will start to work again when I revert back the referenced change by adding the main entry point in the node_modules folder:

"main": "bundles/sentry-angular-ivy.umd.js",

There is a workaround. The following snippet should be added to the Jest config:

  moduleNameMapper: {
    '@sentry/angular-ivy': '<rootDir>/node_modules/@sentry/angular-ivy/bundles/sentry-angular-ivy.umd.js',
  },

This mandatory workaround should be possibly documented somewhere prominent.

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 Nov 21, 2023
@github-actions github-actions bot added the Package: browser Issues related to the Sentry Browser SDK label Nov 21, 2023
@NoNameProvided
Copy link
Author

The package label is incorrectly applied, I am using @sentry/angular-ivy with Angular.

@lforst lforst added Package: angular Issues related to the Sentry Angular SDK and removed Package: browser Issues related to the Sentry Browser SDK labels Nov 22, 2023
@lforst
Copy link
Member

lforst commented Nov 22, 2023

Hi, thanks for reporting this! I am closing this though in favor of #9448 just to avoid duplicates.

Duplicate of #9448

@lforst lforst closed this as not planned Won't fix, can't repro, duplicate, stale Nov 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Package: angular Issues related to the Sentry Angular SDK Type: Bug
Projects
Archived in project
Development

No branches or pull requests

2 participants