We'd like to run supertest-fetch
's tests on Heroku before each release.
Example test:
import {FetchFunction, makeFetch} from 'supertest-fetch';
import {koa} from '../koa';
import {Server} from 'http';
describe('User controller', () => {
let fetch: FetchFunction;
let server: Server;
beforeAll(() => {
server = koa.listen(3101);
fetch = makeFetch(server);
});
afterAll(() => {
server.close();
});
it('GET /users should return 200', async () => {
const response = await fetch('/users');
expect(response.status).toEqual(200);
});
});
Procfile:
release: npm test && node db-tools/apply-migrations.js
Running that test on Heroku fails with
remote: FAIL src/controller/user.spec.ts (5.506s)
remote: User controller
remote: ✕ GET /users should return 200 (48ms)
remote:
remote: ● User controller › GET /users should return 200
remote:
remote: FetchError: request to https://localhost/users failed, reason: connect ECONNREFUSED 127.0.0.1:443
remote:
remote: at ClientRequest.<anonymous> (node_modules/node-fetch/lib/index.js:1345:11)
remote:
I don't know why supertest-fetch makes request for https and even if it made request for http, I don't think Heroku allows arbitrary ports to serve. Did anybody succeed at running supertest's tests on Heroku?