diff --git a/packages/scheduler/src/SchedulerFeatureFlags.js b/packages/scheduler/src/SchedulerFeatureFlags.js index 57c9d151879c7..9b9deeb63ec1c 100644 --- a/packages/scheduler/src/SchedulerFeatureFlags.js +++ b/packages/scheduler/src/SchedulerFeatureFlags.js @@ -8,4 +8,4 @@ export const enableSchedulerDebugging = false; export const enableIsInputPending = false; -export const enableProfiling = __VARIANT__; +export const enableProfiling = false; diff --git a/packages/scheduler/src/forks/SchedulerFeatureFlags.www-dynamic.js b/packages/scheduler/src/forks/SchedulerFeatureFlags.www-dynamic.js new file mode 100644 index 0000000000000..086762d7b7071 --- /dev/null +++ b/packages/scheduler/src/forks/SchedulerFeatureFlags.www-dynamic.js @@ -0,0 +1,17 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + */ + +// In www, these flags are controlled by GKs. Because most GKs have some +// population running in either mode, we should run our tests that way, too, +// +// Use __VARIANT__ to simulate a GK. The tests will be run twice: once +// with the __VARIANT__ set to `true`, and once set to `false`. + +export const enableIsInputPending = __VARIANT__; +export const enableSchedulerDebugging = __VARIANT__; +export const enableProfiling = __VARIANT__; diff --git a/packages/scheduler/src/forks/SchedulerFeatureFlags.www.js b/packages/scheduler/src/forks/SchedulerFeatureFlags.www.js index 9fd86c7f94b2e..9087af8b22f78 100644 --- a/packages/scheduler/src/forks/SchedulerFeatureFlags.www.js +++ b/packages/scheduler/src/forks/SchedulerFeatureFlags.www.js @@ -6,10 +6,13 @@ * */ +const dynamicFeatureFlags = require('SchedulerFeatureFlags'); + +// Re-export dynamic flags from the www version. export const { enableIsInputPending, enableSchedulerDebugging, enableProfiling: enableProfilingFeatureFlag, -} = require('SchedulerFeatureFlags'); +} = dynamicFeatureFlags; export const enableProfiling = __PROFILE__ && enableProfilingFeatureFlag; diff --git a/scripts/jest/TestFlags.js b/scripts/jest/TestFlags.js index 45391b75f4148..9e9a531b0b3bb 100644 --- a/scripts/jest/TestFlags.js +++ b/scripts/jest/TestFlags.js @@ -57,6 +57,7 @@ function getTestFlags() { // These are required on demand because some of our tests mutate them. We try // not to but there are exceptions. const featureFlags = require('shared/ReactFeatureFlags'); + const schedulerFeatureFlags = require('scheduler/src/SchedulerFeatureFlags'); const www = global.__WWW__ === true; const releaseChannel = www @@ -81,6 +82,11 @@ function getTestFlags() { source: !process.env.IS_BUILD, www, + // If there's a naming conflict between scheduler and React feature flags, the + // React ones take precedence. + // TODO: Maybe we should error on conflicts? Or we could namespace + // the flags + ...schedulerFeatureFlags, ...featureFlags, ...environmentFlags, }, diff --git a/scripts/jest/setupTests.www.js b/scripts/jest/setupTests.www.js index e303d9fee22a5..c0058cb6e0849 100644 --- a/scripts/jest/setupTests.www.js +++ b/scripts/jest/setupTests.www.js @@ -19,4 +19,19 @@ jest.mock('shared/ReactFeatureFlags', () => { return wwwFlags; }); +jest.mock('scheduler/src/SchedulerFeatureFlags', () => { + const schedulerSrcPath = process.cwd() + '/packages/scheduler'; + jest.mock( + 'SchedulerFeatureFlags', + () => + jest.requireActual( + schedulerSrcPath + '/src/forks/SchedulerFeatureFlags.www-dynamic' + ), + {virtual: true} + ); + return jest.requireActual( + schedulerSrcPath + '/src/forks/SchedulerFeatureFlags.www' + ); +}); + global.__WWW__ = true;