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

🐛 tech-insights-backend: Forbidden dependency on @backstage/backend-test-utils #1715

Open
2 tasks done
rohitmishr opened this issue Oct 18, 2024 · 5 comments
Open
2 tasks done
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@rohitmishr
Copy link

🔖 Need

Issue: ReferenceError: jest is not defined

Context: We recently upgraded our Backstage version and created a custom TechInsights plugin. This plugin has a dependency on @backstage/backend-test-utils. When attempting to run yarn dev, we encounter the following error:

/Users/rxxxmxxxx/Documents/bug-fix-tech-insights/xyzz-idp-app/packages/backend/node_modules/@backstage-community/plugin-tech-insights-backend/node_modules/@backstage/backend-test-utils/src/next/services/mockServices.ts:64
child: jest.fn().mockImplementation(createLoggerMock),
^

ReferenceError: jest is not defined
at createLoggerMock (/Users/rxxxmxxxx/Documents/bug-fix-tech-insights/xyzz-idp-app/packages/backend/node_modules/@backstage-community/plugin-tech-insights-backend/node_modules/@backstage/backend-test-utils/src/next/services/mockServices.ts:64)

Steps Taken:

  1. Upgraded Backstage version.
  2. Created a custom TechInsights plugin.
  3. Added @backstage/backend-test-utils as a dependency.
  4. Ran yarn dev.

Error Details:

  • The error occurs in the mockServices.ts file at line 64. (inside my node_modules of backend I am able to see this path "backend/node_modules/@backstage-community/plugin-tech-insights-backend/node_modules/@backstage/backend-test-utils/src/next/services/mockServices.ts:64")
  • It seems that jest is not defined in the context where createLoggerMock is being called.

Request for Help: Could anyone provide guidance on how to resolve this ReferenceError? Specifically, how can we ensure that jest is properly defined and available in the context of mockServices.ts?

🎉 Proposal

Issue: ReferenceError: jest is not defined
Context: We recently upgraded our Backstage version and created a custom TechInsights plugin. This plugin has a dependency on @backstage/backend-test-utils. When attempting to run yarn dev, we encounter the following error:

/Users/rxxxmxxxx/Documents/bug-fix-tech-insights/xyzz-idp-app/packages/backend/node_modules/@backstage-community/plugin-tech-insights-backend/node_modules/@backstage/backend-test-utils/src/next/services/mockServices.ts:64
child: jest.fn().mockImplementation(createLoggerMock),
^

ReferenceError: jest is not defined
at createLoggerMock (/Users/rxxxmxxxx/Documents/bug-fix-tech-insights/xyzz-idp-app/packages/backend/node_modules/@backstage-community/plugin-tech-insights-backend/node_modules/@backstage/backend-test-utils/src/next/services/mockServices.ts:64)

when we checked this repo link for latest @backstage/backend-test-utils but after doing yarn install and yarn dev we are getting jest not define.

〽️ Alternatives

No response

❌ Risks

No response

👀 Have you spent some time to check if this RFC has been raised before?

  • I checked and didn't find similar issue

🏢 Have you read the Code of Conduct?

@Rugvip
Copy link
Member

Rugvip commented Oct 19, 2024

Are you seeing this error when importing @backstage/backend-test-utils in a test file? It is only intended to be used in tests, if it's imported in the main build it's expected that it breaks in this way.

@rohitmishr
Copy link
Author

rohitmishr commented Oct 21, 2024

when we are trying to run application via yarn dev then I am getting this jest not define.

The thing is we are not able to find mockservice.ts inside backend/node_modules.

when we tried to upgrade backstage version from 1.26 to 1.31 then we are getting this error.

@rohitmishr
Copy link
Author

And this is getting from plugin tech-insigths.

@Rugvip
Copy link
Member

Rugvip commented Oct 21, 2024

I see that the tech-insights backend has a production dependency on backend-test-utils:

There's also no /testUtils entry point or similar, so that dependency shouldn't be there and is looking like a bug in the tech insights plugin. Gonna move this over to the community plugins repo for fixing there

@Rugvip Rugvip changed the title 💬 RFC: <title>Jest Error from @backstage/backend-test-utils 🐛 tech-insights-backend: Forbidden dependency on @backstage/backend-test-utils Oct 21, 2024
@Rugvip Rugvip added the bug Something isn't working label Oct 21, 2024
@Rugvip Rugvip transferred this issue from backstage/backstage Oct 21, 2024
@awanlin awanlin added the help wanted Extra attention is needed label Oct 21, 2024
@awanlin
Copy link
Contributor

awanlin commented Oct 21, 2024

Contributions to fix this welcome 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants