Skip to content

Commit

Permalink
add failing driver and server tests for circular objs over websocket
Browse files Browse the repository at this point in the history
  • Loading branch information
flotwig committed Jun 12, 2019
1 parent 91c24aa commit 4091206
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,18 @@ describe "driver/src/cypress/index", ->

done()

## https://github.com/cypress-io/cypress/issues/4346
it "can complete if a circular reference is sent", ->
foo = {
bar: {}
}

foo.bar.baz = foo

Cypress.backend("foo", foo)
.catch (e) ->
expect(e.message).to.eq('You requested a backend event we cannot handle: foo')

context ".isCy", ->
it "returns true on cy, cy chainable", ->
expect(Cypress.isCy(cy)).to.be.true
Expand Down Expand Up @@ -75,4 +87,4 @@ describe "driver/src/cypress/index", ->
fn = ->
Cypress.log({ message: 'My Log' })

expect(fn).to.not.throw()
expect(fn).to.not.throw()
16 changes: 16 additions & 0 deletions packages/server/test/unit/socket_spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,22 @@ describe "lib/socket", ->
afterEach ->
@client.disconnect()

## https://github.com/cypress-io/cypress/issues/4346
it "can emit a circular object without crashing", (done) ->
foo = {
bar: {}
}

foo.bar.baz = foo

## going to stub exec here just so we have something that we can
## control the resolved value of
sinon.stub(exec, 'run').resolves(foo)

@client.emit "backend:request", "exec", "quuz", (res) ->
expect(res).to.deep.eq(foo)
done()

context "on(automation:request)", ->
describe "#onAutomation", ->
before ->
Expand Down

0 comments on commit 4091206

Please sign in to comment.