Skip to content

Commit 619f68b

Browse files
rubennortefacebook-github-bot
authored andcommitted
Do not log warning for missing feature flags native module in tests (#51629)
Summary: Pull Request resolved: #51629 Changelog: [internal] The native module will never be defined in tests, so there's no point in logging this warning there. Reviewed By: rshest Differential Revision: D75451414 fbshipit-source-id: cdc1f674d01fcaf58c1c2342c994d95e6b3b6847
1 parent 254a918 commit 619f68b

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

packages/react-native/src/private/featureflags/ReactNativeFeatureFlagsBase.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ const hasTurboModules =
102102
function maybeLogUnavailableNativeModuleError(configName: string): void {
103103
if (
104104
!NativeReactNativeFeatureFlags &&
105+
// Don't log in tests.
106+
process.env.NODE_ENV !== 'test' &&
105107
// Don't log more than once per config
106108
!reportedConfigNames.has(configName) &&
107109
// Don't log in the legacy architecture.

packages/react-native/src/private/featureflags/__tests__/ReactNativeFeatureFlags-test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
* @format
99
*/
1010

11+
// Pretend to not run in a testing environment so we log the warning for the
12+
// missing native module to the console.
13+
process.env.NODE_ENV = 'development';
14+
1115
describe('ReactNativeFeatureFlags', () => {
1216
beforeEach(() => {
1317
jest.unmock('../specs/NativeReactNativeFeatureFlags');

0 commit comments

Comments
 (0)