Files
react-native-devtools-frontend/test/shared/config.ts
T
Ted Meyer 7e5ebf014b Adds End2End test for the Media tab.
I had to add support for running the tests with chromium
--enable-features flags. This isn't on by default though, I'll leave
that up to you to turn on. The tests just exit early if the flag isn't
present.

Change-Id: I132ca71796d8f069a6fba0342f10f2f2b18c7b62
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2125249
Commit-Queue: Ted Meyer <tmathmeyer@chromium.org>
Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org>
2020-03-31 16:29:03 +00:00

40 lines
1.7 KiB
TypeScript

// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
interface SupportedEnvVars {
NO_SHUFFLE: boolean; // Whether or not to shuffle tests.
STRESS: boolean; // Stress test (slowdown CPU; multiple iterations)
VERBOSE: boolean; // Log stdout from the workers.
THROTTLE: number; // CPU throttle multiplier.
TEST_LIST: string; // Absolute path to the test list.
TEST_FILE: string; // Absolute path to the test file from the test list to run in isolation.
DEBUG: boolean; // Debug mode. When enabled, has longer timeouts and runs Chrome in head mode.
ITERATIONS: number; // Number of test iterations.
JOBS: number; // Number of workers to use.
SLOWMO: number; // Number of milliseconds between actions. Recommended value: 50.
CHROME_BIN: string; // Absolute path to the Chrome binary.
INTERACTIVE: boolean; // [Unused]: Placeholder for screenshot diffing.
TIMEOUT: number; // The timeout in ms to wait for tests.
CHROME_FEATURES: string; // --enable-features={} for the Chrome binary.
}
export function getEnvVar<Key extends keyof SupportedEnvVars>(
name: Key, defaultValue?: SupportedEnvVars[Key]): SupportedEnvVars[Key] {
const envVar = process.env[name];
if (typeof defaultValue === 'boolean') {
return (!!envVar) as SupportedEnvVars[Key];
}
if (typeof defaultValue === 'number') {
let value = Number(envVar);
if (Number.isNaN(value)) {
value = defaultValue;
}
return value as SupportedEnvVars[Key];
}
return (envVar || defaultValue) as SupportedEnvVars[Key];
}