Skip to content

Commit

Permalink
Fix unexpected GitHub Actions failures (#7980)
Browse files Browse the repository at this point in the history
  • Loading branch information
thorn0 committed Apr 11, 2020
1 parent 2a9f651 commit 1bfef81
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 10 deletions.
4 changes: 1 addition & 3 deletions tests_integration/__tests__/check.js
Expand Up @@ -27,10 +27,8 @@ describe("--checks works in CI just as in a non-TTY mode", () => {
"cli/write",
["--check", "formatted.js", "unformatted.js"],
{
env: {
CI: "true",
},
stdoutIsTTY: true,
ci: true,
}
).test({
status: 1,
Expand Down
4 changes: 1 addition & 3 deletions tests_integration/__tests__/list-different.js
Expand Up @@ -27,10 +27,8 @@ describe("--list-different works in CI just as in a non-TTY mode", () => {
"cli/write",
["--list-different", "formatted.js", "unformatted.js"],
{
env: {
CI: "true",
},
stdoutIsTTY: true,
ci: true,
}
).test({
status: 1,
Expand Down
5 changes: 1 addition & 4 deletions tests_integration/runPrettier.js
Expand Up @@ -62,13 +62,11 @@ function runPrettier(dir, args, options) {
const originalExitCode = process.exitCode;
const originalStdinIsTTY = process.stdin.isTTY;
const originalStdoutIsTTY = process.stdout.isTTY;
const originalEnv = process.env;

process.chdir(normalizeDir(dir));
process.stdin.isTTY = !!options.isTTY;
process.stdout.isTTY = !!options.stdoutIsTTY;
process.argv = ["path/to/node", "path/to/prettier/bin"].concat(args);
process.env = { ...process.env, ...options.env };

jest.resetModules();

Expand All @@ -80,7 +78,7 @@ function runPrettier(dir, args, options) {
.mockImplementation(() => SynchronousPromise.resolve(options.input || ""));
jest
.spyOn(require(thirdParty), "isCI")
.mockImplementation(() => process.env.CI);
.mockImplementation(() => !!options.ci);
jest
.spyOn(require(thirdParty), "cosmiconfig")
.mockImplementation((moduleName, options) =>
Expand Down Expand Up @@ -113,7 +111,6 @@ function runPrettier(dir, args, options) {
process.exitCode = originalExitCode;
process.stdin.isTTY = originalStdinIsTTY;
process.stdout.isTTY = originalStdoutIsTTY;
process.env = originalEnv;
jest.restoreAllMocks();
}

Expand Down

0 comments on commit 1bfef81

Please sign in to comment.