Skip to content

Commit

Permalink
Add stack traces on async failures (#6008)
Browse files Browse the repository at this point in the history
* add stacktraces to async matchers

* add stack trace on spec timeout

* link to PR

* remove uninteresting frame from snapshot

* Add stack trace for thrown non-`Error`s

* more node 6 stack cleanup

* please flow gods
  • Loading branch information
SimenB authored and cpojer committed Apr 17, 2018
1 parent 3ce8743 commit 25bc4bf
Show file tree
Hide file tree
Showing 10 changed files with 333 additions and 75 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

### Features

* `[expect]` Add stack trace for async errors
([#6008](https://github.com/facebook/jest/pull/6008))
* `[jest-jasmine2]` Add stack trace for timeouts
([#6008](https://github.com/facebook/jest/pull/6008))
* `[jest-jasmine2]` Add stack trace for thrown non-`Error`s
([#6008](https://github.com/facebook/jest/pull/6008))
* `[jest-runtime]` Prevent modules from marking themselves as their own parent
([#5235](https://github.com/facebook/jest/issues/5235))
* `[jest-mock]` Add support for auto-mocking generator functions
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`shows the correct errors in stderr when failing tests 1`] = `
Object {
"rest": "FAIL __tests__/failure.test.js
"FAIL __tests__/failure.test.js
✕ fail with expected non promise values
✕ fail with expected non promise values and not
✕ fail with expected promise values
Expand Down Expand Up @@ -30,30 +29,47 @@ Object {
● fail with expected promise values
Error
Error: Expected value to have length:
2
Received:
1
received.length:
1
Expected value to have length:
2
Received:
1
received.length:
1
22 |
23 | it('fail with expected promise values', async () => {
> 24 | await (expect(Promise.resolve([1])): any).resolves.toHaveLengthAsync(
| ^
25 | Promise.resolve(2)
26 | );
27 | });
at __tests__/failure.test.js:24:54
at __tests__/failure.test.js:11:191
at __tests__/failure.test.js:11:437
at __tests__/failure.test.js:11:99
● fail with expected promise values and not
Error
Error: Expected value to not have length:
2
Received:
1,2
received.length:
2
Expected value to not have length:
2
Received:
1,2
received.length:
2
28 |
29 | it('fail with expected promise values and not', async () => {
> 30 | await (expect(Promise.resolve([1, 2])).resolves.not: any).toHaveLengthAsync(
| ^
31 | Promise.resolve(2)
32 | );
33 | });
at __tests__/failure.test.js:30:61
at __tests__/failure.test.js:11:191
at __tests__/failure.test.js:11:437
at __tests__/failure.test.js:11:99
",
"summary": "Test Suites: 1 failed, 1 total
Tests: 4 failed, 4 total
Snapshots: 0 total
Time: <<REPLACED>>
Ran all test suites matching /failure.test.js/i.
",
}
"
`;
Loading

0 comments on commit 25bc4bf

Please sign in to comment.