Browserstack: Next.js Cypress e2e test unable to resolve relative import

优雅先森。 测试交流1 132字数 1187阅读模式
摘要I’m using Cypress’ nextjs plugin, and when I try to run any test via Browserstack, I get t...

I’m using Cypress’ nextjs plugin, and when I try to run any test via Browserstack, I get the following error when trying to import modules via relative paths.

Oops...we found an error preparing this test file:
  > cypress/integration/happy-paths/modules/promo-card-page-automation-checks.spec.js
The error was:
Error: Webpack Compilation Error
    ./cypress/integration/happy-paths/modules/promo-card-page-automation-checks.spec.js
    Module not found: Error: Can't resolve '../../../../services/i18n' in '/e2e/cypress/integration/happy-paths/modules'
    Looked for and couldn't find the file at the following paths:
    [/e2e/services/i18n]
    [/e2e/services/i18n.js]
    [/e2e/services/i18n.json]
    [/e2e/services/i18n.jsx]
    [/e2e/services/i18n.mjs]
    [/e2e/services/i18n.coffee]
    [/e2e/services/i18n/index]
    [/e2e/services/i18n/index.js]
    [/e2e/services/i18n/index.json]
    [/e2e/services/i18n/index.jsx]
    [/e2e/services/i18n/index.mjs]
    [/e2e/services/i18n/index.coffee]
     @ ./cypress/integration/happy-paths/modules/promo-card-page-automation-checks.spec.js 5:35-71

I’ve tried to modify my plugins/index.js file in order to import i18n globally, with no success.
The specified relative path of the imported module is correct, because when I ran tests on local they work, but when I try to run them in Browserstack, they fail with the error from above.文章源自玩技e族-https://www.playezu.com/179289.html 文章源自玩技e族-https://www.playezu.com/179289.html

玩技站长微信
添加好友自动发送入群邀请
weinxin
rainbow-shownow
玩技官方公众号
官方微信公众号
weinxin
PLAYEZU
 
  • 版权提示:本站仅供存储任何法律责任由作者承担▷诈骗举报◁▷新闻不符◁▷我要投稿◁
    风险通知:非原创文章均为网络投稿真实性无法判断,侵权联系2523030730
    免责声明:内容来自用户上传发布或新闻客户端自媒体,切勿!切勿!切勿!添加联系方式以免受骗。
  • 原创转载:https://www.playezu.com/179289.html
    转载说明: 点我前往阅读>>>
    • rlandster
      rlandster 9

      请在没有Browserstack的情况下尝试,如果出现与插件相关的相同错误。
      此外,您还可以尝试为安装在node_模块内的包指定正确的URL。例如:
      import ‘../../../node_modules/cypress-wait-util’;

      你可以探索-https://nextjs.org/examples例如使用nextJS

    匿名

    发表评论

    匿名网友
    确定