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.