diff options
Diffstat (limited to 'test/js')
-rw-r--r-- | test/js/bun/dns/resolve-dns.test.ts | 2 | ||||
-rw-r--r-- | test/js/bun/plugin/plugins.test.ts | 4 | ||||
-rw-r--r-- | test/js/bun/resolve/png/test-png-import.test.js | 4 | ||||
-rw-r--r-- | test/js/bun/test/preload-test.test.js | 4 | ||||
-rw-r--r-- | test/js/bun/test/snapshot-tests/snapshots/more-snapshots/different-directory.test.ts | 2 | ||||
-rw-r--r-- | test/js/bun/test/snapshot-tests/snapshots/more.test.ts | 7 | ||||
-rw-r--r-- | test/js/node/child_process/child_process-node.test.js | 78 | ||||
-rw-r--r-- | test/js/node/child_process/child_process.test.ts | 58 | ||||
-rw-r--r-- | test/js/node/process/process.test.js | 2 |
9 files changed, 61 insertions, 100 deletions
diff --git a/test/js/bun/dns/resolve-dns.test.ts b/test/js/bun/dns/resolve-dns.test.ts index 87d666616..6102b0745 100644 --- a/test/js/bun/dns/resolve-dns.test.ts +++ b/test/js/bun/dns/resolve-dns.test.ts @@ -32,7 +32,7 @@ describe("dns.lookup", () => { const [first, second] = await dns.lookup("google.com", { backend }); console.log(first, second); }); - it.skip(backend + " local", async () => { + it(backend + " local", async () => { const [first, second] = await dns.lookup("localhost", { backend }); console.log(first, second); }); diff --git a/test/js/bun/plugin/plugins.test.ts b/test/js/bun/plugin/plugins.test.ts index 54ebb15e7..778eca7d0 100644 --- a/test/js/bun/plugin/plugins.test.ts +++ b/test/js/bun/plugin/plugins.test.ts @@ -209,7 +209,7 @@ export default Hello; }); describe("errors", () => { - it("valid loaders work", () => { + it.todo("valid loaders work", () => { const validLoaders = ["js", "jsx", "ts", "tsx"]; const inputs = ["export default 'hi';", "export default 'hi';", "export default 'hi';", "export default 'hi';"]; for (let i = 0; i < validLoaders.length; i++) { @@ -306,7 +306,7 @@ describe("errors", () => { } }); - it("async transpiler errors work", async () => { + it.skip("async transpiler errors work", async () => { expect(async () => { globalThis.asyncOnLoad = `const x: string = -NaNAn../!!;`; await import("async:fail"); diff --git a/test/js/bun/resolve/png/test-png-import.test.js b/test/js/bun/resolve/png/test-png-import.test.js index ca2d0b9ce..f4a809e7a 100644 --- a/test/js/bun/resolve/png/test-png-import.test.js +++ b/test/js/bun/resolve/png/test-png-import.test.js @@ -1,7 +1,7 @@ import { expect, test } from "bun:test"; import { resolve } from "path"; -import MyPNG from "./test-png.png"; +// import MyPNG from "./test-png.png"; -test("png import", () => { +test.todo("png import", () => { expect(MyPNG).toBe(resolve(__dirname, "./test-png.png")); }); diff --git a/test/js/bun/test/preload-test.test.js b/test/js/bun/test/preload-test.test.js index 0cc090fbd..edcc73888 100644 --- a/test/js/bun/test/preload-test.test.js +++ b/test/js/bun/test/preload-test.test.js @@ -44,7 +44,7 @@ test('says hello world', () => { const bunfig = `test.preload = ["./preload.js"]`; describe("preload for bun:test", () => { - test("works with bunfig", async () => { + test.todo("works with bunfig", async () => { const preloadDir = join(realpathSync(tmpdir()), "bun-test-preload-test1"); mkdirSync(preloadDir, { recursive: true }); const preloadPath = join(preloadDir, "preload.js"); @@ -73,7 +73,7 @@ describe("preload for bun:test", () => { } }); - test("works from CLI", async () => { + test.todo("works from CLI", async () => { const preloadDir = join(realpathSync(tmpdir()), "bun-test-preload-test2"); mkdirSync(preloadDir, { recursive: true }); const preloadPath = join(preloadDir, "preload.js"); diff --git a/test/js/bun/test/snapshot-tests/snapshots/more-snapshots/different-directory.test.ts b/test/js/bun/test/snapshot-tests/snapshots/more-snapshots/different-directory.test.ts index 6692d72d0..3717fb442 100644 --- a/test/js/bun/test/snapshot-tests/snapshots/more-snapshots/different-directory.test.ts +++ b/test/js/bun/test/snapshot-tests/snapshots/more-snapshots/different-directory.test.ts @@ -1,6 +1,6 @@ import { it, test, expect, describe } from "bun:test"; -test("snapshots in different directory", () => { +test.todo("snapshots in different directory", () => { expect("1\b2\n3\r4").toMatchSnapshot(); expect("\r\n").toMatchSnapshot(); expect("1\b2\n3\r r\r\\").toMatchSnapshot(); diff --git a/test/js/bun/test/snapshot-tests/snapshots/more.test.ts b/test/js/bun/test/snapshot-tests/snapshots/more.test.ts index 0922e4756..bf98cddf1 100644 --- a/test/js/bun/test/snapshot-tests/snapshots/more.test.ts +++ b/test/js/bun/test/snapshot-tests/snapshots/more.test.ts @@ -1,6 +1,7 @@ import { it, test, expect, describe } from "bun:test"; + describe("d0", () => { - test("snapshot serialize edgecases", () => { + test.todo("snapshot serialize edgecases", () => { expect(1).toMatchSnapshot(); expect("1\b2\n3\r4").toMatchSnapshot(); expect("\r\n").toMatchSnapshot(); @@ -46,7 +47,7 @@ describe("d0", () => { describe("d0", () => { describe("d1", () => { - test("t1", () => { + test.todo("t1", () => { expect("hello`snapshot\\").toEqual("hello`snapshot\\"); expect("hello`snapshot\\").toMatchSnapshot(); }); @@ -57,7 +58,7 @@ describe("d0", () => { test("t3", () => { expect("hello snapshot").toMatchSnapshot(); }); - test("t4", () => { + test.todo("t4", () => { expect("hello`snapshot\\").toMatchSnapshot(); }); }); diff --git a/test/js/node/child_process/child_process-node.test.js b/test/js/node/child_process/child_process-node.test.js index b845beb1e..1d354b702 100644 --- a/test/js/node/child_process/child_process-node.test.js +++ b/test/js/node/child_process/child_process-node.test.js @@ -165,61 +165,59 @@ describe("ChildProcess spawn bad stdio", () => { // Monkey patch spawn() to create a child process normally, but destroy the // stdout and stderr streams. This replicates the conditions where the streams // cannot be properly created. - function createChild(options, callback, done, target) { - var __originalSpawn = ChildProcess.prototype.spawn; - ChildProcess.prototype.spawn = function () { - const err = __originalSpawn.apply(this, arguments); - - this.stdout.destroy(); - this.stderr.destroy(); - - return err; - }; - - const { mustCall } = createCallCheckCtx(done); - let cmd = `${bunExe()} ${import.meta.dir}/spawned-child.js`; - if (target) cmd += " " + target; - const child = exec(cmd, options, mustCall(callback)); - ChildProcess.prototype.spawn = __originalSpawn; - return child; + function createChild(options, callback, target) { + return new Promise((resolve, reject) => { + var __originalSpawn = ChildProcess.prototype.spawn; + ChildProcess.prototype.spawn = function () { + const err = __originalSpawn.apply(this, arguments); + + this.stdout.destroy(); + this.stderr.destroy(); + + return err; + }; + + let cmd = `${bunExe()} ${import.meta.dir}/spawned-child.js`; + if (target) cmd += " " + target; + const child = exec(cmd, options, async (err, stdout, stderr) => { + try { + await callback(err, stdout, stderr); + resolve(); + } catch (e) { + reject(e); + } + }); + ChildProcess.prototype.spawn = __originalSpawn; + }); } - it.skip("should handle normal execution of child process", done => { - createChild( - {}, - (err, stdout, stderr) => { - strictEqual(err, null); - strictEqual(stdout, ""); - strictEqual(stderr, ""); - }, - done, - ); + it("should handle normal execution of child process", async () => { + await createChild({}, (err, stdout, stderr) => { + strictEqual(err, null); + strictEqual(stdout, ""); + strictEqual(stderr, ""); + }); }); - it.skip("should handle error event of child process", done => { + it.todo("should handle error event of child process", async () => { const error = new Error(`Command failed: bun ${import.meta.dir}/spawned-child.js ERROR`); - createChild( + await createChild( {}, (err, stdout, stderr) => { strictEqual(stdout, ""); strictEqual(stderr, ""); strictEqual(err?.message, error.message); }, - done, "ERROR", ); }); - it.skip("should handle killed process", done => { - createChild( - { timeout: 1 }, - (err, stdout, stderr) => { - strictEqual(err.killed, true); - strictEqual(stdout, ""); - strictEqual(stderr, ""); - }, - done, - ); + it("should handle killed process", async () => { + await createChild({ timeout: 1 }, (err, stdout, stderr) => { + strictEqual(err.killed, true); + strictEqual(stdout, ""); + strictEqual(stderr, ""); + }); }); }); diff --git a/test/js/node/child_process/child_process.test.ts b/test/js/node/child_process/child_process.test.ts index f4e08ac74..d6fe065ca 100644 --- a/test/js/node/child_process/child_process.test.ts +++ b/test/js/node/child_process/child_process.test.ts @@ -1,45 +1,8 @@ -import { describe, it as it_, expect as expect_ } from "bun:test"; -import { gcTick } from "harness"; +import { describe, it, expect } from "bun:test"; import { ChildProcess, spawn, execFile, exec, fork, spawnSync, execFileSync, execSync } from "node:child_process"; import { tmpdir } from "node:os"; import { promisify } from "node:util"; -const expect = ((actual: unknown) => { - gcTick(); - const ret = expect_(actual); - gcTick(); - return ret; -}) as typeof expect_; - -const it = ((label, fn) => { - const hasDone = fn.length === 1; - if (fn.constructor.name === "AsyncFunction" && hasDone) { - return it_(label, async done => { - gcTick(); - await fn(done); - gcTick(); - }); - } else if (hasDone) { - return it_(label, done => { - gcTick(); - fn(done); - gcTick(); - }); - } else if (fn.constructor.name === "AsyncFunction") { - return it_(label, async () => { - gcTick(); - await fn(() => {}); - gcTick(); - }); - } else { - return it_(label, () => { - gcTick(); - fn(() => {}); - gcTick(); - }); - } -}) as typeof it_; - const debug = process.env.DEBUG ? console.log : () => {}; const platformTmpDir = require("fs").realpathSync(tmpdir()); @@ -95,7 +58,7 @@ describe("spawn()", () => { expect(!!child2).toBe(false); }); - it("should allow stdout to be read via Node stream.Readable `data` events", async () => { + it.todo("should allow stdout to be read via Node stream.Readable `data` events", async () => { const child = spawn("bun", ["-v"]); const result: string = await new Promise(resolve => { child.stdout.on("error", e => { @@ -112,12 +75,12 @@ describe("spawn()", () => { expect(SEMVER_REGEX.test(result.trim())).toBe(true); }); - it("should allow stdout to be read via .read() API", async done => { + it.todo("should allow stdout to be read via .read() API", async () => { const child = spawn("bun", ["-v"]); - const result: string = await new Promise(resolve => { + const result: string = await new Promise((resolve, reject) => { let finalData = ""; child.stdout.on("error", e => { - done(e); + reject(e); }); child.stdout.on("readable", () => { let data; @@ -129,7 +92,6 @@ describe("spawn()", () => { }); }); expect(SEMVER_REGEX.test(result.trim())).toBe(true); - done(); }); it("should accept stdio option with 'ignore' for no stdio fds", async () => { @@ -241,7 +203,7 @@ describe("spawn()", () => { }); describe("execFile()", () => { - it("should execute a file", async () => { + it.todo("should execute a file", async () => { const result: Buffer = await new Promise((resolve, reject) => { execFile("bun", ["-v"], { encoding: "buffer" }, (error, stdout, stderr) => { if (error) { @@ -255,7 +217,7 @@ describe("execFile()", () => { }); describe("exec()", () => { - it("should execute a command in a shell", async () => { + it.todo("should execute a command in a shell", async () => { const result: Buffer = await new Promise((resolve, reject) => { exec("bun -v", { encoding: "buffer" }, (error, stdout, stderr) => { if (error) { @@ -267,7 +229,7 @@ describe("exec()", () => { expect(SEMVER_REGEX.test(result.toString().trim())).toBe(true); }); - it("should return an object w/ stdout and stderr when promisified", async () => { + it.todo("should return an object w/ stdout and stderr when promisified", async () => { const result = await promisify(exec)("bun -v"); expect(typeof result).toBe("object"); expect(typeof result.stdout).toBe("string"); @@ -299,7 +261,7 @@ describe("spawnSync()", () => { }); describe("execFileSync()", () => { - it("should execute a file synchronously", () => { + it.todo("should execute a file synchronously", () => { const result = execFileSync("bun", ["-v"], { encoding: "utf8" }); expect(SEMVER_REGEX.test(result.trim())).toBe(true); }); @@ -314,7 +276,7 @@ describe("execFileSync()", () => { }); describe("execSync()", () => { - it("should execute a command in the shell synchronously", () => { + it.todo("should execute a command in the shell synchronously", () => { const result = execSync("bun -v", { encoding: "utf8" }); expect(SEMVER_REGEX.test(result.trim())).toBe(true); }); diff --git a/test/js/node/process/process.test.js b/test/js/node/process/process.test.js index c9f92362c..f701be1b3 100644 --- a/test/js/node/process/process.test.js +++ b/test/js/node/process/process.test.js @@ -124,7 +124,7 @@ it("process.version starts with v", () => { expect(process.version.startsWith("v")).toBeTruthy(); }); -it("process.argv0", () => { +it.todo("process.argv0", () => { expect(basename(process.argv0)).toBe(basename(process.argv[0])); }); |