Skip to content

Commit 5936f29

Browse files
rubennortefacebook-github-bot
authored andcommitted
Add test to ensure setUpDefaultReactNativeEnvironment does not access feature flags (#53057)
Summary: Pull Request resolved: #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
1 parent 527e308 commit 5936f29

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @flow strict-local
8+
* @format
9+
*/
10+
11+
import * as ReactNativeFeatureFlags from '../../featureflags/ReactNativeFeatureFlags';
12+
import * as ReactNativeFeatureFlagsBase from '../../featureflags/ReactNativeFeatureFlagsBase';
13+
import setUpDefaultReactNativeEnvironment from 'react-native/src/private/setup/setUpDefaultReactNativeEnvironment';
14+
15+
describe('setUpReactNativeEnvironment', () => {
16+
it('should not read any feature flags', () => {
17+
ReactNativeFeatureFlagsBase.dangerouslyResetForTesting();
18+
19+
setUpDefaultReactNativeEnvironment(false);
20+
21+
expect(() => {
22+
// If any feature flags were read, this call would fail.
23+
ReactNativeFeatureFlags.override({
24+
jsOnlyTestFlag: () => true,
25+
});
26+
}).not.toThrow();
27+
});
28+
});

0 commit comments

Comments
 (0)