Skip to content

Commit

Permalink
fix: Implement { log: false } for clearLocalStorage Issue #6342 (#6495)
Browse files Browse the repository at this point in the history
* fix: disable log for clearLocalStorage #6342

* fix: default log value

* fix: remove unwanted isnt false and options._log

* test: add test for log: false

* feat: add options fallback to keys param

* feat: add options fallback to keys param

* test: add test for key to be options

* test: fix not string error test

Co-authored-by: Brian Mann <brian.mann86@gmail.com>
Co-authored-by: Zach Bloomquist <github@chary.us>
Co-authored-by: Chris Breiding <chrisbreiding@users.noreply.github.com>
  • Loading branch information
4 people authored Feb 26, 2020
1 parent 655cd2e commit 62dd438
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 7 deletions.
17 changes: 12 additions & 5 deletions packages/driver/src/cy/commands/local_storage.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,24 @@ module.exports = (Commands, Cypress, cy, state, config) ->
null

Commands.addAll({
clearLocalStorage: (keys) ->
clearLocalStorage: (keys, options = {}) ->
if _.isPlainObject(keys)
options = keys
keys = null

_.defaults options, {log: true}

## bail if we have keys and we're not a string and we're not a regexp
if keys and not _.isString(keys) and not _.isRegExp(keys)
$errUtils.throwErrByPath("clearLocalStorage.invalid_argument")

remote = clearLocalStorage(state, keys)

Cypress.log
name: "clear ls"
snapshot: true
end: true
if options.log
Cypress.log
name: "clear ls"
snapshot: true
end: true

## return the remote local storage object
return remote
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ describe "src/cy/commands/local_storage", ->
cy.on "fail", (err) ->
expect(err.message).to.include "cy.clearLocalStorage() must be called with either a string or regular expression."
done()

cy.clearLocalStorage({})
# A number is used as an object will be considered as `options`
cy.clearLocalStorage(1)

describe ".log", ->
beforeEach ->
Expand All @@ -63,3 +63,23 @@ describe "src/cy/commands/local_storage", ->

expect(lastLog.get("snapshots").length).to.eq(1)
expect(lastLog.get("snapshots")[0]).to.be.an("object")

describe "without log", ->
beforeEach ->
cy.on "log:added", (attrs, log) =>
@lastLog = log

return null

it "log is disabled", ->
cy.clearLocalStorage('foo', {log: false}).then ->
lastLog = @lastLog

expect(lastLog).to.be.undefined

it "log is disabled without key", ->
cy.clearLocalStorage({log: false}).then ->
lastLog = @lastLog

expect(lastLog).to.be.undefined

4 comments on commit 62dd438

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 62dd438 Feb 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux x64 version of the Test Runner.

You can install this pre-release platform-specific build using instructions at https://on.cypress.io/installing-cypress#Install-pre-release-version.

You will need to use custom CYPRESS_INSTALL_BINARY url and install Cypress using an url instead of the version.

export CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/4.0.3/linux-x64/circle-develop-62dd43848592433cd57cfb2d06f25158ce16b8dd-265629/cypress.zip
npm install https://cdn.cypress.io/beta/npm/4.0.3/circle-develop-62dd43848592433cd57cfb2d06f25158ce16b8dd-265610/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 62dd438 Feb 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux x64 version of the Test Runner.

You can install this pre-release platform-specific build using instructions at https://on.cypress.io/installing-cypress#Install-pre-release-version.

You will need to use custom CYPRESS_INSTALL_BINARY url and install Cypress using an url instead of the version.

export CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/4.0.3/darwin-x64/circle-develop-62dd43848592433cd57cfb2d06f25158ce16b8dd-265742/cypress.zip
npm install https://cdn.cypress.io/beta/npm/4.0.3/circle-develop-62dd43848592433cd57cfb2d06f25158ce16b8dd-265630/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 62dd438 Feb 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AppVeyor has built the win32 ia32 version of the Test Runner.

You can install this pre-release platform-specific build using instructions at https://on.cypress.io/installing-cypress#Install-pre-release-version.

You will need to use custom CYPRESS_INSTALL_BINARY url and install Cypress using an url instead of the version.

Instructions are included below, depending on the shell you are using.

In Command Prompt (cmd.exe):

set CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/4.0.3/win32-ia32/appveyor-develop-62dd43848592433cd57cfb2d06f25158ce16b8dd-31081361/cypress.zip
npm install https://cdn.cypress.io/beta/npm/4.0.3/appveyor-develop-62dd43848592433cd57cfb2d06f25158ce16b8dd-31081361/cypress.tgz

In PowerShell:

$env:CYPRESS_INSTALL_BINARY = https://cdn.cypress.io/beta/binary/4.0.3/win32-ia32/appveyor-develop-62dd43848592433cd57cfb2d06f25158ce16b8dd-31081361/cypress.zip
npm install https://cdn.cypress.io/beta/npm/4.0.3/appveyor-develop-62dd43848592433cd57cfb2d06f25158ce16b8dd-31081361/cypress.tgz

In Git Bash:

export CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/4.0.3/win32-ia32/appveyor-develop-62dd43848592433cd57cfb2d06f25158ce16b8dd-31081361/cypress.zip
npm install https://cdn.cypress.io/beta/npm/4.0.3/appveyor-develop-62dd43848592433cd57cfb2d06f25158ce16b8dd-31081361/cypress.tgz

Using cross-env:

If the above commands do not work for you, you can also try using cross-env:

npm i -g cross-env
cross-env CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/4.0.3/win32-ia32/appveyor-develop-62dd43848592433cd57cfb2d06f25158ce16b8dd-31081361/cypress.zip npm install https://cdn.cypress.io/beta/npm/4.0.3/appveyor-develop-62dd43848592433cd57cfb2d06f25158ce16b8dd-31081361/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 62dd438 Feb 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AppVeyor has built the win32 x64 version of the Test Runner.

You can install this pre-release platform-specific build using instructions at https://on.cypress.io/installing-cypress#Install-pre-release-version.

You will need to use custom CYPRESS_INSTALL_BINARY url and install Cypress using an url instead of the version.

Instructions are included below, depending on the shell you are using.

In Command Prompt (cmd.exe):

set CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/4.0.3/win32-x64/appveyor-develop-62dd43848592433cd57cfb2d06f25158ce16b8dd-31081361/cypress.zip
npm install https://cdn.cypress.io/beta/npm/4.0.3/appveyor-develop-62dd43848592433cd57cfb2d06f25158ce16b8dd-31081361/cypress.tgz

In PowerShell:

$env:CYPRESS_INSTALL_BINARY = https://cdn.cypress.io/beta/binary/4.0.3/win32-x64/appveyor-develop-62dd43848592433cd57cfb2d06f25158ce16b8dd-31081361/cypress.zip
npm install https://cdn.cypress.io/beta/npm/4.0.3/appveyor-develop-62dd43848592433cd57cfb2d06f25158ce16b8dd-31081361/cypress.tgz

In Git Bash:

export CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/4.0.3/win32-x64/appveyor-develop-62dd43848592433cd57cfb2d06f25158ce16b8dd-31081361/cypress.zip
npm install https://cdn.cypress.io/beta/npm/4.0.3/appveyor-develop-62dd43848592433cd57cfb2d06f25158ce16b8dd-31081361/cypress.tgz

Using cross-env:

If the above commands do not work for you, you can also try using cross-env:

npm i -g cross-env
cross-env CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/4.0.3/win32-x64/appveyor-develop-62dd43848592433cd57cfb2d06f25158ce16b8dd-31081361/cypress.zip npm install https://cdn.cypress.io/beta/npm/4.0.3/appveyor-develop-62dd43848592433cd57cfb2d06f25158ce16b8dd-31081361/cypress.tgz

Please sign in to comment.