From 0581a7d363a18ef36f40761bcc6e92aae9f5e83d Mon Sep 17 00:00:00 2001 From: Edwin Takahashi Date: Thu, 2 Sep 2021 13:31:50 -0700 Subject: [PATCH] Revise behavior when hook fails. --- test/e2e/lib/jest/environment.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/test/e2e/lib/jest/environment.js b/test/e2e/lib/jest/environment.js index ac22d4704b8418..9732c873e0f637 100644 --- a/test/e2e/lib/jest/environment.js +++ b/test/e2e/lib/jest/environment.js @@ -19,9 +19,12 @@ class JestEnvironmentE2E extends JestEnvironmentNode { break; case 'hook_failure': - console.error( event.error ); + this.global.__CURRENT_TEST_FAILED__ = true; this.testFailed = true; - break; + // Re-throw the error. This triggers Jest to print + // the contents nicely with color code. + throw event.error; + case 'test_fn_failure': this.global.__CURRENT_TEST_FAILED__ = true; this.testFailed = true;