From 8e9950e5e7ae468f82364a4e6a3ff0234b3d3ea1 Mon Sep 17 00:00:00 2001 From: Mikhail Date: Sun, 21 Jul 2024 11:01:57 +0300 Subject: [PATCH] fix: optimize collection beforeEach hooks (#15198) --- packages/jest-circus/src/utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/jest-circus/src/utils.ts b/packages/jest-circus/src/utils.ts index 9776072964b0..c259aad3da03 100644 --- a/packages/jest-circus/src/utils.ts +++ b/packages/jest-circus/src/utils.ts @@ -161,7 +161,7 @@ export const getEachHooksForTest = (test: Circus.TestEntry): TestHooks => { } // 'beforeEach' hooks are executed from top to bottom, the opposite of the // way we traversed it. - result.beforeEach = [...beforeEachForCurrentBlock, ...result.beforeEach]; + result.beforeEach.unshift(...beforeEachForCurrentBlock); } while ((block = block.parent)); return result; };