Skip to content

Instantly share code, notes, and snippets.

@subtleGradient
Created July 29, 2019 20:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save subtleGradient/dbb15536ce7585a2bd3c93ceaef11af4 to your computer and use it in GitHub Desktop.
Save subtleGradient/dbb15536ce7585a2bd3c93ceaef11af4 to your computer and use it in GitHub Desktop.
Cypress.Commands.add('waitForAllAPIs', waitForAllAPIs);
let requestCount;
beforeEach(() => {
requestCount = 0;
cy.server({
onRequest() {
requestCount++;
},
onResponse() {
setTimeout(() => requestCount--, 0);
}
});
});
export const waitForAllAPIs = () => {
cy.log('Waiting for pending API requests:');
cy
.shouldRetry(() => {
expect(requestCount).to.eq(0);
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment