From 1b8da916d119295543ee53c80bfb95ad320dc7a4 Mon Sep 17 00:00:00 2001 From: Mark Date: Sat, 2 Dec 2023 17:38:10 -0500 Subject: [PATCH] feat(actions): add "When I clear all cookies" https://docs.cypress.io/api/commands/clearallcookies --- src/actions/cookies.ts | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/actions/cookies.ts b/src/actions/cookies.ts index 46321c447..9cd5d73ab 100644 --- a/src/actions/cookies.ts +++ b/src/actions/cookies.ts @@ -33,9 +33,47 @@ import { getOptions } from '../utils'; * @see * * - {@link When_I_clear_cookie | When I clear cookie} + * - {@link When_I_clear_all_cookies | When I clear all cookies} */ export function When_I_clear_cookies(options?: DataTable) { cy.clearCookies(getOptions(options)); } When('I clear cookies', When_I_clear_cookies); + +/** + * When I clear all cookies: + * + * ```gherkin + * When I clear all cookies + * ``` + * + * Clear all browser cookies. + * + * @example + * + * ```gherkin + * When I clear all cookies + * ``` + * + * With [options](https://docs.cypress.io/api/commands/clearallcookies#Arguments): + * + * ```gherkin + * When I clear all cookies + * | log | true | + * | timeout | 3000 | + * ``` + * + * @remarks + * + * Cypress automatically clears all cookies _before_ each test to prevent state from being shared across tests when [test isolation](https://docs.cypress.io/guides/core-concepts/writing-and-organizing-tests#Test-Isolation) is enabled. You shouldn't need to use this command unless you're using it to clear a specific cookie inside a single test or test isolation is disabled. + * + * @see + * + * - {@link When_I_clear_cookies | When I clear cookies} + */ +export function When_I_clear_all_cookies(options?: DataTable) { + cy.clearAllCookies(getOptions(options)); +} + +When('I clear all cookies', When_I_clear_all_cookies);