Skip to content

Commit ea2eb88

Browse files
committed
Fix broken test
1 parent 9fb054a commit ea2eb88

File tree

1 file changed

+34
-23
lines changed
  • v-next/hardhat-toolbox-mocha-ethers/test

1 file changed

+34
-23
lines changed

v-next/hardhat-toolbox-mocha-ethers/test/index.ts

Lines changed: 34 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,40 @@ describe("hardhat-toolbox-mocha-ethers", function () {
1212
useFixtureProject("toolbox");
1313

1414
it("should not throw because all the plugins should exist", async function () {
15-
const hardhatConfig = await import(
16-
pathToFileURL(path.join(process.cwd(), "hardhat.config.js")).href
17-
);
18-
19-
const hre = await createHardhatRuntimeEnvironment(hardhatConfig.default);
20-
21-
// This will check that the node test runner is available
22-
assert.notEqual(hre.tasks.getTask(["test", "mocha"]), undefined);
23-
24-
// This will check that ethers, chai and network helpers are available
25-
await hre.tasks.getTask(["run"]).run({ script: "scripts/script.ts" });
26-
27-
// This will check that the keystore is available
28-
assert.notEqual(hre.tasks.getTask(["keystore", "list"]), undefined);
29-
30-
// This will check that ignition is available
31-
assert.notEqual(hre.tasks.getTask(["ignition"]), undefined);
32-
33-
// This will check that typechain is available
34-
await remove(path.join(process.cwd(), "types")); // Be sure the folder doesn't exist
35-
await hre.tasks.getTask(["build"]).run();
36-
await exists(path.join(process.cwd(), "types"));
37-
await remove(path.join(process.cwd(), "types"));
15+
try {
16+
const hardhatConfig = await import(
17+
pathToFileURL(path.join(process.cwd(), "hardhat.config.js")).href
18+
);
19+
20+
const hre = await createHardhatRuntimeEnvironment(
21+
hardhatConfig.default,
22+
);
23+
24+
// This will check that the node test runner is available
25+
assert.notEqual(hre.tasks.getTask(["test", "mocha"]), undefined);
26+
27+
// This will check that ethers, chai and network helpers are available
28+
await hre.tasks.getTask(["run"]).run({ script: "scripts/script.ts" });
29+
30+
// This will check that the keystore is available
31+
assert.notEqual(hre.tasks.getTask(["keystore", "list"]), undefined);
32+
33+
// This will check that ignition is available
34+
assert.notEqual(hre.tasks.getTask(["ignition"]), undefined);
35+
36+
// This will check that typechain is available
37+
await remove(path.join(process.cwd(), "types")); // Be sure the folder doesn't exist
38+
39+
await hre.tasks.getTask(["build"]).run();
40+
assert.equal(await exists(path.join(process.cwd(), "types")), true);
41+
} finally {
42+
// We need to make sure we remove it, because the generated files
43+
// don't compile with --isolatedDeclarations and otherwise break the
44+
// build process
45+
if (await exists(path.join(process.cwd(), "types"))) {
46+
await remove(path.join(process.cwd(), "types"));
47+
}
48+
}
3849
});
3950
});
4051
});

0 commit comments

Comments
 (0)