Skip to content

Commit

Permalink
console.warn => console.log
Browse files Browse the repository at this point in the history
  • Loading branch information
jeysal committed Mar 3, 2019
1 parent 1ead0ff commit 5328444
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 15 deletions.
4 changes: 2 additions & 2 deletions e2e/__tests__/__snapshots__/declarationErrors.test.ts.snap
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion e2e/__tests__/declarationErrors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
17 changes: 11 additions & 6 deletions packages/jest-circus/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
TestMode,
} from './types';
import {dispatch} from './state';
import chalk from 'chalk';

type THook = (fn: HookFn, timeout?: number) => void;
type DescribeFn = (blockName: BlockName, blockFn: BlockFn) => void;
Expand Down Expand Up @@ -68,23 +69,27 @@ 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: []},
{noStackTrace: false},
),
);
} 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: []},
Expand Down
17 changes: 11 additions & 6 deletions packages/jest-jasmine2/src/jasmine/Env.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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},
Expand Down

0 comments on commit 5328444

Please sign in to comment.