Skip to content

Commit f576d9f

Browse files
Minor enhancements on interceptApi command
1 parent 03e55ca commit f576d9f

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

cypress/support/commands/api_commands.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/**
44
* Custom command to get the intercepted API aliases stored in Cypress environment variables.
55
* This command returns the object containing all registered API interception aliases.
6-
*
6+
*
77
* @returns {Object} An object where keys are in format method-alias(e.g. post-myApiAlias) and values are typically the same alias names
88
* @example
99
* cy.getInterceptedApiAliases().then((aliases) => {
@@ -127,14 +127,12 @@ Cypress.Commands.add(
127127
/* ======================================================= */
128128

129129
// Check if this request is already registered
130-
cy.getInterceptedApiAliases().then((interceptedAliasesMap) => {
130+
return cy.getInterceptedApiAliases().then((interceptedAliasesMap) => {
131131
const aliasObjectKey = `${method.toLowerCase()}-${alias}`;
132132
// Check if this request is already registered
133133
const isAlreadyRegistered = !!interceptedAliasesMap[aliasObjectKey];
134134
// Setting wasRequestIntercepted flag to false initially
135-
if (waitOnlyIfRequestIntercepted) {
136-
setRequestIntercepted(false);
137-
}
135+
setRequestIntercepted(false);
138136
// Register the intercept if not already done
139137
if (!isAlreadyRegistered) {
140138
cy.intercept(method, urlPattern, (req) => {

0 commit comments

Comments
 (0)