Skip to content

Commit

Permalink
Merge pull request #628 from remarkablemark/feat/session-storage
Browse files Browse the repository at this point in the history
feat(assertions): add "Then I do not see session storage item"
  • Loading branch information
remarkablemark authored Dec 3, 2023
2 parents 5422a2b + e829780 commit 92cad9a
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions cypress/e2e/cypress/example.feature
Original file line number Diff line number Diff line change
Expand Up @@ -355,3 +355,4 @@ Feature: Cypress example
When I click on button "Populate localStorage and sessionStorage"
Then I see session storage item "prop5"
When I clear session storage
Then I do not see local storage item "prop5"
34 changes: 34 additions & 0 deletions src/assertions/session-storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ import { Then } from '@badeball/cypress-cucumber-preprocessor';
* ```gherkin
* Then I see session storage item "key"
* ```
*
* @see
*
* - {@link Then_I_do_not_see_session_storage_item | Then I do not see session storage item}
*/
export function Then_I_see_session_storage_item(key: string) {
cy.wrap({}).should(() => {
Expand All @@ -22,3 +26,33 @@ export function Then_I_see_session_storage_item(key: string) {
}

Then('I see session storage item {string}', Then_I_see_session_storage_item);

/**
* Then I do not see session storage item:
*
* ```gherkin
* Then I do not see session storage item {string}
* ```
*
* Assert session storage item **_does not exist_**.
*
* @example
*
* ```gherkin
* Then I do not see session storage item "key"
* ```
*
* @see
*
* - {@link Then_I_see_session_storage_item | Then I see session storage item}
*/
export function Then_I_do_not_see_session_storage_item(key: string) {
cy.wrap({}).should(() => {
expect(sessionStorage.getItem(key)).to.not.exist;
});
}

Then(
'I do not see session storage item {string}',
Then_I_do_not_see_session_storage_item,
);

0 comments on commit 92cad9a

Please sign in to comment.