Cypress fixtures - Cannot read properties of undefined (reading 'data')
✔ Recommended Answer
I prefer using closure variables to assign fixture data.
describe('Some Test', () => { let data; before(() => { cy.fixture('credentials').then((fData) => { data = fData; }); }); it('Login correct', () => { cy.visit('/') loginPage.signIn(data.admin.username, data.admin.password) cy.wait(5000) // assertion cy.contains('Dashboard').should('be.visible') })});
Gleb Bahmutov also recommends using closure variables.
I strongly recommend using closure variables instead of this properties. The closure variables are clearly visible and do not depend on
function
vs() => {}
syntax.
Source: stackoverflow.com
Answered By: agoff
Very Informative and creative contents. This concept is a good way to enhance knowledge. Thanks for sharing. Continue to share your knowledge through articles like these.
ReplyDeleteData Engineering Services
Data Analytics Services
Artificial Intelligence Solutions
Data Modernization Services
Very Informative and creative contents. This concept is a good way to enhance knowledge. Thanks for sharing. Continue to share your knowledge through articles like these.
ReplyDeleteData Engineering Services
Data Analytics Services
Artificial Intelligence Solutions
Data Modernization Services
Very Informative and creative contents. This concept is a good way to enhance knowledge. Thanks for sharing. Continue to share your knowledge through articles like these.
ReplyDeleteData Engineering Services
Data Analytics Services
Artificial Intelligence Solutions
Data Modernization Services
Very Informative and creative contents. This concept is a good way to enhance knowledge. Thanks for sharing. Continue to share your knowledge through articles like these.
ReplyDeleteData Engineering Services
Data Analytics Services
Artificial Intelligence Solutions
Data Modernization Services