Fix "missing flag" error for non-boolean types (#18592)

Not all test flags are booleans, e.g. the build type
This commit is contained in:
Andrew Clark 2020-04-13 12:57:31 -07:00 committed by GitHub
parent 65237a237e
commit 0c3c27a718
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View File

@ -173,6 +173,13 @@ describe('transform test-gate-pragma: actual runtime', () => {
}
});
// @gate build === "development"
test('strings', () => {
if (!__DEV__) {
throw Error("Doesn't work in production!");
}
});
// Always should fail because of the unguarded console.error
// @gate false
test('works with console.error tracking', () => {

View File

@ -58,7 +58,7 @@ function getTestFlags() {
{
get(flags, flagName) {
const flagValue = flags[flagName];
if (typeof flagValue !== 'boolean' && typeof flagName === 'string') {
if (flagValue === undefined && typeof flagName === 'string') {
throw Error(
`Feature flag "${flagName}" does not exist. See TestFlags.js ` +
'for more details.'