Skip to content

Commit 225bcd2

Browse files
lilaconleejennifer-shehane
authored andcommitted
Clone setCookie options instead of mutating (#2707)
* Clone setCookie options instead of mutating * Clone command options in runCommand * Revert "Clone command options in runCommand" This reverts commit 0e5aeb1. Co-authored-by: Jennifer Shehane <shehane.jennifer@gmail.com>
1 parent 85569fa commit 225bcd2

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

packages/driver/src/cy/commands/cookies.coffee

+2-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,8 @@ module.exports = (Commands, Cypress, cy, state, config) ->
143143

144144
return resp
145145

146-
setCookie: (name, value, options = {}) ->
146+
setCookie: (name, value, userOptions = {}) ->
147+
options = _.clone(userOptions)
147148
_.defaults options, {
148149
name: name
149150
value: value

packages/driver/test/cypress/integration/commands/cookies_spec.coffee

+9
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,15 @@ describe "src/cy/commands/cookies", ->
388388
{ domain: "brian.dev.local", name: "foo", value: "bar", path: "/foo", secure: true, httpOnly: true, expiry: 987 }
389389
)
390390

391+
it "can set multiple cookies with the same options", ->
392+
Cypress.utils.addTwentyYears.restore()
393+
options = {}
394+
395+
cy.setCookie("foo", "bar", options)
396+
cy.setCookie("bing", "bong", options)
397+
398+
cy.getCookie("bing").its("value").should("equal", "bong")
399+
391400
describe "timeout", ->
392401
it "sets timeout to Cypress.config(responseTimeout)", ->
393402
Cypress.config("responseTimeout", 2500)

0 commit comments

Comments
 (0)