My code doesn't do what it should. All the Jasmine expect()
that are in a supertest end()
callback function pass, even if they should not.
const app = require('../server')
const request = require('supertest')
describe('Client', function() {
const agent = request.agent(app)
it('connects to the server', function() {
agent.post('/users/register/foobar').end(function(err, res) {
done()
expect(true).toBe(false) // Doesn't fail
}
})
})
Extract from package.json
:
"devDependencies": {
"jasmine": "^2.4.1",
"supertest": "^2.0.0"
}
The actual versions given by npm list
are [email protected]
and [email protected]
.
My guess is that end()
never calls its function, but I just started yesterday with all that and I'm not sure what to do to solve the problem.
Do you see my error?
As suggested, I switched lines to put the done()
at the end, still no change, though.
I think you're wrong to use the function "done". Try:
it('connects to the server', function(done) {
agent.post('/users/register/foobar').end(function(err, res) {
expect(true).toBe(false); // Doesn't fail
done();
} })
For more details, check the jasmine documentation: Jasmine documentation: Asynchronous Support