supertest
supertest copied to clipboard
restify 6 gives app.address is not a function error
const restify = require('restify');
const server = restify.createServer();
server.get('/endpoint', (req, res) => {
res.send({ a: 'ok' });
});
server.listen(8080, () => {
console.log('%s listening at %s', server.name, server.url);
});
test('200 ok', done => {
const server = require('../index');
request(server)
.get('/endpoint')
.expect('Content-Type', /json/)
.expect(200, { a: 'ok' }, done);
});
trying to run this test results in a app.address is not a function
error.
Did anyone get supertest and restify v6+ up and running?
BTW, testing with jest
.
Dependencies:
{
"restify": "^6.3.4",
"jest": "^22.0.3",
"supertest": "^3.0.0",
// ...
}
I am just learning, but, trying adding:
module.exports = server
to you app.js/server.js
I am just learning, but, trying adding:
module.exports = server
to you app.js/server.js
In my case, this worked.