Created
December 7, 2018 19:25
-
-
Save jessesanders/83e1f6874b90f8460320a093ad6b5f7e to your computer and use it in GitHub Desktop.
Cypress example on waiting for stubbed responses to return
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cy.server(); | |
// create aliases | |
cy.route("activities/*", "fixture:activities").as("getActivities"); | |
cy.route("messages/*", "fixture:messages").as("getMessages"); | |
// visit the dashboard, which should make requests that match | |
// the two routes above | |
cy.visit("http://localhost:8888/dashboard"); | |
// pass an array of Route Aliases that forces Cypress to wait | |
// until it sees a response for each request that matches | |
// each of these aliases | |
cy.wait(["@getActivities", "@getMessages"]); | |
// these commands will not run until the wait command resolves above | |
cy.get("h1").should("contain", "Dashboard"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment