supertest icon indicating copy to clipboard operation
supertest copied to clipboard

restify 6 gives app.address is not a function error

Open pkyeck opened this issue 7 years ago • 2 comments

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",
  // ...
}

pkyeck avatar Dec 21 '17 20:12 pkyeck

I am just learning, but, trying adding: module.exports = server to you app.js/server.js

sjames-au avatar Jan 12 '18 01:01 sjames-au

I am just learning, but, trying adding: module.exports = server to you app.js/server.js

In my case, this worked.

modavidc avatar Sep 24 '22 20:09 modavidc