Skip to content

Commit 99a3fb8

Browse files
Update JSDoc for interceptApi command
1 parent ae4d4ec commit 99a3fb8

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

cypress/support/commands/api_commands.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,19 +84,20 @@ const getRequestIntercepted = () => Cypress.env('wasRequestIntercepted');
8484
*
8585
* @param {Object} options - The options for the intercept
8686
* @param {string} options.alias - Unique alias for this interception
87-
* @param {string} options.method - HTTP method (default: 'POST')
87+
* @param {string} [options.method] - HTTP method (default: 'POST')
8888
* @param {string|RegExp} options.urlPattern - URL pattern to intercept
89-
* @param {boolean} [options.waitOnlyIfRequestIntercepted=false] - When set to true, the command will only wait for the response
89+
* @param {boolean} [options.waitOnlyIfRequestIntercepted] - When set to true(default: false), the command will only wait for the response
9090
* if the request was actually intercepted. This is useful for conditional API calls that may or may not happen like in tree navigations.
9191
* If false (default), the command will always wait for the intercepted request, where a request is always expected (e.g., button events).
92-
* @param {Function} options.triggerFn - Function that triggers the API call
92+
* @param {Function} options.triggerFn - Function that triggers the API call. e.g. { triggerFn: () => { cy.get('button').click(); } }
9393
* @param {Function} [options.responseInterceptor] - Optional function that can modify the response before it's returned to the application.
9494
* This function receives the request object and can handle the response in different ways:
9595
* 1. req.reply({body: {...}}) - Immediately respond with a stubbed response (request never goes to origin)
9696
* 2. req.continue() - Let the request go to the origin server without modification
9797
* 3. req.continue((res) => { res.send({...}) }) - Let the request go to origin, then modify the response
9898
* Examples:
9999
* - Stub response: { responseInterceptor: (req) => req.reply({ body: { customData: 'value' } }) }
100+
* - Using fixture to stub response: { responseInterceptor: (req) => req.reply({ fixture: 'users.json' }) }
100101
* - Pass through to origin: { responseInterceptor: (req) => req.continue() }
101102
* - Modify origin response: { responseInterceptor: (req) => req.continue((res) => { res.send(200, { modified: true }) }) }
102103
* @param {Function} [options.onApiResponse] - Optional callback function that receives the interception object after the API call completes.

0 commit comments

Comments
 (0)