Skip to content

Commit

Permalink
stack trace
Browse files Browse the repository at this point in the history
  • Loading branch information
jeysal committed Mar 2, 2019
1 parent f17bcce commit 6b64186
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
2 changes: 2 additions & 0 deletions e2e/__tests__/declarationErrors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ it('warns if describe returns a Promise', () => {

expect(result.status).toBe(0);
expect(result.stdout).toMatch(/Tests must be defined synchronously/);
expect(result.stdout).toMatch(/at Object.describe/);
});

it('warns if describe returns something', () => {
Expand All @@ -23,4 +24,5 @@ it('warns if describe returns something', () => {

expect(result.status).toBe(0);
expect(result.stdout).toMatch(/"describe" callback must not return a value/);
expect(result.stdout).toMatch(/at Object.describe/);
});
12 changes: 8 additions & 4 deletions packages/jest-circus/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,17 @@ const _dispatchDescribe = (
// TODO throw in Jest 25
if (isPromise(describeReturn)) {
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.',
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.',
),
);
} else if (describeReturn !== 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.',
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.',
),
);
}

Expand Down
12 changes: 8 additions & 4 deletions packages/jest-jasmine2/src/jasmine/Env.js
Original file line number Diff line number Diff line change
Expand Up @@ -379,13 +379,17 @@ export default function(j$) {
// 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.',
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.',
),
);
} 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.',
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.',
),
);
}

Expand Down

0 comments on commit 6b64186

Please sign in to comment.