aboutsummaryrefslogtreecommitdiff
path: root/test/js/node/child_process/child_process.test.ts
diff options
context:
space:
mode:
authorGravatar Colin McDonnell <colinmcd94@gmail.com> 2023-03-22 15:01:01 -0700
committerGravatar GitHub <noreply@github.com> 2023-03-22 15:01:01 -0700
commita5f92224b586289fc72f0abdb68b08eef9f017db (patch)
tree6092397858776820b431b0dffa635d8bc3b3185e /test/js/node/child_process/child_process.test.ts
parent2bdaa81b1c2325687c5115b4e97627533cb3646b (diff)
downloadbun-a5f92224b586289fc72f0abdb68b08eef9f017db.tar.gz
bun-a5f92224b586289fc72f0abdb68b08eef9f017db.tar.zst
bun-a5f92224b586289fc72f0abdb68b08eef9f017db.zip
Fix types (#2453)
* WIP * WIP * WIP * WIP * Improve typechecking in type files * Fix typechecking * Update * Update submodule * CI for typechecking * Add ci * Update commands * Format after build * Dont use bunx * Rename job * Use nodemodules prettier * Update workflow * Use symlink * Debug * Debug * Clean up and rename jobs
Diffstat (limited to 'test/js/node/child_process/child_process.test.ts')
-rw-r--r--test/js/node/child_process/child_process.test.ts18
1 files changed, 10 insertions, 8 deletions
diff --git a/test/js/node/child_process/child_process.test.ts b/test/js/node/child_process/child_process.test.ts
index 167cbd8b0..c249c6434 100644
--- a/test/js/node/child_process/child_process.test.ts
+++ b/test/js/node/child_process/child_process.test.ts
@@ -4,14 +4,14 @@ import { ChildProcess, spawn, execFile, exec, fork, spawnSync, execFileSync, exe
import { tmpdir } from "node:os";
import { promisify } from "node:util";
-const expect: typeof expect_ = (actual: unknown) => {
+const expect = ((actual: unknown) => {
gcTick();
const ret = expect_(actual);
gcTick();
return ret;
-};
+}) as typeof expect_;
-const it: typeof it_ = (label, fn) => {
+const it = ((label, fn) => {
const hasDone = fn.length === 1;
if (fn.constructor.name === "AsyncFunction" && hasDone) {
return it_(label, async done => {
@@ -38,7 +38,7 @@ const it: typeof it_ = (label, fn) => {
gcTick();
});
}
-};
+}) as typeof it_;
const debug = process.env.DEBUG ? console.log : () => {};
@@ -56,6 +56,7 @@ describe("ChildProcess.spawn()", () => {
proc.on("spawn", () => {
resolve(true);
});
+ // @ts-ignore
proc.spawn({ file: "bun", args: ["bun", "-v"] });
});
expect(result).toBe(true);
@@ -67,7 +68,7 @@ describe("ChildProcess.spawn()", () => {
proc.on("exit", () => {
resolve(true);
});
-
+ // @ts-ignore
proc.spawn({ file: "bun", args: ["bun", "-v"] });
proc.kill();
});
@@ -174,14 +175,15 @@ describe("spawn()", () => {
it("should allow us to timeout hanging processes", async () => {
const child = spawn("sleep", ["2"], { timeout: 3 });
const start = performance.now();
- let end;
+ let end: number;
await new Promise(resolve => {
child.on("exit", () => {
end = performance.now();
resolve(true);
});
});
- expect(end - start < 2000).toBe(true);
+ expect(end!).toBeDefined();
+ expect(end! - start < 2000).toBe(true);
});
it("should allow us to set env", async () => {
@@ -195,7 +197,7 @@ describe("spawn()", () => {
});
it("should allow explicit setting of argv0", async () => {
- var resolve;
+ var resolve: (_?: any) => void;
const promise = new Promise<string>(resolve1 => {
resolve = resolve1;
});