Skip to content

Commit 6b64186

Browse files
committed
stack trace
1 parent f17bcce commit 6b64186

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

e2e/__tests__/declarationErrors.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ it('warns if describe returns a Promise', () => {
1414

1515
expect(result.status).toBe(0);
1616
expect(result.stdout).toMatch(/Tests must be defined synchronously/);
17+
expect(result.stdout).toMatch(/at Object.describe/);
1718
});
1819

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

2425
expect(result.status).toBe(0);
2526
expect(result.stdout).toMatch(/"describe" callback must not return a value/);
27+
expect(result.stdout).toMatch(/at Object.describe/);
2628
});

packages/jest-circus/src/index.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,17 @@ const _dispatchDescribe = (
6868
// TODO throw in Jest 25
6969
if (isPromise(describeReturn)) {
7070
console.warn(
71-
'Returning a Promise from "describe" is not supported. Tests must be defined synchronously.\n' +
72-
'Returning a value from "describe" will fail the test in a future version of Jest.',
71+
new ErrorWithStack(
72+
'Returning a Promise from "describe" is not supported. Tests must be defined synchronously.\n' +
73+
'Returning a value from "describe" will fail the test in a future version of Jest.',
74+
),
7375
);
7476
} else if (describeReturn !== undefined) {
7577
console.warn(
76-
'A "describe" callback must not return a value.\n' +
77-
'Returning a value from "describe" will fail the test in a future version of Jest.',
78+
new ErrorWithStack(
79+
'A "describe" callback must not return a value.\n' +
80+
'Returning a value from "describe" will fail the test in a future version of Jest.',
81+
),
7882
);
7983
}
8084

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -379,13 +379,17 @@ export default function(j$) {
379379
// TODO throw in Jest 25: declarationError = new Error
380380
if (isPromise(describeReturnValue)) {
381381
console.warn(
382-
'Returning a Promise from "describe" is not supported. Tests must be defined synchronously.\n' +
383-
'Returning a value from "describe" will fail the test in a future version of Jest.',
382+
new ErrorWithStack(
383+
'Returning a Promise from "describe" is not supported. Tests must be defined synchronously.\n' +
384+
'Returning a value from "describe" will fail the test in a future version of Jest.',
385+
),
384386
);
385387
} else if (describeReturnValue !== undefined) {
386388
console.warn(
387-
'A "describe" callback must not return a value.\n' +
388-
'Returning a value from "describe" will fail the test in a future version of Jest.',
389+
new ErrorWithStack(
390+
'A "describe" callback must not return a value.\n' +
391+
'Returning a value from "describe" will fail the test in a future version of Jest.',
392+
),
389393
);
390394
}
391395

0 commit comments

Comments
 (0)