Files
react-native-devtools-frontend/test/shared/config.ts
T
Alex Rudenko fd136e001e Rename DEBUG env var to DEBUG_TEST
Currently, you cannot run tests in non-debug mode
and turn on debug logging from Puppeteer that relies
on https://www.npmjs.com/package/debug.

Running `DEBUG=puppeteer.* ...` would also start the
test runner in a debug and non headless mode. This
CL renames the DEBUG variable that DevTools test runner
relies on so that debug logging is independent from the
debug mode we have for tests.

Bug: none
Change-Id: I8b8476f7c26c07eea1db29bfae74d4fb61afd42c
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2963755
Reviewed-by: Simon Zünd <szuend@chromium.org>
Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org>
Reviewed-by: Jan Scheffler <janscheffler@chromium.org>
Commit-Queue: Alex Rudenko <alexrudenko@chromium.org>
2021-06-16 12:47:15 +00:00

42 lines
1.8 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 {
/* eslint-disable @typescript-eslint/naming-convention */
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_PATTERNS: string; // A semicolon-separated list of extglob pattern to filter the tests.
DEBUG_TEST: 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.
/* eslint-enable @typescript-eslint/naming-convention */
}
export function getEnvVar<Key extends keyof SupportedEnvVars>(
name: Key, defaultValue?: SupportedEnvVars[Key]): SupportedEnvVars[Key] {
const envVar = process.env[name];
if (typeof defaultValue === 'boolean') {
return (Boolean(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];
}