I'm trying to use fixtures to hold data for different tests. This is an example of the code. When it gets to the second test I'm getting 'Cannot read property 'email' of undefined'.
Any ideas why and how I can get around that? I'm new to this and followed a course where they said the whole point of using fixtures in the 'before' was to have the data accessible to everything. Is that wrong?
Thank you
describe('Example', function() {
before(function() {
cy.fixture('dataFile').then(function(dataJson) {
this.dataJson = dataJson;
});
});
it('name', function() {
cy.log(this.dataJson.email);
});
it('name2', function() {
cy.log(this.dataJson.email);
});
});