最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin0浏览0评论

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

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论