From a565a77700b96956f2c8e74c058b01ac5cfb7572 Mon Sep 17 00:00:00 2001 From: Joseph Weissman <61561354+CypressJoseph@users.noreply.github.com> Date: Mon, 9 Mar 2020 00:02:43 -0400 Subject: [PATCH] =?UTF-8?q?Characterize=20overloaded=20signatures=20of=20c?= =?UTF-8?q?y.clearLocalStorage=20more=E2=80=A6=20(#6652)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Characterize overloaded signatures of cy.clearLocalStorage more carefully * capture clearLocalStorage signatures in kitchen sink tests --- cli/types/index.d.ts | 37 ++++++++++++++++++++++++++++++--- cli/types/tests/kitchen-sink.ts | 6 ++++++ 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/cli/types/index.d.ts b/cli/types/index.d.ts index 021d674d4a..ac62fc01bf 100644 --- a/cli/types/index.d.ts +++ b/cli/types/index.d.ts @@ -622,12 +622,12 @@ declare namespace Cypress { * @param {string} [key] - name of a particular item to remove (optional). * @example ``` - // removes all local storage keys + // Removes all local storage keys cy.clearLocalStorage() .should(ls => { expect(ls.getItem('prop1')).to.be.null }) - // removes item "todos" + // Removes item "todos" cy.clearLocalStorage("todos") ``` */ @@ -639,11 +639,42 @@ declare namespace Cypress { * @param {RegExp} re - regular expression to match. * @example ``` - // Clear all local storage matching /app-/ + // Clears all local storage matching /app-/ cy.clearLocalStorage(/app-/) ``` */ clearLocalStorage(re: RegExp): Chainable + /** + * Clear data in local storage. + * Cypress automatically runs this command before each test to prevent state from being + * shared across tests. You shouldn’t need to use this command unless you’re using it + * to clear localStorage inside a single test. Yields `localStorage` object. + * + * @see https://on.cypress.io/clearlocalstorage + * @param {options} [object] - options object + * @example + ``` + // Removes all local storage items, without logging + cy.clearLocalStorage({ log: false }) + ``` + */ + clearLocalStorage(options: Partial): Chainable + /** + * Clear data in local storage. + * Cypress automatically runs this command before each test to prevent state from being + * shared across tests. You shouldn’t need to use this command unless you’re using it + * to clear localStorage inside a single test. Yields `localStorage` object. + * + * @see https://on.cypress.io/clearlocalstorage + * @param {string} [key] - name of a particular item to remove (optional). + * @param {options} [object] - options object + * @example + ``` + // Removes item "todos" without logging + cy.clearLocalStorage("todos", { log: false }) + ``` + */ + clearLocalStorage(key: string, options: Partial): Chainable /** * Click a DOM element. diff --git a/cli/types/tests/kitchen-sink.ts b/cli/types/tests/kitchen-sink.ts index 63b83adbe3..4a2b56dec9 100644 --- a/cli/types/tests/kitchen-sink.ts +++ b/cli/types/tests/kitchen-sink.ts @@ -116,3 +116,9 @@ const obj = { foo: () => { } } cy.spy(obj, 'foo').as('my-spy') + +// clearLocalStorage signatures +cy.clearLocalStorage() +cy.clearLocalStorage('todos') +cy.clearLocalStorage('todos', { log: false }) +cy.clearLocalStorage({ log: false })