Get User Data from json file in Cypress
Get User Data from json file in Cypress and use it your Test Cases.
(1) Create a UserData.json file in fixtures folder.
(2) Define the Values in the Curly Brackets . Something like this.
{
“UserName”:”Admin”,
“UserPassword”:”admin123″
}
(3) Open your tests file.Use the fixtures method and Pass these Values in the Type().
cy.fixture(‘UserData.json’).then((user) => {
cy.get(‘#txtUsername’).type(user.UserName)
cy.get(‘#txtPassword’).type(user.UserPassword)
})

(4) Run Your Test. It will Work.

For more blogs click here
Follow this link for Cypress’s Documentation
Excellent post. I definitely appreciate this website. Thanks!