Skip to content

Commit

Permalink
Add flag for www release channels
Browse files Browse the repository at this point in the history
Using a heuristic where I check a flag that is known to only be enabled
in www. I left a TODO to instead set the release channel explicitly in
each test config.
  • Loading branch information
acdlite committed Apr 13, 2020
1 parent 0c3c27a commit a026682
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions scripts/jest/TestFlags.js
Expand Up @@ -35,7 +35,11 @@
const environmentFlags = {
__DEV__,
build: __DEV__ ? 'development' : 'production',

// TODO: Should "experimental" also imply "modern"? Maybe we should
// always compare to the channel?
experimental: __EXPERIMENTAL__,
// Similarly, should stable imply "classic"?
stable: !__EXPERIMENTAL__,
};

Expand All @@ -44,6 +48,18 @@ function getTestFlags() {
// not to but there are exceptions.
const featureFlags = require('shared/ReactFeatureFlags');

// TODO: This is a heuristic to detect the release channel by checking a flag
// that is known to only be enabled in www. What we should do instead is set
// the release channel explicitly in the each test config file.
const www = featureFlags.enableSuspenseCallback === true;
const releaseChannel = www
? __EXPERIMENTAL__
? 'modern'
: 'classic'
: __EXPERIMENTAL__
? 'experimental'
: 'stable';

// Return a proxy so we can throw if you attempt to access a flag that
// doesn't exist.
return new Proxy(
Expand All @@ -52,6 +68,11 @@ function getTestFlags() {
old: featureFlags.enableNewReconciler === true,
new: featureFlags.enableNewReconciler === true,

channel: releaseChannel,
modern: releaseChannel === 'modern',
classic: releaseChannel === 'classic',
www,

...featureFlags,
...environmentFlags,
},
Expand Down

0 comments on commit a026682

Please sign in to comment.