Repository: microsoft/TypeScript
File: src/testRunner/unittests/tsc/commandLine.ts (TypeScript)

Code before:
    verifyTsc({
        scenario: "commandLine",
        subScenario: "show help with ExitStatus.DiagnosticsPresent_OutputsSkipped when host can't provide terminal width",
        sys: () => TestServerHost.createWatchedSystem(emptyArray),
        commandLineArgs: emptyArray,
    });

    verifyTsc({
        scenario: "commandLine",
        subScenario: "does not add color when NO_COLOR is set",
        sys: () =>
            TestServerHost.createWatchedSystem(emptyArray, {
                environmentVariables: new Map([["NO_COLOR", "true"]]),
            }),
        commandLineArgs: emptyArray,
    });

    verifyTsc({
        scenario: "commandLine",
        subScenario: "when build not first argument",
        sys: () => TestServerHost.createWatchedSystem(emptyArray),
        commandLineArgs: ["--verbose", "--build"],
    });

    verifyTsc({
        scenario: "commandLine",
        subScenario: "help",
        sys: () => TestServerHost.createWatchedSystem(emptyArray),
        commandLineArgs: ["--help"],
    });

    verifyTsc({
        scenario: "commandLine",
        subScenario: "help all",
        sys: () => TestServerHost.createWatchedSystem(emptyArray),
        commandLineArgs: ["--help", "--all"],
    });
});


Review comment (suggestion):
The new "adds color when FORCE_COLOR is set" test uses `TestServerHost.createWatchedSystem`, whose `writeOutputIsTTY()` always returns `true`. That means the output would already be colored even without `FORCE_COLOR`, so this test doesn't actually validate the new FORCE_COLOR behavior (forcing color in a non-TTY scenario). Consider overriding `writeOutputIsTTY` to return `false` for this test (or enhancing the host to support a non-TTY mode) so the baseline would differ without FORCE_COLOR and the test would catch regressions.

Code after:
    verifyTsc({
        scenario: "commandLine",
        subScenario: "show help with ExitStatus.DiagnosticsPresent_OutputsSkipped when host can't provide terminal width",
        sys: () => TestServerHost.createWatchedSystem(emptyArray),
        commandLineArgs: emptyArray,
    });

    verifyTsc({
        scenario: "commandLine",
        subScenario: "does not add color when NO_COLOR is set",
        sys: () =>
            TestServerHost.createWatchedSystem(emptyArray, {
                environmentVariables: new Map([["NO_COLOR", "true"]]),
            }),
        commandLineArgs: emptyArray,
    });

    verifyTsc({
        scenario: "commandLine",
        subScenario: "adds color when FORCE_COLOR is set",
        sys: () =>
            TestServerHost.createWatchedSystem(emptyArray, {
                environmentVariables: new Map([["FORCE_COLOR", "true"]]),
            }),
        commandLineArgs: emptyArray,
    });

    verifyTsc({
        scenario: "commandLine",
        subScenario: "does not add color when NO_COLOR is set even if FORCE_COLOR is set",
        sys: () =>
            TestServerHost.createWatchedSystem(emptyArray, {
                environmentVariables: new Map([["NO_COLOR", "true"], ["FORCE_COLOR", "true"]]),
            }),
        commandLineArgs: emptyArray,
    });

    verifyTsc({
        scenario: "commandLine",
        subScenario: "when build not first argument",
        sys: () => TestServerHost.createWatchedSystem(emptyArray),
        commandLineArgs: ["--verbose", "--build"],
    });

    verifyTsc({
        scenario: "commandLine",
        subScenario: "help",
        sys: () => TestServerHost.createWatchedSystem(emptyArray),
        commandLineArgs: ["--help"],
    });