Skip to content

Commit

Permalink
fix flakey tests (#3227)
Browse files Browse the repository at this point in the history
* add tests, escapse strings for console

* add comment about tests in logger.js

* fix undefined prop bug

* fix broken test

* move diff to dependencies

* fix escape function, add more tests, refacter showDiff

* pin diff dependency

* fix flakey timers_spec

* fix another flaky tests, seems .should doesn't retry when chained off of .then 🤔'

* timers_spec fix update, comment
  • Loading branch information
kuceb authored and brian-mann committed Jan 29, 2019
1 parent 1341893 commit acceb79
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
17 changes: 10 additions & 7 deletions packages/driver/test/cypress/integration/commands/xhr_spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -1915,13 +1915,16 @@ describe "src/cy/commands/xhr", ->
xhr.foo = "bar"
resolve(xhr)
xhr.send()
.should (xhr) ->
## ensure this is set to prevent accidental
## race conditions down the road if something
## goes wrong
expect(xhr.foo).to.eq("bar")
expect(xhr.aborted).not.to.be.true
expect(log.get("state")).to.eq("passed")
.then (xhr) ->
cy
.wrap(null)
.should ->
## ensure this is set to prevent accidental
## race conditions down the road if something
## goes wrong
expect(xhr.foo).to.eq("bar")
expect(xhr.aborted).not.to.be.true
expect(log.get("state")).to.eq("passed")

context "Cypress.on(window:unload)", ->
it "aborts all open XHR's", ->
Expand Down
9 changes: 7 additions & 2 deletions packages/driver/test/cypress/integration/cy/timers_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -387,12 +387,17 @@ describe('driver/src/cy/timers', () => {
.then((win) => {
const stub1 = cy.stub()

win.setTimeout(stub1, 200)
// we're setting setTimeout to 500ms because
// there were times where the driver's webserver
// was sending bytes after 200ms (TTFB) that caused
// this test to be flaky.
win.setTimeout(stub1, 500)

// force the window to sync reload
win.location.reload()

cy
.wait(400)
.wait(800)
.then(() => {
expect(stub1).not.to.be.called
})
Expand Down

0 comments on commit acceb79

Please sign in to comment.