Skip to content

Commit e9f7484

Browse files
authored
fix: Fully transpile in Mocha tests to correctly inline const enums (#594)
It seems transpile-only transpiles per module, however we need to perform full "compilation" in order to correctly see and inline values for const enums. We use const enums because that's how they are emitted by napi-rs and there's no option to change that. Rather than invest into supporting that or working around it, let's just fully compile the test harness once. See https://www.typescriptlang.org/tsconfig/#isolatedModules for more context.
1 parent eb7b324 commit e9f7484

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

hardhat-tests/.mocharc.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"require": "ts-node/register/transpile-only",
2+
"require": "ts-node/register",
33
"file": "./test/setup.ts",
44
"exclude": [
55
"test/fixture-projects/**/*.ts",

hardhat-tests/test/internal/hardhat-network/stack-traces/test.ts

+3-9
Original file line numberDiff line numberDiff line change
@@ -281,15 +281,9 @@ function compareStackTraces(
281281

282282
// if IR is enabled, we ignore callstack entries in the comparison
283283
if (isViaIR) {
284-
trace = trace.filter((frame) => {
285-
// FIXME: For some reason, the const enum from napi-rs is not picked up by TS
286-
// and we get undefined instead of the actual value. Just use the number.
287-
// eslint-disable-next-line @typescript-eslint/naming-convention
288-
function assertCallstackEntry<_T extends 0>() {}
289-
assertCallstackEntry<StackTraceEntryType.CALLSTACK_ENTRY>();
290-
291-
return frame.type !== 0;
292-
});
284+
trace = trace.filter(
285+
(frame) => frame.type !== StackTraceEntryType.CALLSTACK_ENTRY
286+
);
293287
description = description.filter(
294288
(frame) => frame.type !== "CALLSTACK_ENTRY"
295289
);

0 commit comments

Comments
 (0)