Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LocalStorage.clear not found #4070

Closed
AbdealiJK opened this issue Apr 30, 2019 · 3 comments

Comments

4 participants
@AbdealiJK
Copy link

commented Apr 30, 2019

Current behavior:

As per the docs at https://on.cypress.io/using-cypress-faq#How-do-I-preserve-cookies-localStorage-in-between-my-tests for LocalStorage which links to #461 (comment)

I am trying to override the Cypress.LocalStorage.clear. This gives me a typescript error that Cypress has no property LocalStorage.

I have /// <reference types="cypress" /> and all my other type management is working fine.

Desired behavior:

Was expecting to be able to override the LocalStorage.clear as described in docs to whitelist some keys that should not be cleared.

Steps to reproduce: (app code and test code)

I'm adding this to my support/commands.ts

const oldCypressLocalStorageClear = Cypress.LocalStorage.clear

Cypress.LocalStorage.clear = function (keys, ls, rs) {
    // do something with the keys here
    cy.debug();
    if (keys) {
        return oldCypressLocalStorageClear.apply(this, arguments)
    }
}

Versions

Mac OSX 10.13.6
cypress: ^3.1.5 (locked at 3.2.0)

@jennifer-shehane

This comment has been minimized.

Copy link
Member

commented Apr 30, 2019

Yeah, since this isn't a publicly documented method in our documentation, there weren't any TypeScript definitions added for it.

@bahmutov How would you handle something like this?

@cypress-bot

This comment has been minimized.

Copy link

commented May 13, 2019

The code for this is done in cypress-io/cypress#4168, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

@cypress-bot

This comment has been minimized.

Copy link

commented May 17, 2019

Released in 3.3.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.