diff options
author | 2023-02-09 00:30:40 -0800 | |
---|---|---|
committer | 2023-02-09 00:30:40 -0800 | |
commit | 523b112945d20f7aa59ad3de327348cc77353a1f (patch) | |
tree | 9f5fd5253a797f6391d4dd947d723d77b707eb9b /test | |
parent | 8aa29040e6d79e80bc7e913bfb457b273dbec1a4 (diff) | |
download | bun-523b112945d20f7aa59ad3de327348cc77353a1f.tar.gz bun-523b112945d20f7aa59ad3de327348cc77353a1f.tar.zst bun-523b112945d20f7aa59ad3de327348cc77353a1f.zip |
[bun:test] Auto-import jest globals in test files
Diffstat (limited to 'test')
-rw-r--r-- | test/bun.js/jest-doesnt-auto-import.js | 12 | ||||
-rw-r--r-- | test/bun.js/test-auto-import-jest-globals.test.js | 24 |
2 files changed, 36 insertions, 0 deletions
diff --git a/test/bun.js/jest-doesnt-auto-import.js b/test/bun.js/jest-doesnt-auto-import.js new file mode 100644 index 000000000..4d4a02b37 --- /dev/null +++ b/test/bun.js/jest-doesnt-auto-import.js @@ -0,0 +1,12 @@ +export function getJestGlobals() { + return { + describe: typeof describe === "function" ? describe : undefined, + it: typeof it === "function" ? it : undefined, + test: typeof test === "function" ? test : undefined, + expect: typeof expect === "function" ? expect : undefined, + beforeAll: typeof beforeAll === "function" ? beforeAll : undefined, + beforeEach: typeof beforeEach === "function" ? beforeEach : undefined, + afterAll: typeof afterAll === "function" ? afterAll : undefined, + afterEach: typeof afterEach === "function" ? afterEach : undefined, + }; +} diff --git a/test/bun.js/test-auto-import-jest-globals.test.js b/test/bun.js/test-auto-import-jest-globals.test.js new file mode 100644 index 000000000..5baeae43e --- /dev/null +++ b/test/bun.js/test-auto-import-jest-globals.test.js @@ -0,0 +1,24 @@ +test("Jest auto imports", () => { + expect(true).toBe(true); + expect(typeof describe).toBe("function"); + expect(typeof it).toBe("function"); + expect(typeof test).toBe("function"); + expect(typeof expect).toBe("function"); + expect(typeof beforeAll).toBe("function"); + expect(typeof beforeEach).toBe("function"); + expect(typeof afterAll).toBe("function"); + expect(typeof afterEach).toBe("function"); +}); + +test("Jest's globals aren't available in every file", async () => { + const jestGlobals = await import("./jest-doesnt-auto-import.js"); + + expect(typeof jestGlobals.describe).toBe("undefined"); + expect(typeof jestGlobals.it).toBe("undefined"); + expect(typeof jestGlobals.test).toBe("undefined"); + expect(typeof jestGlobals.expect).toBe("undefined"); + expect(typeof jestGlobals.beforeAll).toBe("undefined"); + expect(typeof jestGlobals.beforeEach).toBe("undefined"); + expect(typeof jestGlobals.afterAll).toBe("undefined"); + expect(typeof jestGlobals.afterEach).toBe("undefined"); +}); |