Files
react-native-devtools-frontend/test/shared/config.ts
T
Eric Leese cbb0a8bfe0 Add option to save screenshots to an html file
If the HTML_OUTPUT_FILE environment variable is set, screenshots
from timed out tests will be appended to an html file rather than
the log. Remember to delete this file between runs.

Bug: 1081217
Change-Id: I064ca303061b49042366d35933f0f8d3f3a01158
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3810236
Commit-Queue: Eric Leese <leese@chromium.org>
Reviewed-by: Danil Somsikov <dsv@chromium.org>
2022-08-09 14:28:20 +00:00

43 lines
1.9 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 comma-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.
HTML_OUTPUT_FILE: string; // Path to an html file for additional debug output such as screenshots.
/* 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];
}