Skip to content

Commit

Permalink
Merge pull request #103 from ShellyDCMS/get-number-of-requests
Browse files Browse the repository at this point in the history
add getNumberOfRequests
  • Loading branch information
ShellyDCMS committed Jun 14, 2024
2 parents 0d9e23a + d1d5182 commit 0f7d89a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@shellygo/cypress-test-utils",
"description": "Cypress Test Automation Utilities",
"version": "2.1.12",
"version": "2.1.13",
"author": "Shelly Goldblit",
"private": false,
"license": "MIT",
Expand Down
4 changes: 4 additions & 0 deletions src/cypress-helper.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ describe("cypress helper tests", () => {
shelly: "3"
});
});

it("should assert number of calls", () => {
then(get.numberOfRequests("shellygo")).shouldEqual(3);
});
});

describe("interception negative tests", () => {
Expand Down
13 changes: 13 additions & 0 deletions src/cypress-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,19 @@ export class CypressHelper {
*/
numberOfElements: (dataTestID: string): Cypress.Chainable<number> =>
this.get.bySelector(dataTestID).its("length"),

/**
* Get number of outgoing request with a specific alias
* @example
* ```ts
* then(helper.get.numberOfCalls("fetch-pokemon")).shouldEqual(2);
* ```
* @param alias
* @returns {Cypress.Chainable<number>}
*/
numberOfRequests: (alias: string): Cypress.Chainable<number> =>
cy.get(`@${alias}.all`).its("length"),

/**
* @example
* ```ts
Expand Down

0 comments on commit 0f7d89a

Please sign in to comment.