cucumbercypressbdd

how to import json files from fixtures in BDD step definition file in cypress


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.

Fixture folder structure

I have the below functions in command.js file

commands.js file

Earlier i was calling using the below code in my .cy.js file but the same code is not working with BDD

Script code

getting bellow error when running Error while running


Solution

  • 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: