Skip to content

Commit

Permalink
Kill hanging process after integration tests complete
Browse files Browse the repository at this point in the history
  • Loading branch information
GregBrimble committed Mar 22, 2022
1 parent bb8e1ed commit 1a0f403
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
12 changes: 9 additions & 3 deletions packages/example-pages-functions-app/tests/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { spawn } from "child_process";
import { ChildProcess, spawn } from "child_process";
import { resolve } from "path";
import { fetch } from "undici";
import type { Response } from "undici";
Expand All @@ -19,9 +19,11 @@ const waitUntilReady = async (url: string): Promise<Response> => {

const isWindows = process.platform === "win32";

describe("Remix", () => {
describe("Pages Functions", () => {
let wranglerProcess: ChildProcess;

beforeAll(async () => {
const wranglerProcess = spawn("npm", ["run", "dev"], {
wranglerProcess = spawn("npm", ["run", "dev"], {
shell: isWindows,
cwd: resolve(__dirname, "../"),
env: { BROWSER: "none", ...process.env },
Expand All @@ -34,6 +36,10 @@ describe("Remix", () => {
});
});

afterAll(() => {
wranglerProcess.kill();
});

it("renders static pages", async () => {
const response = await waitUntilReady("http://localhost:8789/");
const text = await response.text();
Expand Down
10 changes: 8 additions & 2 deletions packages/example-remix-pages-app/tests/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { spawn, spawnSync } from "child_process";
import { ChildProcess, spawn, spawnSync } from "child_process";
import { resolve } from "path";
import { fetch } from "undici";
import type { Response } from "undici";
Expand All @@ -20,12 +20,14 @@ const waitUntilReady = async (url: string): Promise<Response> => {
const isWindows = process.platform === "win32";

describe("Remix", () => {
let wranglerProcess: ChildProcess;

beforeAll(async () => {
spawnSync("npm", ["run", "build"], {
shell: isWindows,
cwd: resolve(__dirname, "../"),
});
const wranglerProcess = spawn("npm", ["run", "dev:wrangler"], {
wranglerProcess = spawn("npm", ["run", "dev:wrangler"], {
shell: isWindows,
cwd: resolve(__dirname, "../"),
env: { BROWSER: "none", ...process.env },
Expand All @@ -38,6 +40,10 @@ describe("Remix", () => {
});
});

afterAll(() => {
wranglerProcess.kill();
});

it("renders", async () => {
const response = await waitUntilReady("http://localhost:8788/");
const text = await response.text();
Expand Down

0 comments on commit 1a0f403

Please sign in to comment.