mirror of
https://github.com/facebook/react.git
synced 2026-11-18 20:15:56 +00:00
Create a separate test file for incremental error handling
This commit is contained in:
1 parent
4266f08e48
commit
e2be9830b8
2 files changed
+46
-23
No files matched your search
@@ -1465,27 +1465,4 @@ describe('ReactIncremental', () => {
|
||||
]);
|
||||
expect(instance.state.n).toEqual(4);
|
||||
});
|
||||
|
||||
it('propagates an error from a noop error boundary', () => {
|
||||
class NoopBoundary extends React.Component {
|
||||
unstable_handleError() {
|
||||
// Noop
|
||||
}
|
||||
render() {
|
||||
return this.props.children;
|
||||
}
|
||||
}
|
||||
|
||||
function RenderError() {
|
||||
throw new Error('render error');
|
||||
}
|
||||
|
||||
ReactNoop.render(
|
||||
<NoopBoundary>
|
||||
<RenderError />
|
||||
</NoopBoundary>
|
||||
);
|
||||
|
||||
expect(ReactNoop.flush).toThrow('render error');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* Copyright 2013-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* @emails react-core
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var React;
|
||||
var ReactNoop;
|
||||
|
||||
describe('ReactIncrementalErrorHandling', () => {
|
||||
beforeEach(() => {
|
||||
jest.resetModuleRegistry();
|
||||
React = require('React');
|
||||
ReactNoop = require('ReactNoop');
|
||||
});
|
||||
|
||||
it('propagates an error from a noop error boundary', () => {
|
||||
class NoopBoundary extends React.Component {
|
||||
unstable_handleError() {
|
||||
// Noop
|
||||
}
|
||||
render() {
|
||||
return this.props.children;
|
||||
}
|
||||
}
|
||||
|
||||
function RenderError() {
|
||||
throw new Error('render error');
|
||||
}
|
||||
|
||||
ReactNoop.render(
|
||||
<NoopBoundary>
|
||||
<RenderError />
|
||||
</NoopBoundary>
|
||||
);
|
||||
|
||||
expect(ReactNoop.flush).toThrow('render error');
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user