Created
September 6, 2016 04:54
-
-
Save pgarrison/6e474d1e907168e5f58ff46b7a4d9309 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "testing_bug", | |
"version": "1.0.0", | |
"description": "Bug?", | |
"main": "''", | |
"scripts": { | |
"test": "mocha test.js" | |
}, | |
"author": "", | |
"license": "ISC", | |
"devDependencies": { | |
"chai": "^3.5.0", | |
"express": "^4.14.0", | |
"mocha": "^3.0.2", | |
"supertest": "^2.0.0" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var expect = require('chai').expect; | |
var request = require('supertest'); | |
var express = require('express'); | |
describe('Testing requests and errors', function() { | |
var app; | |
before(function setup() { | |
app = express(); | |
app.get('/foo', function(req, res) { | |
app.emit('hi'); | |
res.send(200); | |
}); | |
app.foo = function(req, res) { | |
setTimeout(function() { | |
app.emit('hi'); | |
}, 100); | |
}; | |
}); | |
it('should fail fast, but times out instead', function(done) { | |
app.on('hi', function() { | |
console.log('got event'); // this happens | |
expect(true).to.equal(false); // this should cause the test to fail | |
}); | |
request(app) | |
.get('/foo') | |
.end(function(err) {}); | |
}); | |
it('should fail', function(done) { | |
app.on('hi', function() { | |
expect(true).to.equal(false); | |
}); | |
app.foo(); | |
}); | |
it('should fail', function(done) { | |
app.on('hi', function() { | |
expect(true).to.equal(false); | |
}); | |
app.emit('hi'); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment