Let's say we have the following suite:
describe('Devices', () => {
describe('Master Data Set-Up', () => {
it('should create the device if necessary', () => {
cy.createDevice()
its('body.id')
.as(deviceId);
});
});
describe('Test Suite 1', () => {
it('should allow to send data to device', () => {
cy.get('@deviceId').then((deviceId) => {
cy.sendData(deviceId, 'Some Data');
});
});
});
});
So, we have a set up suite that creates master data. This is a simplified version, actually it contains a couple of it specs and I'd like to keep it like that because it's better to read in the Cypress output.
Then, there is the actual test suite that want's to use data that has previously been created. In this case a server generated id that should be used for another REST call.
This is assuming, that cy.createDevice
and cy.sendData
are custom commands available that internally use cy.request
.
When running that, cy.get('@deviceId')
fails because aliases are not shared across describe blocks AFAIK. I tried to use let deviceId
but it's undefined as it is not yet available when the test specs are processed.
What is a proper way to do this?
Aucun commentaire:
Enregistrer un commentaire