Skip to content

Commit 5328444

Browse files
committed
console.warn => console.log
1 parent 1ead0ff commit 5328444

4 files changed

Lines changed: 25 additions & 15 deletions

File tree

e2e/__tests__/__snapshots__/declarationErrors.test.ts.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

33
exports[`warns if describe returns a Promise 1`] = `
4-
" console.warn
4+
" console.log
55
● Test suite failed to run
66
77
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`] = `
2121
`;
2222

2323
exports[`warns if describe returns something 1`] = `
24-
" console.warn
24+
" console.log
2525
● Test suite failed to run
2626
2727
A \\"describe\\" callback must not return a value.

e2e/__tests__/declarationErrors.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import runJest from '../runJest';
99

1010
const normalizeCircusJasmine = (str: string) =>
1111
str
12-
.replace(/console\.warn .+:\d+/, 'console.warn')
12+
.replace(/console\.log .+:\d+/, 'console.log')
1313
.replace(/.+addSpecsToSuite (.+:\d+:\d+).+\n/, '');
1414

1515
it('warns if describe returns a Promise', () => {

packages/jest-circus/src/index.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
TestMode,
2121
} from './types';
2222
import {dispatch} from './state';
23+
import chalk from 'chalk';
2324

2425
type THook = (fn: HookFn, timeout?: number) => void;
2526
type DescribeFn = (blockName: BlockName, blockFn: BlockFn) => void;
@@ -68,23 +69,27 @@ const _dispatchDescribe = (
6869

6970
// TODO throw in Jest 25
7071
if (isPromise(describeReturn)) {
71-
console.warn(
72+
console.log(
7273
formatExecError(
7374
new ErrorWithStack(
74-
'Returning a Promise from "describe" is not supported. Tests must be defined synchronously.\n' +
75-
'Returning a value from "describe" will fail the test in a future version of Jest.',
75+
chalk.yellow(
76+
'Returning a Promise from "describe" is not supported. Tests must be defined synchronously.\n' +
77+
'Returning a value from "describe" will fail the test in a future version of Jest.',
78+
),
7679
describeFn,
7780
),
7881
{rootDir: '', testMatch: []},
7982
{noStackTrace: false},
8083
),
8184
);
8285
} else if (describeReturn !== undefined) {
83-
console.warn(
86+
console.log(
8487
formatExecError(
8588
new ErrorWithStack(
86-
'A "describe" callback must not return a value.\n' +
87-
'Returning a value from "describe" will fail the test in a future version of Jest.',
89+
chalk.yellow(
90+
'A "describe" callback must not return a value.\n' +
91+
'Returning a value from "describe" will fail the test in a future version of Jest.',
92+
),
8893
describeFn,
8994
),
9095
{rootDir: '', testMatch: []},

packages/jest-jasmine2/src/jasmine/Env.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
3131
/* eslint-disable sort-keys */
3232

3333
import {AssertionError} from 'assert';
34+
import chalk from 'chalk';
3435
import queueRunner from '../queueRunner';
3536
import treeProcessor from '../treeProcessor';
3637
import isError from '../isError';
@@ -379,22 +380,26 @@ export default function(j$) {
379380

380381
// TODO throw in Jest 25: declarationError = new Error
381382
if (isPromise(describeReturnValue)) {
382-
console.warn(
383+
console.log(
383384
formatExecError(
384385
new Error(
385-
'Returning a Promise from "describe" is not supported. Tests must be defined synchronously.\n' +
386-
'Returning a value from "describe" will fail the test in a future version of Jest.',
386+
chalk.yellow(
387+
'Returning a Promise from "describe" is not supported. Tests must be defined synchronously.\n' +
388+
'Returning a value from "describe" will fail the test in a future version of Jest.',
389+
),
387390
),
388391
{rootDir: '', testMatch: []},
389392
{noStackTrace: false},
390393
),
391394
);
392395
} else if (describeReturnValue !== undefined) {
393-
console.warn(
396+
console.log(
394397
formatExecError(
395398
new Error(
396-
'A "describe" callback must not return a value.\n' +
397-
'Returning a value from "describe" will fail the test in a future version of Jest.',
399+
chalk.yellow(
400+
'A "describe" callback must not return a value.\n' +
401+
'Returning a value from "describe" will fail the test in a future version of Jest.',
402+
),
398403
),
399404
{rootDir: '', testMatch: []},
400405
{noStackTrace: false},

0 commit comments

Comments
 (0)