mirror of
https://github.com/facebook/react.git
synced 2026-02-24 20:53:03 +00:00
* Support throwing null In JavaScript, you can throw values of any type, not just errors. That includes null. We currently rely on null checks to determine if a user- provided function has thrown. This refactors our error handling code to keep track of an explicit boolean flag instead. * Add DOM fixture test case for break on exception behavior * preventDefault error events during feature test We call invokeGuardedCallbackDev at startup as part of a feature test. But we don't want those errors to log to the console. * Add throwing null test case * Use ReactFeatureFlags instead of ReactDOMFeatureFlags React ART uses this, too. * Non-errors in error logger If a non-error is thrown, we'll coerce the value to a string and use that as the message.
28 lines
892 B
JavaScript
28 lines
892 B
JavaScript
'use strict';
|
|
|
|
// We want to globally mock this but jest doesn't let us do that by default
|
|
// for a file that already exists. So we have to explicitly mock it.
|
|
jest.mock('ReactDOMFeatureFlags', () => {
|
|
const flags = require.requireActual('ReactDOMFeatureFlags');
|
|
return Object.assign({}, flags, {
|
|
useFiber: true,
|
|
});
|
|
});
|
|
jest.mock('ReactFeatureFlags', () => {
|
|
const flags = require.requireActual('ReactFeatureFlags');
|
|
return Object.assign({}, flags, {
|
|
disableNewFiberFeatures: true,
|
|
forceInvokeGuardedCallbackDev: true,
|
|
});
|
|
});
|
|
jest.mock('ReactNativeFeatureFlags', () => {
|
|
const flags = require.requireActual('ReactNativeFeatureFlags');
|
|
return Object.assign({}, flags, {
|
|
useFiber: true,
|
|
});
|
|
});
|
|
|
|
// Error logging varies between Fiber and Stack;
|
|
// Rather than fork dozens of tests, mock the error-logging file by default.
|
|
jest.mock('ReactFiberErrorLogger');
|