下一个路由器的下一个JS测试问题
我正在尝试在NextJ中为我的项目编写React-Testing-Library编写单元测试,但是
const t = locale === 'fa' ? fa : en;
在进行测试时,我在下一个路由器方面遇到 了麻烦。 无法破坏“路由器”的“地方”,因为它是空的。 任何人对这个问题有任何想法吗?
I am trying to writing unit test with react-testing-library for my project in nextjs but I have trouble with next router specially localization
const t = locale === 'fa' ? fa : en;
I face to this error while I run the test
Cannot destructure property 'locale' of 'router' as it is null.
any body have idea about this problem ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您只需模拟userOuter()即可按下
“描述”块上方
You will need to just mock the useRouter() like follow
Place this above the "describe" block