Skip to content

Instantly share code, notes, and snippets.

@pgarrison
Created September 6, 2016 04:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pgarrison/6e474d1e907168e5f58ff46b7a4d9309 to your computer and use it in GitHub Desktop.
Save pgarrison/6e474d1e907168e5f58ff46b7a4d9309 to your computer and use it in GitHub Desktop.
{
"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"
}
}
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