Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set up test infra for dynamic Scheduler flags #22139

Merged
merged 1 commit into from
Aug 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/scheduler/src/SchedulerFeatureFlags.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@

export const enableSchedulerDebugging = false;
export const enableIsInputPending = false;
export const enableProfiling = __VARIANT__;
export const enableProfiling = false;
17 changes: 17 additions & 0 deletions packages/scheduler/src/forks/SchedulerFeatureFlags.www-dynamic.js
Original file line number Diff line number Diff line change
@@ -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__;
5 changes: 4 additions & 1 deletion packages/scheduler/src/forks/SchedulerFeatureFlags.www.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
6 changes: 6 additions & 0 deletions scripts/jest/TestFlags.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
},
Expand Down
15 changes: 15 additions & 0 deletions scripts/jest/setupTests.www.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;