Skip to content

Commit

Permalink
feat(actions): add "When I clear local storage"
Browse files Browse the repository at this point in the history
  • Loading branch information
remarkablemark committed Jan 14, 2023
1 parent 0635759 commit df2407b
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/actions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export * from './cookie';
export * from './debug';
export * from './double-click';
export * from './go';
export * from './local-storage';
export * from './log';
export * from './pause';
export * from './reload';
Expand Down
40 changes: 40 additions & 0 deletions src/actions/local-storage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { When } from '@badeball/cypress-cucumber-preprocessor';

/* eslint-disable tsdoc/syntax */
/**
* When I clear local storage:
*
* ```gherkin
* When I clear local storage
* When I clear local storage {string}
* ```
*
* @example
*
* Clear all localStorage:
*
* ```gherkin
* When I clear local storage
* ```
*
* Clear localStorage with the key `appName`:
*
* ```gherkin
* When I clear local storage "appName"
* ```
*
* @remarks
*
* Clears [`localStorage`](https://developer.mozilla.org/docs/Web/API/Window/localStorage) data for current domain and subdomain.
*
* > Cypress automatically clears all local storage 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 localStorage inside a single test or test isolation is disabled.
*/
/* eslint-enable tsdoc/syntax */
export function When_I_clear_local_storage(key?: string) {
cy.clearLocalStorage(key);
}

When('I clear local storage', When_I_clear_local_storage);
When('I clear local storage {string}', When_I_clear_local_storage);

0 comments on commit df2407b

Please sign in to comment.