From c682ca3421bedecab311283f188e8aa377e862bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bazyli=20Brzo=CC=81ska?= Date: Mon, 16 Apr 2018 21:41:27 +0200 Subject: [PATCH] fix(treeProcessor): revert a small change from the #5585 refactoring fixes #5964 moves the `wrapChildren` into higher scope to restore undocumented execution order --- packages/jest-jasmine2/src/tree_processor.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/jest-jasmine2/src/tree_processor.js b/packages/jest-jasmine2/src/tree_processor.js index 0ebcc01a59da..9bea3c4db383 100644 --- a/packages/jest-jasmine2/src/tree_processor.js +++ b/packages/jest-jasmine2/src/tree_processor.js @@ -57,11 +57,16 @@ export default function treeProcessor(options: Options) { } function getNodeWithChildrenHandler(node: TreeNode, enabled: boolean) { + // NOTE: We create the array of queueableFns preemptively, + // in order to keep a legacy, undocumented ordering of beforeEach execution. + // Specifically, this applies to beforeEach that were added inside of tests. + // Facebook depends on this behavior internally (see #5964 for discussion) + const queueableFns = wrapChildren(node, enabled); return async function fn(done: (error?: any) => void = () => {}) { nodeStart(node); await queueRunnerFactory({ onException: error => node.onException(error), - queueableFns: wrapChildren(node, enabled), + queueableFns, userContext: node.sharedUserContext(), }); nodeComplete(node);