aboutsummaryrefslogtreecommitdiff
path: root/test/bun.js/bun-test/jest-hooks.test.ts
diff options
context:
space:
mode:
authorGravatar Ethan Burrell <30448729+ethanburrell@users.noreply.github.com> 2022-12-21 14:36:44 -0800
committerGravatar GitHub <noreply@github.com> 2022-12-21 14:36:44 -0800
commit4f7d06500c073c3ac35c2fc6bdbd0ce90e03f36f (patch)
tree40596f95b4efef8fd7c8511f0a597b0661ce1018 /test/bun.js/bun-test/jest-hooks.test.ts
parentf6bbfa7e404ec21f5aa3f60fabbd4a290a3b379d (diff)
downloadbun-4f7d06500c073c3ac35c2fc6bdbd0ce90e03f36f.tar.gz
bun-4f7d06500c073c3ac35c2fc6bdbd0ce90e03f36f.tar.zst
bun-4f7d06500c073c3ac35c2fc6bdbd0ce90e03f36f.zip
fix jest hooks in bun-test (#1639)
* fix(jest) fix broken jest hooks * add tests
Diffstat (limited to '')
-rw-r--r--test/bun.js/bun-test/jest-hooks.test.ts76
1 files changed, 76 insertions, 0 deletions
diff --git a/test/bun.js/bun-test/jest-hooks.test.ts b/test/bun.js/bun-test/jest-hooks.test.ts
new file mode 100644
index 000000000..a75025041
--- /dev/null
+++ b/test/bun.js/bun-test/jest-hooks.test.ts
@@ -0,0 +1,76 @@
+import {
+ afterAll,
+ afterEach,
+ beforeAll,
+ beforeEach,
+ describe,
+ expect,
+ it,
+} from "bun:test";
+
+describe("test jest hooks in bun-test", () => {
+ describe("test beforeAll hook", () => {
+ let animal = "tiger";
+
+ beforeAll(() => {
+ animal = "lion";
+ });
+
+ it("string should be set by hook", () => {
+ expect(animal).toEqual("lion");
+ });
+ });
+
+ describe("test beforeEach hook", () => {
+ let animal = "tiger";
+
+ beforeEach(() => {
+ animal = "lion";
+ });
+
+ it("string should be set by hook", () => {
+ expect(animal).toEqual("lion");
+ animal = "dog";
+ });
+
+ it("string should be re-set by hook", () => {
+ expect(animal).toEqual("lion");
+ });
+ });
+
+ describe("test afterEach hook", () => {
+ let animal = "tiger";
+
+ afterEach(() => {
+ animal = "lion";
+ });
+
+ it("string should not be set by hook", () => {
+ expect(animal).toEqual("tiger");
+ animal = "dog";
+ });
+
+ it("string should be set by hook", () => {
+ expect(animal).toEqual("lion");
+ });
+ });
+
+ describe("test afterAll hook", () => {
+ let animal = "tiger";
+
+ describe("test afterAll hook", () => {
+ afterAll(() => {
+ animal = "lion";
+ });
+
+ it("string should not be set by hook", () => {
+ expect(animal).toEqual("tiger");
+ animal = "dog";
+ });
+ });
+
+ it("string should be set by hook", () => {
+ expect(animal).toEqual("lion");
+ });
+ });
+});