Skip to content

Commit 962c6c6

Browse files
committed
Update FAQs for 5.10
1 parent 42e984a commit 962c6c6

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

_faq/async/unhandled-rejection.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ promise rejection event if you allow control to return to the JavaScript
77
runtime without first attaching a rejection handler. That's true even if you
88
don't do anything with the promise. Jasmine turns unhandled rejections into
99
failures because they almost always mean that something unexpectedly went wrong,
10-
and becuase there's no way to distinguish "real" unhandled rejections from the
11-
ones that would eventually be handled in the future.
10+
and because there's no cheap way to distinguish "real" unhandled rejections from
11+
the ones that will eventually be handled in the future.
1212

1313
Consider this spec:
1414

@@ -24,7 +24,6 @@ it('causes an unhandled rejection', async function() {
2424
});
2525
```
2626

27-
2827
The rejection will eventually be handled via the `try`/`catch`. But the JS
2928
runtime detects the unhandled rejection before that part of the spec runs. This
3029
happens because the `await somethingAsync()` call returns control to the JS
@@ -47,7 +46,7 @@ it('causes an unhandled rejection', async function() {
4746
});
4847
```
4948

50-
As a last resort, you can suppress the unhandled rejection by attaching a no-op
49+
Alternately, you can suppress the unhandled rejection by attaching a no-op
5150
catch handler:
5251

5352
```
@@ -65,5 +64,12 @@ it('causes an unhandled rejection', async function() {
6564
});
6665
```
6766

67+
Another option is to set the [detectLateRejectionHandling](/api/edge/Configuration.html#detectLateRejectionHandling)
68+
core configuration property to true. With that option enabled, Jasmine will use
69+
the browser or Node's `rejectionhandled` event to detect rejections that were
70+
handled after the browser or Node emitted an unhandled rejection. The
71+
`detectLateRejectionHandling` option is off by default because it imposes a
72+
performance penatly.
73+
6874
See also [How can I configure a spy to return a rejected promise without triggering an unhandled promise rejection error?](#return-reject)
6975
for how to avoid unhandled rejections when configuring spies.

_faq/spies/return-reject.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,11 @@ it('does not cause an unhandled promise rejection', async function() {
4343
await expectAsync(doSomething(foo)).toBeRejected();
4444
});
4545
```
46+
47+
Another option is to set the [detectLateRejectionHandling](/api/edge/Configuration.html#detectLateRejectionHandling)
48+
core configuration property to true. With that option enabled, Jasmine will use
49+
the browser or Node's `rejectionhandled` event to detect rejections that were
50+
handled after the browser or Node emitted an unhandled rejection. The
51+
`detectLateRejectionHandling` option is off by default because it imposes a
52+
performance penatly.
53+

0 commit comments

Comments
 (0)