Skip to content

Commit

Permalink
added additional integration tests around ended early errors
Browse files Browse the repository at this point in the history
  • Loading branch information
brian-mann committed Apr 22, 2015
1 parent a635124 commit 459c61a
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 5 deletions.
13 changes: 13 additions & 0 deletions spec/client/api/integration/ended_early_spec.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
describe "Timeout Integration Tests", ->
## dont console.error errors else it makes it look
## like our tests are failing!
enterIntegrationTestingMode("html/ended_early", {silent: true})

context "ended early", ->
it "correct associates runnable which ended early", (done) ->
runner = @Cypress.runner

@Cypress.run (failures) ->
test = runner.getTestByTitle("does end early [003]")
expect(test.err.message).to.eq "Cypress detected your test ended early before all of the commands have run. This can happen if you explicitly done() a test before all of the commands have finished."
done()
10 changes: 7 additions & 3 deletions spec/client/spec_helper.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,20 @@ window.getNames = (queue) ->
window.getFirstSubjectByName = (name) ->
_(@cy.queue).findWhere({name: name}).subject

window.enterIntegrationTestingMode = (fixture) ->
window.enterIntegrationTestingMode = (fixture, options = {}) ->
_.defaults options,
silent: false

before ->
@loadDom = _.bind(loadDom, @)

beforeEach ->
## load all of the modules
@Cypress = $Cypress.create({loadModules: true})

@Cypress.on "fail", (err) ->
console.error(err.stack)
if options.silent is false
@Cypress.on "fail", (err) ->
console.error(err.stack)

@loadDom(fixture).then =>
@Cypress.initialize @iframe.prop("contentWindow"), @iframe, ->
Expand Down
28 changes: 28 additions & 0 deletions spec/fixtures/html/ended_early.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!doctype html>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<title>Ended Early Tests</title>
<link rel="icon" href="data:;base64,=">
<script type="text/javascript" src="/lib/public/js/iframe.js"></script>
<script type="text/javascript">
describe("ending early [001]", function(){
beforeEach(function(){
cy.visit("fixtures/html/generic.html")
})

it("does not end early [002]", function(){

})

it("does end early [003]", function(done){
cy.then(function(){})

done()
})
})
</script>
</head>
<body>
</body>
</html>
4 changes: 3 additions & 1 deletion spec/fixtures/html/generic.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@
<head>
<title>Generic HTML Fixture</title>
</head>
<body></body>
<body>
Some generic content
</body>
</html>
2 changes: 1 addition & 1 deletion spec/fixtures/html/timeout.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<title>.Only Tests</title>
<title>Timeout Tests</title>
<link rel="icon" href="data:;base64,=">
<script type="text/javascript" src="/lib/public/js/iframe.js"></script>
<script type="text/javascript">
Expand Down

0 comments on commit 459c61a

Please sign in to comment.