Skip to content

Commit 85a252e

Browse files
author
Lenz Weber
committed
bind to 127.0.0.1 for travis
1 parent 3197496 commit 85a252e

1 file changed

Lines changed: 17 additions & 12 deletions

File tree

__tests__/integration.test.ts

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import federationPlugin from "../src";
2-
import * as express from "express";
2+
import * as http from "http";
33
import { postgraphile } from "postgraphile";
44
import { ApolloGateway } from "@apollo/gateway";
55
import { startFederatedServiceExtendingUser } from "./__fixtures__/federatedServiceExtendingUser";
@@ -22,20 +22,23 @@ afterAll(() => {
2222
}
2323
});
2424

25-
function startPostgraphile() {
26-
if (!pgPool) {
27-
throw new Error("pool not ready!");
28-
}
29-
return express()
30-
.use(
25+
function startPostgraphile(): Promise<http.Server> {
26+
return new Promise(resolve => {
27+
if (!pgPool) {
28+
throw new Error("pool not ready!");
29+
}
30+
const httpServer = http.createServer(
3131
postgraphile(pgPool, "graphile_federation", {
3232
disableDefaultMutations: true,
3333
appendPlugins: [federationPlugin],
3434
simpleCollections: "only",
3535
retryOnInitFail: true,
3636
})
37-
)
38-
.listen(0);
37+
);
38+
39+
httpServer.once("listening", () => resolve(httpServer));
40+
httpServer.listen({ port: 0, host: "127.0.0.1" });
41+
});
3942
}
4043

4144
function toUrl(
@@ -49,7 +52,7 @@ function toUrl(
4952
}
5053

5154
test("federated service", async () => {
52-
const postgraphileServer = startPostgraphile();
55+
const postgraphileServer = await startPostgraphile();
5356
const serviceExtendingUser = startFederatedServiceExtendingUser();
5457
let server: ApolloServer | undefined;
5558

@@ -61,7 +64,9 @@ test("federated service", async () => {
6164
},
6265
{
6366
name: "serviceExtendingUser",
64-
url: toUrl(await serviceExtendingUser.listen(0)),
67+
url: toUrl(
68+
await serviceExtendingUser.listen({ port: 0, host: "127.0.0.1" })
69+
),
6570
},
6671
];
6772

@@ -76,7 +81,7 @@ test("federated service", async () => {
7681
executor,
7782
});
7883

79-
const running = await server.listen(0);
84+
const running = await server.listen({ port: 0, host: "127.0.0.1" });
8085

8186
debugger;
8287
const result = await axios.post(running.url, {

0 commit comments

Comments
 (0)