jestjs - Upgrading Sentry (in Next.js and Jest project) from v7 to v8 fails with error: TypeError: Cannot read properties of und

I've run into a nasty config issue in a project using Next.js 14.2.5 (pages router), Jest, and Sen

I've run into a nasty config issue in a project using Next.js 14.2.5 (pages router), Jest, and Sentry. I am upgrading from Sentry v7 to v8, and any time that I import from @sentry/nextjs, running Jest tests immediately results in a cryptic error:

TypeError: Cannot read properties of undefined (reading 'events')

I've run into a nasty config issue in a project using Next.js 14.2.5 (pages router), Jest, and Sentry. I am upgrading from Sentry v7 to v8, and any time that I import from @sentry/nextjs, running Jest tests immediately results in a cryptic error:

TypeError: Cannot read properties of undefined (reading 'events')
Share Improve this question edited Mar 11 at 15:43 Joshua Miles asked Mar 11 at 15:42 Joshua MilesJoshua Miles 817 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

While it is presenting differently, I believe the error is the same one reported in this GitHub Issue, and the work-around proposed there worked for me as well. I added the following to my jest.config.js:

  moduleNameMapper: {  
    '@sentry/nextjs': '\<rootDir\>/node_modules/@sentry/nextjs',  
  },  

Cross-posting here with the specific error message I encountered so that it can be found a little more easily by the next person

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744783911a4593505.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信