Skip to content

Commit

Permalink
Don't show warning from spied console.warn (#12946)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo committed Mar 2, 2021
1 parent 8574aa3 commit 42752a4
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions packages/babel-cli/test/index.js
Expand Up @@ -274,10 +274,20 @@ fs.readdirSync(fixtureLoc).forEach(function (binName) {
describe("util.js", () => {
describe("chmod", () => {
it("should warn the user if chmod fails", () => {
const spyConsoleWarn = jest.spyOn(console, "warn");
// should expect a string as first argument
const spyConsoleWarn = jest
.spyOn(console, "warn")
.mockImplementation(() => {});

// The first argument should be a string.
// The real reason chmod will fail is due to wrong permissions,
// but this is enough to cause a failure.
chmod(100, "file.js");

expect(spyConsoleWarn).toHaveBeenCalledTimes(1);
expect(spyConsoleWarn).toHaveBeenCalledWith(
"Cannot change permissions of file.js",
);

spyConsoleWarn.mockRestore();
});
});
Expand Down

0 comments on commit 42752a4

Please sign in to comment.