Fix "missing flag" error for non-boolean types (#18592)
Not all test flags are booleans, e.g. the build type
Andrew Clark committed
Apr 13, 2020 at 12:57 UTC
0c3c27a718579066e08e1b2f5529deb67999e114
2 files changed
+8
-1
scripts/babel/__tests__/transform-test-gate-pragma-test.js
+7
@@ -173,6 +173,13 @@ describe('transform test-gate-pragma: actual runtime', () => {
173
}
174
});
175
176
+ // @gate build === "development"
177
+ test('strings', () => {
178
+ if (!__DEV__) {
179
+ throw Error("Doesn't work in production!");
180
+ }
181
+ });
182
+
183
// Always should fail because of the unguarded console.error
184
// @gate false
185
test('works with console.error tracking', () => {
scripts/jest/TestFlags.js
+1
-1
@@ -58,7 +58,7 @@ function getTestFlags() {
58
{
59
get(flags, flagName) {
60
const flagValue = flags[flagName];
61
- if (typeof flagValue !== 'boolean' && typeof flagName === 'string') {
61
+ if (flagValue === undefined && typeof flagName === 'string') {
62
throw Error(
63
`Feature flag "${flagName}" does not exist. See TestFlags.js ` +
64
'for more details.'