Skip to content

Commit

Permalink
Add some error coverage and retry
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon committed Dec 3, 2020
1 parent 5186e01 commit a92435e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions packages/react-fetch/src/__tests__/ReactFetchNode-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,18 @@ describe('ReactFetchNode', () => {
});
expect(outputs).toMatchObject(['banana', 'mango', 'orange']);
});

// @gate experimental
it('can produce an error', async () => {
serverImpl = (req, res) => {};

expect.assertions(1);
try {
await waitForSuspense(() => {
return fetch('BOOM');
});
} catch (err) {
expect(err.message).toEqual('Invalid URL: BOOM');
}
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export function waitForSuspense<T>(fn: () => T): Promise<T> {
resolve(result);
} catch (thrownValue) {
if (typeof thrownValue.then === 'function') {
thrownValue.then(retry, reject);
thrownValue.then(retry, retry);
} else {
reject(thrownValue);
}
Expand Down

0 comments on commit a92435e

Please sign in to comment.