lundi 22 juin 2020

Cypress.io: How to use Fixtures?

I actually use the following code:

const userType = new Map([['Manager', '1'],['Developer', '2' ]]) 
for (const [key, value] of usertypes.entries()) 
{
    it('log in', () => 
    {
        cy.login(key,value)
        
        cy.xpath('path')
        .click()
         cy.xpath('path')                        
        .should('have.value' , key)         
    })
}

To use the Users in other tests I want to define usertypes in a fixture named users. How can I use this fixture with this test? My Json File looks like :

[
     {"key": "Manager"},
     {"value": "1"}
],

[
    {"key": "Developer"},
    {"value": "2" }
]

I tried to use cy.fixture in the beforeElse but I dont need this in every test and it was not right. How can I use the data of users.json in my test?

Aucun commentaire:

Enregistrer un commentaire