diff --git a/e2e/__tests__/__snapshots__/declarationErrors.test.ts.snap b/e2e/__tests__/__snapshots__/declarationErrors.test.ts.snap index 2cd6c1550a68..ae697a3dfe6c 100644 --- a/e2e/__tests__/__snapshots__/declarationErrors.test.ts.snap +++ b/e2e/__tests__/__snapshots__/declarationErrors.test.ts.snap @@ -1,7 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`warns if describe returns a Promise 1`] = ` -" console.warn +" console.log ● Test suite failed to run Returning a Promise from \\"describe\\" is not supported. Tests must be defined synchronously. @@ -21,7 +21,7 @@ exports[`warns if describe returns a Promise 1`] = ` `; exports[`warns if describe returns something 1`] = ` -" console.warn +" console.log ● Test suite failed to run A \\"describe\\" callback must not return a value. diff --git a/e2e/__tests__/declarationErrors.test.ts b/e2e/__tests__/declarationErrors.test.ts index 35e0ad983896..fcd5050cfe6d 100644 --- a/e2e/__tests__/declarationErrors.test.ts +++ b/e2e/__tests__/declarationErrors.test.ts @@ -9,7 +9,7 @@ import runJest from '../runJest'; const normalizeCircusJasmine = (str: string) => str - .replace(/console\.warn .+:\d+/, 'console.warn') + .replace(/console\.log .+:\d+/, 'console.log') .replace(/.+addSpecsToSuite (.+:\d+:\d+).+\n/, ''); it('warns if describe returns a Promise', () => { diff --git a/packages/jest-circus/src/index.ts b/packages/jest-circus/src/index.ts index 50d9f0668936..b7e93f3da0f4 100644 --- a/packages/jest-circus/src/index.ts +++ b/packages/jest-circus/src/index.ts @@ -5,6 +5,7 @@ * LICENSE file in the root directory of this source tree. */ +import chalk from 'chalk'; import {bind as bindEach} from 'jest-each'; import {formatExecError} from 'jest-message-util'; import {ErrorWithStack, isPromise} from 'jest-util'; @@ -68,11 +69,13 @@ const _dispatchDescribe = ( // TODO throw in Jest 25 if (isPromise(describeReturn)) { - console.warn( + console.log( formatExecError( new ErrorWithStack( - '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.', + 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.', + ), describeFn, ), {rootDir: '', testMatch: []}, @@ -80,11 +83,13 @@ const _dispatchDescribe = ( ), ); } else if (describeReturn !== undefined) { - console.warn( + console.log( formatExecError( new ErrorWithStack( - 'A "describe" callback must not return a value.\n' + - 'Returning a value from "describe" will fail the test in a future version of Jest.', + 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.', + ), describeFn, ), {rootDir: '', testMatch: []}, diff --git a/packages/jest-jasmine2/src/jasmine/Env.js b/packages/jest-jasmine2/src/jasmine/Env.js index 5daefd4355e0..0da0b92ac1f5 100644 --- a/packages/jest-jasmine2/src/jasmine/Env.js +++ b/packages/jest-jasmine2/src/jasmine/Env.js @@ -31,6 +31,7 @@ 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 queueRunner from '../queueRunner'; import treeProcessor from '../treeProcessor'; import isError from '../isError'; @@ -379,22 +380,26 @@ export default function(j$) { // TODO throw in Jest 25: declarationError = new Error if (isPromise(describeReturnValue)) { - console.warn( + console.log( formatExecError( new Error( - '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.', + 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( + console.log( formatExecError( new Error( - 'A "describe" callback must not return a value.\n' + - 'Returning a value from "describe" will fail the test in a future version of Jest.', + 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},