Open neerajlad opened 6 months ago
We have examples in our tests of using a relative path, so this should work. We'll need some way to reproduce it since this is likely influenced by some other component in your test suite.
i'm having the exact same problem - relative paths do not work, having to use absolute. I tried with a bare bones cypress install and still have the issue.
// this is required as expected
const Pages = require('../support/page-objects')
describe('As an user i can', () => {
it('login', () => {
// works as expected, taken to auth page on different domain
Pages.Auth.login()
// navigate to different domain
cy.origin('localhost', () => {
// works as expected
const Pages2 = Cypress.require('/REDACTED/myproject/cypress/support/page-objects.js')
// errors with 'module not found'
const Pages = Cypress.require('../support/page-objects.js')
})
})
})
cypress.config.js
const { defineConfig } = require('cypress')
module.exports = defineConfig({
e2e: {
experimentalOriginDependencies: true
}
})
@jennifer-shehane I was able to fix my issue my using:
const Pages = Cypress.require('/cypress/support/page-objects')
is this expected behaviour? Or do i have an error in my setup?
cypress/
- e2e/
- support/
package.json
i run with npm run cy:local
:
"cy": "cypress open --e2e --browser electron"
"cy:local": "dotenvx run -f .env.local -- npm run cy"
Current behavior
I have two app which open using Okta and then it navigate to actual url . What I am currently facing is that I am using Cypress.require() method with absolute path and it works well but when I change to relative then its shows error as
Cannot find module '../XXX/xxx/xx/pageObjects/XXXPage.js'
Desired behavior
cypress.require() should access relative path
Test code to reproduce
Not working code:
Working code
Cypress Version
v13.6.6
Node version
Bundled Node version: 18.17.1 & npm version : 10.4.0
Operating System
Windows 10 Enterprise - build version 19045.4046
Debug Logs
Other
Value seen as XXX or XX is replaced with actual value