fresh-doctor-14925
11/28/2022, 3:45 PMnutritious-analyst-96582
11/28/2022, 3:45 PMbest-flower-17510
11/28/2022, 5:46 PMbest-flower-17510
11/28/2022, 8:01 PMgreen-summer-76342
11/28/2022, 8:35 PMelegant-dog-90839
11/29/2022, 10:30 AMincalculable-rainbow-43330
11/29/2022, 10:32 AMfresh-doctor-14925
11/29/2022, 10:58 AMfresh-doctor-14925
11/29/2022, 10:59 AMelegant-dog-90839
11/29/2022, 11:01 AMjs
/**
* This is the essential run function that will run all steps.
* It will look for the steps in tests/e2e/support/steps and either take customer specific steps or default steps.
* the it loops over them and executes the connected function.
*/
run() {
this.prepareJourney();
const steps = getSteps(Cypress.env('VUE_APP_ENVIRONMENT'));
steps.forEach((step) => {
cy.wait(Cypress.env('CY_WAIT_EXTRA_SHORT'));
if (step.preProcess) {
this[step.preProcess]();
}
if (step.process) {
this[step.process]();
}
if (step.postProcess) {
this[step.postProcess]();
} else {
this.postStepWait();
}
});
elegant-dog-90839
11/29/2022, 11:02 AMelegant-dog-90839
11/29/2022, 11:04 AMjs
[{
preProcess: null,
process: 'chooseProduct',
postProcess: null
},
{
preProcess: null,
process: 'personalForm',
postProcess: null
},]
fresh-doctor-14925
11/29/2022, 11:04 AMthis.prepareJourney()
So
cy.wrap(this.prepareJourney())
.then(() => {
// the rest of what you're wanting to do
})
cy.wait(Cypress.env('CY_WAIT_EXTRA_SHORT'))
.then(() => {
// Conditional steps
}
Other than that, I recommend using the plugin to better understand chaining in Cypress and avoiding conditional testing wherever possibleelegant-dog-90839
11/29/2022, 11:05 AMelegant-dog-90839
11/29/2022, 11:06 AMthis[step.process]();
elegant-dog-90839
11/29/2022, 11:06 AMelegant-dog-90839
11/29/2022, 11:08 AMjs
cy.wrap(this[step.preProcess]()).then(()=> cy.wrap(this[step.process]()).then(...))
elegant-dog-90839
11/29/2022, 11:08 AMelegant-dog-90839
11/29/2022, 11:09 AMfresh-doctor-14925
11/29/2022, 11:11 AM.then(() => {
if (step.preProcess) {
cy.wrap(this[step.preProcess]())
}
if (step.process) {
cy.wrap(this[step.process]())
}
if (step.postProcess) {
cy.wrap(this[step.postProcess]())
} else {
cy.wrap(this.postStepWait())
}
})
But I would suggest not having conditionals if possible, and instead trying to control the starting state of your app
As well, if any of these can be converted to cypress custom commands, you'll have an easier time with chainingelegant-dog-90839
11/29/2022, 11:12 AMelegant-dog-90839
11/29/2022, 11:12 AMelegant-dog-90839
11/29/2022, 11:12 AMelegant-dog-90839
11/29/2022, 11:13 AMelegant-dog-90839
11/29/2022, 11:13 AMelegant-dog-90839
11/29/2022, 11:13 AMfresh-doctor-14925
11/29/2022, 11:13 AMelegant-dog-90839
11/29/2022, 11:14 AMelegant-dog-90839
11/29/2022, 11:14 AMfresh-doctor-14925
11/29/2022, 11:14 AM