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

Jest: Cannot find module @vercel/analytics/react from src/pages/_app.tsx #22

Closed
bitabs opened this issue Nov 23, 2022 · 6 comments
Closed

Comments

@bitabs
Copy link

bitabs commented Nov 23, 2022

Hi there,

I'm using Blitz, and Jest test is failing:

Screenshot 2022-11-23 at 18 48 13

Screenshot 2022-11-23 at 18 48 28

Jest

Screenshot 2022-11-23 at 18 49 23

@dglsparsons
Copy link
Collaborator

dglsparsons commented Nov 25, 2022

Hey @bitabs, thanks for raising this. We'll get investigating! I suspect it's something to do with how the module is packaged...

Are you just using a blitzjs starter? Is there a minimal repro you can share? I'm not overly familiar with blitz :D

@bitabs
Copy link
Author

bitabs commented Nov 25, 2022

Hya 👋🏻 @dglsparsons - Yes, It's a Blitz starter indeed. Can you please try the starter?

@dglsparsons
Copy link
Collaborator

dglsparsons commented Nov 28, 2022

Hey @bitabs! Sorry, but I'm struggling to reproduce this - I'm being frustratingly blocked on this Blitz issue which means I'm struggling to get any tests to work at all in Blitz.

I was, however, able to set up a brand new NextJS project based on the NextJS Jest Example. Adding Analytics to this in either the _app.tsx file, or in a specific page gave me no issues at all though - and worked exactly as you'd expect.

Screenshot 2022-11-28 at 11 25 19

It seems like the issue is with the Blitz jest config because of this. However, since I'm unable to reproduce I can't confirm this.

Sorry to ask again, but I don't suppose you are able to share any reproduction?

@dillondotzip
Copy link

Hey just here to add some context. We had some issues with jest & some types. There is a PR open currently to scrap jest completely and move to vitest blitz-js/blitz#3985

@bitabs
Copy link
Author

bitabs commented Nov 30, 2022

@dglsparsons I share your frustration, unfortunately. 😞 It looks like something very specific to Blitz. @dillonraphael Thanks for jumping in and adding some context 🙇.

I guess I'll close this ticket for the time being 🙏🏻

@bitabs bitabs closed this as completed Nov 30, 2022
@wowczarczyk
Copy link

For me it was a matter of adding this to "jest" config in package.json:

"jest": {
    "moduleNameMapper": {
      "@vercel/analytics/react": "identity-obj-proxy"
    }
  },

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

No branches or pull requests

4 participants