Skip to content

Commit cf38c1a

Browse files
Fix Configuration Variables tests for CI (#4557)
1 parent 7772524 commit cf38c1a

File tree

1 file changed

+45
-27
lines changed
  • packages/hardhat-core/test/internal/cli/vars

1 file changed

+45
-27
lines changed

packages/hardhat-core/test/internal/cli/vars/vars.ts

+45-27
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,15 @@ describe("vars", () => {
6868
);
6969

7070
expect(ctx.varsManager.get("newKey")).equals("newVal");
71-
assert(
72-
spyConsoleWarn.calledWith(
73-
`The configuration variable has been stored in ${TMP_FILE_PATH}`
74-
)
75-
);
7671
expect(code).equals(0);
72+
73+
if (process.stdout.isTTY) {
74+
assert(
75+
spyConsoleWarn.calledWith(
76+
`The configuration variable has been stored in ${TMP_FILE_PATH}`
77+
)
78+
);
79+
}
7780
});
7881

7982
describe("cli user prompt", () => {
@@ -97,12 +100,15 @@ describe("vars", () => {
97100
const code = await handleVars(["vars", "set", "newKey"], undefined);
98101

99102
expect(ctx.varsManager.get("newKey")).equals("valueFromCli");
100-
assert(
101-
spyConsoleWarn.calledWith(
102-
`The configuration variable has been stored in ${TMP_FILE_PATH}`
103-
)
104-
);
105103
expect(code).equals(0);
104+
105+
if (process.stdout.isTTY) {
106+
assert(
107+
spyConsoleWarn.calledWith(
108+
`The configuration variable has been stored in ${TMP_FILE_PATH}`
109+
)
110+
);
111+
}
106112
});
107113

108114
it("should throw an error because the cli user prompt for the value is not valid", async () => {
@@ -162,12 +168,16 @@ describe("vars", () => {
162168
assert(spyConsoleLog.getCall(2).calledWith("key3"));
163169
assert(spyConsoleLog.getCall(3).calledWith("key4"));
164170
assert(spyConsoleLog.getCall(4).calledWith("key5"));
165-
assert(
166-
spyConsoleWarn.calledWith(
167-
`\nAll configuration variables are stored in ${TMP_FILE_PATH}`
168-
)
169-
);
171+
170172
expect(code).equals(0);
173+
174+
if (process.stdout.isTTY) {
175+
assert(
176+
spyConsoleWarn.calledWith(
177+
`\nAll configuration variables are stored in ${TMP_FILE_PATH}`
178+
)
179+
);
180+
}
171181
});
172182

173183
it("should not list any key because they are not defined", async () => {
@@ -179,27 +189,35 @@ describe("vars", () => {
179189

180190
const code = await handleVars(["vars", "list"], undefined);
181191

182-
assert(
183-
spyConsoleWarn.calledWith(
184-
chalk.yellow(
185-
`There are no configuration variables stored in ${TMP_FILE_PATH}`
186-
)
187-
)
188-
);
189192
expect(code).equals(0);
193+
194+
if (process.stdout.isTTY) {
195+
assert(
196+
spyConsoleWarn.calledWith(
197+
chalk.yellow(
198+
`There are no configuration variables stored in ${TMP_FILE_PATH}`
199+
)
200+
)
201+
);
202+
}
190203
});
191204
});
192205

193206
describe("delete", () => {
194207
it("should successfully delete a key and its value", async () => {
195208
const code = await handleVars(["vars", "delete", "key1"], undefined);
209+
196210
assert(ctx.varsManager.get("key1") === undefined);
197-
assert(
198-
spyConsoleWarn.calledWith(
199-
`The configuration variable was deleted from ${TMP_FILE_PATH}`
200-
)
201-
);
211+
202212
expect(code).equals(0);
213+
214+
if (process.stdout.isTTY) {
215+
assert(
216+
spyConsoleWarn.calledWith(
217+
`The configuration variable was deleted from ${TMP_FILE_PATH}`
218+
)
219+
);
220+
}
203221
});
204222

205223
it("should show a warning because the key to delete cannot be found", async () => {

0 commit comments

Comments
 (0)