Chaining commands that return a "promise" in beforeEach #15288
Unanswered
Nxtra
asked this question in
Component Testing
Replies: 1 comment 1 reply
-
You can use cy.wrap to make Cypress test wait for your promise to finish. But I don't understand from your examples what is not working. The red flag to me is this: beforeEach(() => {
makeNewClub().then((c)=> createdClub = c)
makeNewCompetition(createdClub).then((comp) => createdCompetition = comp)
}); Notice how beforeEach(() => {
makeNewClub().then((c)=> {
createdClub = c
makeNewCompetition(createdClub).then((comp) => createdCompetition = comp)
})
}); |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I want to do some setup before I start executing my e2e tests.
Example:
An application where clubs can organize competitions for members to enroll in.
I want to test the page to enroll in a competition.
BeforeEach
Before running a test I need to setup a Club. And a competition created by that Club.
(Hence we will need to chain these requests).
However I cannot get it working. Here is the code that runs in beforeEach:
This does not work, so I tried chaining it somehow:
This doesn't work either.
Important to know. You need authorization for the calls to makeNewClub and makeNewCompetition:
commands.js
club.util.js
How can a properly chain the calls from makeNewClub and makeNewCompetition
Beta Was this translation helpful? Give feedback.
All reactions