-
-
Notifications
You must be signed in to change notification settings - Fork 173
Closed
Description
Polka does not work well with supertest. Is there alternative yet simple way to test Polka's middleware or router handler in a similar fashion?
FYI, I'm using Polka + TypeScript + Jest.
healthcheck.js
module.exports = function healthcheck() {
return (_, res) => res.end('OK');
};
healthcheck.spec.js
// With `supertest` in Express...
const express = require('express'); // const polka = require('polka');
const supertest = require('supertest');
const healthcheck = require('../healthcheck.js');
describe('test-route', () => {
it('returns', async (done) => {
try {
const app = express()); // const app = polka();
const rq = supertest(app.use('/healthcheck', healthcheck()); // throw error when using `polka`
rq.get('/healthcheck')
.expect(200)
.end((err, res) => {
if (err) throw err;
expect(res).toStrictEqual('OK');
done();
});
} catch (e) {
throw e;
}
}, 10e3);
});
Metadata
Metadata
Assignees
Labels
No labels