ladjs / supertest

🕷 Super-agent driven library for testing node.js HTTP servers using a fluent API. Maintained for @forwardemail, @ladjs, @spamscanner, @breejs, @cabinjs, and @lassjs.
MIT License
13.82k stars 759 forks source link

restify 6 gives app.address is not a function error #452

Open pkyeck opened 6 years ago

pkyeck commented 6 years ago
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",
  // ...
}
sjames-au commented 6 years ago

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

modavidc commented 2 years ago

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

In my case, this worked.