mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Add test to ensure setUpDefaultReactNativeEnvironment does not access feature flags (#53057)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/53057 Changelog: [internal] This adds a Fantom test to ensure that `setUpDefaultReactNativeEnvironment` doesn't read any feature flags. This prevents catching this as a runtime issue when the feature flag system complains that feature flags were accessed before being overridden, which always would happen if this module read any flags (as it runs before any product code that sets overrides). Reviewed By: rshest Differential Revision: D79639890 fbshipit-source-id: 6997609b7bf84947a6da53b58e68f9edd5654912
This commit is contained in:
committed by
Facebook GitHub Bot
parent
527e308a90
commit
5936f29d6a
+28
@@ -0,0 +1,28 @@
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @flow strict-local
|
||||
* @format
|
||||
*/
|
||||
|
||||
import * as ReactNativeFeatureFlags from '../../featureflags/ReactNativeFeatureFlags';
|
||||
import * as ReactNativeFeatureFlagsBase from '../../featureflags/ReactNativeFeatureFlagsBase';
|
||||
import setUpDefaultReactNativeEnvironment from 'react-native/src/private/setup/setUpDefaultReactNativeEnvironment';
|
||||
|
||||
describe('setUpReactNativeEnvironment', () => {
|
||||
it('should not read any feature flags', () => {
|
||||
ReactNativeFeatureFlagsBase.dangerouslyResetForTesting();
|
||||
|
||||
setUpDefaultReactNativeEnvironment(false);
|
||||
|
||||
expect(() => {
|
||||
// If any feature flags were read, this call would fail.
|
||||
ReactNativeFeatureFlags.override({
|
||||
jsOnlyTestFlag: () => true,
|
||||
});
|
||||
}).not.toThrow();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user