Skip to content

Commit

Permalink
Verify batched updates get scheduled despite errors
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon committed Nov 30, 2016
1 parent 641a6e2 commit 5f8b288
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 2 deletions.
15 changes: 13 additions & 2 deletions scripts/fiber/tests-passing.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1080,8 +1080,19 @@ src/renderers/shared/fiber/__tests__/ReactIncremental-test.js
* reads context when setState is above the provider

src/renderers/shared/fiber/__tests__/ReactIncrementalErrorHandling-test.js
* catches render error in a boundary during mounting
* propagates an error from a noop error boundary
* catches render error in a boundary during full deferred mounting
* catches render error in a boundary during partial deferred mounting
* catches render error in a boundary during animation mounting
* catches render error in a boundary during synchronous mounting
* catches render error in a boundary during batched mounting
* propagates an error from a noop error boundary during full deferred mounting
* propagates an error from a noop error boundary during partial deferred mounting
* propagates an error from a noop error boundary during animation mounting
* propagates an error from a noop error boundary during synchronous mounting
* propagates an error from a noop error boundary during batched mounting
* applies batched updates regardless despite errors in scheduling
* applies nested batched updates despite errors in scheduling
* applies sync updates regardless despite errors in scheduling
* can schedule updates after uncaught error in render on mount
* can schedule updates after uncaught error in render on update
* can schedule updates after uncaught error during umounting
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,50 @@ describe('ReactIncrementalErrorHandling', () => {
expect(ReactNoop.getChildren()).toEqual([]);
});

it('applies batched updates regardless despite errors in scheduling', () => {
ReactNoop.render(<span prop="a:1" />);
expect(() => {
ReactNoop.batchedUpdates(() => {
ReactNoop.render(<span prop="a:2" />);
ReactNoop.render(<span prop="a:3" />);
throw new Error('Hello');
});
}).toThrow('Hello');
ReactNoop.flush();
expect(ReactNoop.getChildren()).toEqual([span('a:3')]);
});

it('applies nested batched updates despite errors in scheduling', () => {
ReactNoop.render(<span prop="a:1" />);
expect(() => {
ReactNoop.batchedUpdates(() => {
ReactNoop.render(<span prop="a:2" />);
ReactNoop.render(<span prop="a:3" />);
ReactNoop.batchedUpdates(() => {
ReactNoop.render(<span prop="a:4" />);
ReactNoop.render(<span prop="a:5" />);
throw new Error('Hello');
});
});
}).toThrow('Hello');
ReactNoop.flush();
expect(ReactNoop.getChildren()).toEqual([span('a:5')]);
});

it('applies sync updates regardless despite errors in scheduling', () => {
ReactNoop.render(<span prop="a:1" />);
expect(() => {
ReactNoop.syncUpdates(() => {
ReactNoop.batchedUpdates(() => {
ReactNoop.render(<span prop="a:2" />);
ReactNoop.render(<span prop="a:3" />);
throw new Error('Hello');
});
});
}).toThrow('Hello');
expect(ReactNoop.getChildren()).toEqual([span('a:3')]);
});

it('can schedule updates after uncaught error in render on mount', () => {
var ops = [];

Expand Down

0 comments on commit 5f8b288

Please sign in to comment.