From 0c8038e0a97a265de4fe47b7dd5a86a533804bda Mon Sep 17 00:00:00 2001 From: Tim Seckinger Date: Thu, 7 Mar 2019 00:41:51 +0100 Subject: [PATCH] fix jasmine2 after rebase --- packages/jest-jasmine2/src/jasmine/Env.ts | 30 ++++++++++++++++++----- 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/packages/jest-jasmine2/src/jasmine/Env.ts b/packages/jest-jasmine2/src/jasmine/Env.ts index 522ae69c6503..14d3ea9587ee 100644 --- a/packages/jest-jasmine2/src/jasmine/Env.ts +++ b/packages/jest-jasmine2/src/jasmine/Env.ts @@ -31,6 +31,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. /* eslint-disable sort-keys */ import {AssertionError} from 'assert'; +import chalk from 'chalk'; +import {formatExecError} from 'jest-message-util'; import {ErrorWithStack, isPromise} from 'jest-util'; import queueRunner, { Options as QueueRunnerOptions, @@ -424,14 +426,30 @@ export default function(j$: Jasmine) { // TODO throw in Jest 25: declarationError = new Error if (isPromise(describeReturnValue)) { - console.warn( - 'Returning a Promise from "describe" is not supported. Tests must be defined synchronously.\n' + - 'Returning a value from "describe" will fail the test in a future version of Jest.', + console.log( + formatExecError( + new Error( + chalk.yellow( + 'Returning a Promise from "describe" is not supported. Tests must be defined synchronously.\n' + + 'Returning a value from "describe" will fail the test in a future version of Jest.', + ), + ), + {rootDir: '', testMatch: []}, + {noStackTrace: false}, + ), ); } else if (describeReturnValue !== undefined) { - console.warn( - 'A "describe" callback must not return a value.\n' + - 'Returning a value from "describe" will fail the test in a future version of Jest.', + console.log( + formatExecError( + new Error( + chalk.yellow( + 'A "describe" callback must not return a value.\n' + + 'Returning a value from "describe" will fail the test in a future version of Jest.', + ), + ), + {rootDir: '', testMatch: []}, + {noStackTrace: false}, + ), ); }