I have the below folder structure in cypress. I am trying to call object repo and test data json files in BDD step definition, but it won't pick the files.
I have the below functions in command.js file
Earlier i was calling using the below code in my .cy.js file but the same code is not working with BDD
It seems like you have used When('login...', () => {
instead of When('login...', function() {
since error message says this
is undefined.
But maybe you already tried that and When()
does not support Mocha this
scope (since When()
is a wrapper over it()
).
There are alternatives:
explicitly retrieve the alias value
cy.get('@ORLoginPage').then(RLoginPage => {
cy.get(RLoginPage.Email...
use require
to get fixtures
const RLoginPage = require('../fixtures/OR_LoginPage.json')
When('login...', () => {
cy.get(RLoginPage.Email...