Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An attempt to fix unexpected GitHub Actions failures #7980

Merged
merged 2 commits into from Apr 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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