diff options
Diffstat (limited to '')
| -rw-r--r-- | test/cli/test/bun-test.test.ts | 382 | ||||
| -rw-r--r-- | test/harness.ts | 1 | ||||
| -rw-r--r-- | test/js/bun/test/__snapshots__/test-test.test.ts.snap | 44 | ||||
| -rw-r--r-- | test/js/bun/test/expect.test.ts | 179 | ||||
| -rw-r--r-- | test/js/bun/test/skip-test-fixture.js | 67 | ||||
| -rw-r--r-- | test/js/bun/test/test-test.test.ts | 34 | ||||
| -rw-r--r-- | test/js/bun/test/timeout-test-fixture.js | 11 | 
7 files changed, 695 insertions, 23 deletions
| diff --git a/test/cli/test/bun-test.test.ts b/test/cli/test/bun-test.test.ts index e1a5fdd60..788ea2454 100644 --- a/test/cli/test/bun-test.test.ts +++ b/test/cli/test/bun-test.test.ts @@ -1,11 +1,184 @@ -import { join } from "node:path"; +import { join, resolve, dirname } from "node:path";  import { tmpdir } from "node:os"; -import { mkdtempSync, writeFileSync, rmSync } from "node:fs"; +import { mkdtempSync, writeFileSync, rmSync, mkdirSync } from "node:fs";  import { spawnSync } from "bun";  import { describe, test, expect } from "bun:test";  import { bunExe, bunEnv } from "harness";  describe("bun test", () => { +  test("can provide no arguments", () => { +    const stderr = runTest({ +      args: [], +      input: [ +        ` +          import { test, expect } from "bun:test"; +          test("test #1", () => { +            expect(true).toBe(true); +          }); +        `, +        ` +          import { test, expect } from "bun:test"; +          test.todo("test #2"); +        `, +        ` +          import { test, expect } from "bun:test"; +          test("test #3", () => { +            expect(true).toBe(false); +          }); +        `, +      ], +    }); +    expect(stderr).toContain("test #1"); +    expect(stderr).toContain("test #2"); +    expect(stderr).toContain("test #3"); +  }); +  test("can provide a relative file", () => { +    const path = join("path", "to", "relative.test.ts"); +    const cwd = createTest( +      ` +      import { test, expect } from "bun:test"; +      test("${path}", () => { +        expect(true).toBe(true); +      }); +    `, +      path, +    ); +    const stderr = runTest({ +      cwd, +      args: [path], +    }); +    expect(stderr).toContain(path); +  }); +  // This fails on macOS because /private/var symlinks to /var +  test.todo("can provide an absolute file", () => { +    const path = join("path", "to", "absolute.test.ts"); +    const cwd = createTest( +      ` +      import { test, expect } from "bun:test"; +      test("${path}", () => { +        expect(true).toBe(true); +      }); +    `, +      path, +    ); +    const absolutePath = resolve(cwd, path); +    const stderr = runTest({ +      cwd, +      args: [absolutePath], +    }); +    expect(stderr).toContain(path); +  }); +  test("can provide a relative directory", () => { +    const path = join("path", "to", "relative.test.ts"); +    const dir = dirname(path); +    const cwd = createTest( +      ` +      import { test, expect } from "bun:test"; +      test("${dir}", () => { +        expect(true).toBe(true); +      }); +    `, +      path, +    ); +    const stderr = runTest({ +      cwd, +      args: [dir], +    }); +    expect(stderr).toContain(dir); +  }); +  test.todo("can provide an absolute directory", () => { +    const path = join("path", "to", "absolute.test.ts"); +    const cwd = createTest( +      ` +      import { test, expect } from "bun:test"; +      test("${path}", () => { +        expect(true).toBe(true); +      }); +    `, +      path, +    ); +    const absoluteDir = resolve(cwd, dirname(path)); +    const stderr = runTest({ +      cwd, +      args: [absoluteDir], +    }); +    expect(stderr).toContain(path); +  }); +  test.todo("can provide a mix of files and directories"); +  describe("--rerun-each", () => { +    test.todo("can rerun with a default value"); +    test.todo("can rerun with a provided value"); +  }); +  describe("--todo", () => { +    test("should not run todo by default", () => { +      const stderr = runTest({ +        input: ` +          import { test, expect } from "bun:test"; +          test.todo("todo", async () => { +            console.error("should not run"); +          }); +        `, +      }); +      expect(stderr).not.toContain("should not run"); +    }); +    test("should run todo when enabled", () => { +      const stderr = runTest({ +        args: ["--todo"], +        input: ` +          import { test, expect } from "bun:test"; +          test.todo("todo", async () => { +            console.error("should run"); +          }); +        `, +      }); +      expect(stderr).toContain("should run"); +    }); +  }); +  describe("--only", () => { +    test("should skip non-only tests when enabled", () => { +      const stderr = runTest({ +        args: ["--only"], +        input: ` +          import { test, describe } from "bun:test"; +          test("test #1", () => { +            console.error("unreachable"); +          }); +          test.only("test #2", () => { +            console.error("reachable"); +          }); +          test("test #3", () => { +            console.error("unreachable"); +          }); +          test.skip("test #4", () => { +            console.error("unreachable"); +          }); +          test.todo("test #5"); +          describe("describe #1", () => { +            test("test #6", () => { +              console.error("unreachable"); +            }); +            test.only("test #7", () => { +              console.error("reachable"); +            }); +          }); +          describe.only("describe #2", () => { +            test("test #8", () => { +              console.error("reachable"); +            }); +            test.skip("test #9", () => { +              console.error("unreachable"); +            }); +            test.only("test #10", () => { +              console.error("reachable"); +            }); +          }); +        `, +      }); +      expect(stderr).toContain("reachable"); +      expect(stderr).not.toContain("unreachable"); +      expect(stderr.match(/reachable/g)).toHaveLength(4); +    }); +  });    describe("--timeout", () => {      test("must provide a number timeout", () => {        const stderr = runTest({ @@ -22,7 +195,7 @@ describe("bun test", () => {      test("timeout can be set to 1ms", () => {        const stderr = runTest({          args: ["--timeout", "1"], -        code: ` +        input: `            import { test, expect } from "bun:test";            import { sleep } from "bun";            test("timeout", async () => { @@ -34,7 +207,7 @@ describe("bun test", () => {      });      test("timeout should default to 5000ms", () => {        const stderr = runTest({ -        code: ` +        input: `            import { test, expect } from "bun:test";            import { sleep } from "bun";            test("timeout", async () => { @@ -45,22 +218,207 @@ describe("bun test", () => {        expect(stderr).toContain("timed out after 5000ms");      });    }); +  describe("support for Github Actions", () => { +    test("should not group logs by default", () => { +      const stderr = runTest({ +        env: { +          GITHUB_ACTIONS: undefined, +        }, +      }); +      expect(stderr).not.toContain("::group::"); +      expect(stderr).not.toContain("::endgroup::"); +    }); +    test("should not group logs when disabled", () => { +      const stderr = runTest({ +        env: { +          GITHUB_ACTIONS: "false", +        }, +      }); +      expect(stderr).not.toContain("::group::"); +      expect(stderr).not.toContain("::endgroup::"); +    }); +    test("should group logs when enabled", () => { +      const stderr = runTest({ +        env: { +          GITHUB_ACTIONS: "true", +        }, +      }); +      expect(stderr).toContain("::group::"); +      expect(stderr.match(/::group::/g)).toHaveLength(1); +      expect(stderr).toContain("::endgroup::"); +      expect(stderr.match(/::endgroup::/g)).toHaveLength(1); +    }); +    test("should group logs with multiple files", () => { +      const stderr = runTest({ +        input: [ +          ` +            import { test, expect } from "bun:test"; +            test("pass", () => { +              expect(true).toBe(true); +            }); +          `, +          ` +            import { test, expect } from "bun:test"; +            test.skip("skip", () => {}); +          `, +          ` +            import { test, expect } from "bun:test"; +            test("fail", () => { +              expect(true).toBe(false); +            }); +          `, +        ], +        env: { +          GITHUB_ACTIONS: "true", +        }, +      }); +      expect(stderr).toContain("::group::"); +      expect(stderr.match(/::group::/g)).toHaveLength(3); +      expect(stderr).toContain("::endgroup::"); +      expect(stderr.match(/::endgroup::/g)).toHaveLength(3); +    }); +    test("should group logs with --rerun-each", () => { +      const stderr = runTest({ +        args: ["--rerun-each", "3"], +        input: [ +          ` +            import { test, expect } from "bun:test"; +            test("pass", () => { +              expect(true).toBe(true); +            }); +          `, +          ` +            import { test, expect } from "bun:test"; +            test("fail", () => { +              expect(true).toBe(false); +            }); +          `, +        ], +        env: { +          GITHUB_ACTIONS: "true", +        }, +      }); +      expect(stderr).toContain("::group::"); +      expect(stderr.match(/::group::/g)).toHaveLength(6); +      expect(stderr).toContain("::endgroup::"); +      expect(stderr.match(/::endgroup::/g)).toHaveLength(6); +    }); +    test("should not annotate errors by default", () => { +      const stderr = runTest({ +        input: ` +          import { test, expect } from "bun:test"; +          test("fail", () => { +            expect(true).toBe(false); +          }); +        `, +        env: { +          GITHUB_ACTIONS: undefined, +        }, +      }); +      expect(stderr).not.toContain("::error"); +    }); +    test("should not annotate errors when using inspect()", () => { +      const stderr = runTest({ +        input: ` +          import { test } from "bun:test"; +          import { inspect } from "bun"; +          test("inspect", () => { +            inspect(new TypeError()); +            console.error(inspect(new TypeError())); +          }); +        `, +        env: { +          GITHUB_ACTIONS: undefined, +        }, +      }); +      expect(stderr).not.toContain("::error"); +    }); +    test("should annotate errors when enabled", () => { +      const stderr = runTest({ +        input: ` +          import { test, expect } from "bun:test"; +          test("fail", () => { +            throw new Error(); +          }); +        `, +        env: { +          GITHUB_ACTIONS: "true", +        }, +      }); +      expect(stderr).toMatch(/::error file=.*,line=\d+,col=\d+,title=error::/); +    }); +    test("should annotate errors with escaped strings", () => { +      const stderr = runTest({ +        input: ` +          import { test, expect } from "bun:test"; +          test("fail", () => { +            expect(true).toBe(false); +          }); +        `, +        env: { +          FORCE_COLOR: "1", +          GITHUB_ACTIONS: "true", +        }, +      }); +      expect(stderr).toMatch(/::error file=.*,line=\d+,col=\d+,title=.*::/); +      expect(stderr).toMatch(/error: expect\(received\)\.toBe\(expected\)/); // stripped ansi +      expect(stderr).toMatch(/Expected: false%0AReceived: true%0A/); // escaped newlines +    }); +    test("should annotate errors without a stack", () => { +      const stderr = runTest({ +        input: ` +          import { test, expect } from "bun:test"; +          test("fail", () => { +            throw "Oops!"; +          }); +        `, +        env: { +          FORCE_COLOR: "1", +          GITHUB_ACTIONS: "true", +        }, +      }); +      expect(stderr).toMatch(/::error title=error: Oops!::/); +    }); +  });  }); -function runTest({ code = "", args = [] }: { code?: string; args?: string[] }): string { -  const dir = mkdtempSync(join(tmpdir(), "bun-test-")); -  const path = join(dir, `bun-test-${Date.now()}.test.ts`); -  writeFileSync(path, code); +function createTest(input?: string | string[], filename?: string): string { +  const cwd = mkdtempSync(join(tmpdir(), "bun-test-")); +  const inputs = Array.isArray(input) ? input : [input ?? ""]; +  for (const input of inputs) { +    const path = join(cwd, filename ?? `bun-test-${Math.random()}.test.ts`); +    try { +      writeFileSync(path, input); +    } catch { +      mkdirSync(dirname(path), { recursive: true }); +      writeFileSync(path, input); +    } +  } +  return cwd; +} + +function runTest({ +  input = "", +  cwd, +  args = [], +  env = {}, +}: { +  input?: string | string[]; +  cwd?: string; +  args?: string[]; +  env?: Record<string, string | undefined>; +} = {}): string { +  cwd ??= createTest(input);    try {      const { stderr } = spawnSync({ -      cwd: dir, -      cmd: [bunExe(), "test", path, ...args], -      env: bunEnv, +      cwd, +      cmd: [bunExe(), "test", ...args], +      env: { ...bunEnv, ...env },        stderr: "pipe",        stdout: "ignore",      });      return stderr.toString();    } finally { -    rmSync(path); +    rmSync(cwd, { recursive: true });    }  } diff --git a/test/harness.ts b/test/harness.ts index d29e4367c..bfd159b18 100644 --- a/test/harness.ts +++ b/test/harness.ts @@ -6,6 +6,7 @@ import os from "os";  export const bunEnv: any = {    ...process.env, +  GITHUB_ACTIONS: "false",    BUN_DEBUG_QUIET_LOGS: "1",    NO_COLOR: "1",    FORCE_COLOR: undefined, diff --git a/test/js/bun/test/__snapshots__/test-test.test.ts.snap b/test/js/bun/test/__snapshots__/test-test.test.ts.snap index 31c5d310b..7fea0e8d3 100644 --- a/test/js/bun/test/__snapshots__/test-test.test.ts.snap +++ b/test/js/bun/test/__snapshots__/test-test.test.ts.snap @@ -1,3 +1,45 @@  // Bun Snapshot v1, https://goo.gl/fbAQLP -exports[`expect().toEqual() on objects with property indices doesn't print undefined 1`] = `"expect(received).toEqual(expected)\n\n  {\n+   \"0\": 0,\n+   \"1\": 1,\n+   \"10\": 10,\n+   \"11\": 11,\n+   \"12\": 12,\n+   \"13\": 13,\n+   \"14\": 14,\n+   \"15\": 15,\n+   \"2\": 2,\n+   \"3\": 3,\n+   \"4\": 4,\n+   \"5\": 5,\n+   \"6\": 6,\n+   \"7\": 7,\n+   \"8\": 8,\n+   \"9\": 9\n-   \"0\": 123,\n-   \"1\": 123,\n-   \"10\": 123,\n-   \"11\": 123,\n-   \"12\": 123,\n-   \"13\": 123,\n-   \"14\": 123,\n-   \"15\": 123,\n-   \"2\": 123,\n-   \"3\": 123,\n-   \"4\": 123,\n-   \"5\": 123,\n-   \"6\": 123,\n-   \"7\": 123,\n-   \"8\": 123,\n-   \"9\": 123\n  }\n\n- Expected  - 16\n+ Received  + 16\n\n      "`; +exports[`expect().toEqual() on objects with property indices doesn't print undefined 1`] = ` +"expect(received).toEqual(expected) + +  { ++   "0": 0, ++   "1": 1, ++   "10": 10, ++   "11": 11, ++   "12": 12, ++   "13": 13, ++   "14": 14, ++   "15": 15, ++   "2": 2, ++   "3": 3, ++   "4": 4, ++   "5": 5, ++   "6": 6, ++   "7": 7, ++   "8": 8, ++   "9": 9 +-   "0": 123, +-   "1": 123, +-   "10": 123, +-   "11": 123, +-   "12": 123, +-   "13": 123, +-   "14": 123, +-   "15": 123, +-   "2": 123, +-   "3": 123, +-   "4": 123, +-   "5": 123, +-   "6": 123, +-   "7": 123, +-   "8": 123, +-   "9": 123 +  } + +- Expected  - 16 ++ Received  + 16 + +      " +`; diff --git a/test/js/bun/test/expect.test.ts b/test/js/bun/test/expect.test.ts index 96896013b..2afb9726c 100644 --- a/test/js/bun/test/expect.test.ts +++ b/test/js/bun/test/expect.test.ts @@ -192,6 +192,185 @@ describe("expect()", () => {        });      }    }); + +  test("toBeNil()", () => { +    expect(null).toBeNil(); +    expect(undefined).toBeNil(); +    expect(false).not.toBeNil(); +    expect(0).not.toBeNil(); +    expect("").not.toBeNil(); +    expect([]).not.toBeNil(); +    expect(true).not.toBeNil(); +    expect({}).not.toBeNil(); +  }); + +  test("toBeBoolean()", () => { +    expect(true).toBeBoolean(); +    expect(false).toBeBoolean(); +    expect(0).not.toBeBoolean(); +    expect(1).not.toBeBoolean(); +    expect("").not.toBeBoolean(); +    expect({}).not.toBeBoolean(); +  }); + +  test("toBeTrue()", () => { +    expect(true).toBeTrue(); +    expect(false).not.toBeTrue(); +    expect(0).not.toBeTrue(); +    expect(1).not.toBeTrue(); +    expect("").not.toBeTrue(); +    expect({}).not.toBeTrue(); +  }); + +  test("toBeFalse()", () => { +    expect(false).toBeFalse(); +    expect(true).not.toBeFalse(); +    expect(0).not.toBeFalse(); +    expect(1).not.toBeFalse(); +    expect("").not.toBeFalse(); +    expect({}).not.toBeFalse(); +  }); + +  test("toBeNumber()", () => { +    expect(0).toBeNumber(); +    expect(1).toBeNumber(); +    expect(1.23).toBeNumber(); +    expect(Infinity).toBeNumber(); +    expect(-Infinity).toBeNumber(); +    expect(NaN).toBeNumber(); +    expect("").not.toBeNumber(); +    expect({}).not.toBeNumber(); +  }); + +  test("toBeInteger()", () => { +    expect(0).toBeInteger(); +    expect(1).toBeInteger(); +    expect(1.23).not.toBeInteger(); +    expect(Infinity).not.toBeInteger(); +    expect(-Infinity).not.toBeInteger(); +    expect(NaN).not.toBeInteger(); +    expect("").not.toBeInteger(); +    expect({}).not.toBeInteger(); +  }); + +  test("toBeFinite()", () => { +    expect(0).toBeFinite(); +    expect(1).toBeFinite(); +    expect(1.23).toBeFinite(); +    expect(Infinity).not.toBeFinite(); +    expect(-Infinity).not.toBeFinite(); +    expect(NaN).not.toBeFinite(); +    expect("").not.toBeFinite(); +    expect({}).not.toBeFinite(); +  }); + +  test("toBePositive()", () => { +    expect(1).toBePositive(); +    expect(1.23).toBePositive(); +    expect(Infinity).not.toBePositive(); +    expect(0).not.toBePositive(); +    expect(-Infinity).not.toBePositive(); +    expect(NaN).not.toBePositive(); +    expect("").not.toBePositive(); +    expect({}).not.toBePositive(); +  }); + +  test("toBeNegative()", () => { +    expect(-1).toBeNegative(); +    expect(-1.23).toBeNegative(); +    expect(-Infinity).not.toBeNegative(); +    expect(0).not.toBeNegative(); +    expect(Infinity).not.toBeNegative(); +    expect(NaN).not.toBeNegative(); +    expect("").not.toBeNegative(); +    expect({}).not.toBeNegative(); +  }); + +  test("toBeWithin()", () => { +    expect(0).toBeWithin(0, 1); +    expect(3.14).toBeWithin(3, 3.141); +    expect(-25).toBeWithin(-100, 0); +    expect(0).not.toBeWithin(1, 2); +    expect(3.14).not.toBeWithin(3.1, 3.14); +    expect(99).not.toBeWithin(99, 99); +    expect(100).not.toBeWithin(99, 100); +    expect(NaN).not.toBeWithin(0, 1); +    expect("").not.toBeWithin(0, 1); +    expect({}).not.toBeWithin(0, 1); +    expect(Infinity).not.toBeWithin(-Infinity, Infinity); +  }); + +  test("toBeSymbol()", () => { +    expect(Symbol()).toBeSymbol(); +    expect(Symbol("")).toBeSymbol(); +    expect(Symbol.iterator).toBeSymbol(); +    expect("").not.toBeSymbol(); +    expect({}).not.toBeSymbol(); +  }); + +  test("toBeFunction()", () => { +    expect(() => {}).toBeFunction(); +    expect(function () {}).toBeFunction(); +    expect(async function () {}).toBeFunction(); +    expect(async () => {}).toBeFunction(); +    expect(function* () {}).toBeFunction(); +    expect(async function* () {}).toBeFunction(); +    expect("").not.toBeFunction(); +    expect({}).not.toBeFunction(); +    expect(null).not.toBeFunction(); +  }); + +  test("toBeDate()", () => { +    expect(new Date()).toBeDate(); +    expect(new Date(0)).toBeDate(); +    expect(new Date("2021-01-01")).toBeDate(); +    expect("2021-01-01").not.toBeDate(); +    expect({}).not.toBeDate(); +    expect(null).not.toBeDate(); +  }); + +  test.todo("toBeValidDate()", () => { +    expect(new Date()).toBeValidDate(); +    expect(new Date(-1)).not.toBeValidDate(); +    expect("2021-01-01").not.toBeValidDate(); +    expect({}).not.toBeValidDate(); +    expect(null).not.toBeValidDate(); +  }); + +  test("toBeString()", () => { +    expect("").toBeString(); +    expect("123").toBeString(); +    expect(new String()).toBeString(); +    expect(new String("123")).toBeString(); +    expect(123).not.toBeString(); +    expect({}).not.toBeString(); +  }); + +  test("toInclude()", () => { +    expect("123").toInclude("1"); +    expect("abc").toInclude("abc"); +    expect(" 123 ").toInclude(" "); +    expect("").toInclude(""); +    expect("bob").not.toInclude("alice"); +  }); + +  test("toStartWith()", () => { +    expect("123").toStartWith("1"); +    expect("abc").toStartWith("abc"); +    expect(" 123 ").toStartWith(" "); +    expect(" ").toStartWith(""); +    expect("").toStartWith(""); +    expect("bob").not.toStartWith("alice"); +  }); + +  test("toEndWith()", () => { +    expect("123").toEndWith("3"); +    expect("abc").toEndWith("abc"); +    expect(" 123 ").toEndWith(" "); +    expect(" ").toEndWith(""); +    expect("").toEndWith(""); +    expect("bob").not.toEndWith("alice"); +  });  });  function label(value: unknown): string { diff --git a/test/js/bun/test/skip-test-fixture.js b/test/js/bun/test/skip-test-fixture.js new file mode 100644 index 000000000..acb5f0748 --- /dev/null +++ b/test/js/bun/test/skip-test-fixture.js @@ -0,0 +1,67 @@ +import { test, describe } from "bun:test"; + +test.skip("test #1", () => { +  console.log("unreachable"); +}); + +test.skipIf(true)("test #2", () => { +  console.log("unreachable"); +}); + +test.skipIf(1)("test #3", () => { +  console.log("unreachable"); +}); + +test.skipIf(false)("test #4", () => { +  console.log("reachable"); +}); + +test.skipIf(null)("test #5", () => { +  console.log("reachable"); +}); + +describe.skip("describe #1", () => { +  test("test #6", () => { +    console.log("unreachable"); +  }); +}); + +describe.skipIf(true)("describe #2", () => { +  test("test #7", () => { +    console.log("unreachable"); +  }); +}); + +describe.skipIf(1)("describe #3", () => { +  test("test #8", () => { +    console.log("unreachable"); +  }); +}); + +describe.skipIf(false)("describe #4", () => { +  test("test #9", () => { +    console.log("reachable"); +  }); +}); + +describe.skipIf(null)("describe #5", () => { +  test("test #10", () => { +    console.log("reachable"); +  }); +}); + +test.if(false)("test #11", () => { +  console.log("unreachable"); +}); + +test.if(null)("test #12", () => { +  console.log("unreachable"); +}); + +test.if(true)("test #13", () => { +  console.log("reachable"); +}); + +test.if(1)("test #14", () => { +  console.log("reachable"); +}); diff --git a/test/js/bun/test/test-test.test.ts b/test/js/bun/test/test-test.test.ts index 4d31c9cb4..ed356aa50 100644 --- a/test/js/bun/test/test-test.test.ts +++ b/test/js/bun/test/test-test.test.ts @@ -1725,6 +1725,11 @@ test("toHaveProperty() - all", () => {    expect({ a: new String("a") }).not.toHaveProperty("a", "a");  }); +test("toHaveProperty() - null or undefined", () => { +  expect(null).not.toHaveProperty("length"); +  expect(undefined).not.toHaveProperty("length"); +}); +  test("toBe()", () => {    const a = 1;    const b = 1; @@ -2530,14 +2535,7 @@ describe("throw in describe scope doesn't enqueue tests after thrown", () => {      throw new Error("This test failed");    }); -  class TestPass extends Error { -    constructor(message) { -      super(message); -      this.name = "TestPass"; -    } -  } - -  throw new TestPass("This test passed. Ignore the error message"); +  throw "This test passed. Ignore the error message";    it("test enqueued after a describe scope throws is never run", () => {      throw new Error("This test failed"); @@ -2812,7 +2810,7 @@ it("test.todo", () => {    const path = join(tmp, "todo-test.test.js");    copyFileSync(join(import.meta.dir, "todo-test-fixture.js"), path);    const { stdout, stderr, exitCode } = spawnSync({ -    cmd: [bunExe(), "test", path], +    cmd: [bunExe(), "test", path, "--todo"],      stdout: "pipe",      stderr: "pipe",      env: bunEnv, @@ -2833,7 +2831,7 @@ it("test.todo doesnt cause exit code 1", () => {    const path = join(tmp, "todo-test.test.js");    copyFileSync(join(import.meta.dir, "todo-test-fixture-2.js"), path);    const { stdout, stderr, exitCode } = spawnSync({ -    cmd: [bunExe(), "test", path], +    cmd: [bunExe(), "test", path, "--todo"],      stdout: "pipe",      stderr: "pipe",      env: bunEnv, @@ -2919,3 +2917,19 @@ afterAll: #2  `.trim(),    );  }); + +it("skip() and skipIf()", () => { +  const path = join(tmp, "skip-test-fixture.test.js"); +  copyFileSync(join(import.meta.dir, "skip-test-fixture.js"), path); +  const { stdout } = spawnSync({ +    cmd: [bunExe(), "test", path], +    stdout: "pipe", +    stderr: "pipe", +    env: bunEnv, +    cwd: realpathSync(dirname(path)), +  }); +  const result = stdout!.toString(); +  expect(result).not.toContain("unreachable"); +  expect(result).toMatch(/reachable/); +  expect(result.match(/reachable/g)).toHaveLength(6); +}); diff --git a/test/js/bun/test/timeout-test-fixture.js b/test/js/bun/test/timeout-test-fixture.js index 82e887fb8..36a4ee2c6 100644 --- a/test/js/bun/test/timeout-test-fixture.js +++ b/test/js/bun/test/timeout-test-fixture.js @@ -7,6 +7,17 @@ test("test timeouts when expected", async () => {    console.error("unreachable code");  }, 10); +test( +  "test timeouts when expected 2", +  async () => { +    for (let i = 0; i < 100; i++) { +      await Bun.sleep(1); +    } +    console.error("unreachable code"); +  }, +  { timeout: 10 }, +); +  test("process doesn't hang on test with ref'd value", async () => {    Bun.serve({      port: 0, | 
