Fix unexpected GitHub Actions failures (#7980)
This commit is contained in:
1 parent
22f0c7d8b4
commit
aacaf4b2f2
3 files changed
+3
-10
No files matched your search
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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) =>
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user