Skip to content

Commit 4091206

Browse files
committed
add failing driver and server tests for circular objs over websocket
1 parent 91c24aa commit 4091206

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

packages/driver/test/cypress/integration/cypress/cypress_spec.coffee

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,18 @@ describe "driver/src/cypress/index", ->
4747

4848
done()
4949

50+
## https://github.com/cypress-io/cypress/issues/4346
51+
it "can complete if a circular reference is sent", ->
52+
foo = {
53+
bar: {}
54+
}
55+
56+
foo.bar.baz = foo
57+
58+
Cypress.backend("foo", foo)
59+
.catch (e) ->
60+
expect(e.message).to.eq('You requested a backend event we cannot handle: foo')
61+
5062
context ".isCy", ->
5163
it "returns true on cy, cy chainable", ->
5264
expect(Cypress.isCy(cy)).to.be.true
@@ -75,4 +87,4 @@ describe "driver/src/cypress/index", ->
7587
fn = ->
7688
Cypress.log({ message: 'My Log' })
7789

78-
expect(fn).to.not.throw()
90+
expect(fn).to.not.throw()

packages/server/test/unit/socket_spec.coffee

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,22 @@ describe "lib/socket", ->
7070
afterEach ->
7171
@client.disconnect()
7272

73+
## https://github.com/cypress-io/cypress/issues/4346
74+
it "can emit a circular object without crashing", (done) ->
75+
foo = {
76+
bar: {}
77+
}
78+
79+
foo.bar.baz = foo
80+
81+
## going to stub exec here just so we have something that we can
82+
## control the resolved value of
83+
sinon.stub(exec, 'run').resolves(foo)
84+
85+
@client.emit "backend:request", "exec", "quuz", (res) ->
86+
expect(res).to.deep.eq(foo)
87+
done()
88+
7389
context "on(automation:request)", ->
7490
describe "#onAutomation", ->
7591
before ->

0 commit comments

Comments
 (0)