Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export class SolcJsCompiler implements Compiler {
// If the script is a TypeScript file, we need to pass the --import tsx/esm
// which is available, as we are running the tests
const nodeOptions = scriptPath.endsWith(".ts")
? ["--import", "tsx/esm"]
? ["--import", import.meta.resolve("tsx/esm")]
: [];

const args = [...nodeOptions];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ import { createHardhatRuntimeEnvironment } from "../../../../src/internal/hre-in

const log = debug("hardhat:test:console:task-action");

// NOTE:
// In a few tests, we replace the `replServer.displayPrompt` function with
// an empty function to prevent the final prompt from being printed to the console.
// This avoids a "use after close" error when running tests.

describe("console/task-action", function () {
let hre: HardhatRuntimeEnvironment;
let options: repl.ReplOptions;
Expand All @@ -42,6 +37,17 @@ describe("console/task-action", function () {
options = {
input,
output,
// We force the TTY mode to true because this simulates the conditions
// under which the console task is used.
// We should be careful about not using commands that require user input
// in tests.
// In non-TTY mode, the test fail with a "use after close" error because
// the REPL server processes the commands differently then and, at least,
// the ones that produce errors are not fully processed before the REPL
// is closed.
// Stricter validation for functions used after close was introduced in
// https://github.com/nodejs/node/commit/462c4b0c2459110326f8e20c908a8e1c62e69825
terminal: true,
};
});

Expand All @@ -58,7 +64,6 @@ describe("console/task-action", function () {
},
hre,
);
replServer.displayPrompt = () => {};
ensureError(replServer.lastError);
});

Expand All @@ -85,7 +90,6 @@ describe("console/task-action", function () {
},
hre,
);
replServer.displayPrompt = () => {};
ensureError(replServer.lastError);
});
});
Expand All @@ -103,7 +107,6 @@ describe("console/task-action", function () {
},
hre,
);
replServer.displayPrompt = () => {};
ensureError(replServer.lastError);
});

Expand All @@ -130,7 +133,6 @@ describe("console/task-action", function () {
},
hre,
);
replServer.displayPrompt = () => {};
ensureError(replServer.lastError);
});
});
Expand Down
Loading