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
AbdealiLoKo opened this issue Apr 30, 2019 · 3 comments · Fixed by #4168
Closed

LocalStorage.clear not found #4070

AbdealiLoKo opened this issue Apr 30, 2019 · 3 comments · Fixed by #4168
Assignees

Comments

@AbdealiLoKo
Copy link

AbdealiLoKo 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
Copy link
Member

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?

@flotwig flotwig assigned flotwig and unassigned bahmutov May 2, 2019
@cypress-bot cypress-bot bot added stage: work in progress stage: needs review The PR code is done & tested, needs review and removed stage: work in progress labels May 9, 2019
@cypress-bot cypress-bot bot added stage: pending release and removed stage: needs review The PR code is done & tested, needs review labels May 13, 2019
@cypress-bot
Copy link
Contributor

cypress-bot bot 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
Copy link
Contributor

cypress-bot bot 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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants