Skip to content

Commit

Permalink
Merge pull request #616 from remarkablemark/feat/local-storage
Browse files Browse the repository at this point in the history
feat(assertions): add "Then I see local storage item"
  • Loading branch information
remarkablemark authored Dec 3, 2023
2 parents b38257c + ebf36b6 commit 0a8d876
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cypress/e2e/cypress/example.feature
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,8 @@ Feature: Cypress example

Scenario: Local storage
Given I visit "https://example.cypress.io/commands/storage"
When I click on button "Populate localStorage and sessionStorage"
Then I see local storage item "prop1"
When I clear local storage
And I clear local storage "key"
And I clear all local storage
1 change: 1 addition & 0 deletions src/assertions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export * from './hash';
export * from './heading';
export * from './label';
export * from './link';
export * from './local-storage';
export * from './option';
export * from './response';
export * from './text';
Expand Down
24 changes: 24 additions & 0 deletions src/assertions/local-storage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { Then } from '@badeball/cypress-cucumber-preprocessor';

/**
* Then I see local storage item:
*
* ```gherkin
* Then I see local storage item {string}
* ```
*
* Assert local storage item with key **_exists_**.
*
* @example
*
* ```gherkin
* Then I see local storage item "key"
* ```
*/
export function Then_I_see_local_storage_item(key: string) {
cy.wrap({}).should(() => {
expect(localStorage.getItem(key)).to.exist;
});
}

Then('I see local storage item {string}', Then_I_see_local_storage_item);

0 comments on commit 0a8d876

Please sign in to comment.