Skip to content

Commit 38b2dc1

Browse files
authored
Merge pull request #5423 from NomicFoundation/fix-test-runner-integration-tests
Make the test reporter's integration tests more robust across node versions
2 parents 733fa6a + 48f0862 commit 38b2dc1

File tree

1 file changed

+16
-6
lines changed
  • v-next/hardhat-node-test-reporter/integration-tests

1 file changed

+16
-6
lines changed

v-next/hardhat-node-test-reporter/integration-tests/index.ts

+16-6
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,20 @@ for (const entry of readdirSync(import.meta.dirname + "/fixture-tests")) {
6060
}
6161

6262
function normalizeOutputs(output: string): string {
63-
return output
64-
.replace(/\(\d+ms\)/, "(Xms)")
65-
.replaceAll("\r\n", "\n")
66-
.replaceAll(/\(.*?:\d+:\d+\)/g, (match) => {
67-
return match.replaceAll(path.sep, "/");
68-
});
63+
return (
64+
output
65+
// Normalize the time it took to run the test
66+
.replace(/\(\d+ms\)/, "(Xms)")
67+
// Normalize windows new lines
68+
.replaceAll("\r\n", "\n")
69+
// Normalize path separators to `/` within the (file:line:column)
70+
// part of the stack traces
71+
.replaceAll(/\(.*?:\d+:\d+\)/g, (match) => {
72+
return match.replaceAll(path.sep, "/");
73+
})
74+
// Remove lines like `at TestHook.run (node:internal/test_runner/test:1107:18)`
75+
.replaceAll(/at .*? \(node\:.*?:\d+:\d+\)/g, "")
76+
// Remove lines like `at node:internal/test_runner/test:776:20`
77+
.replaceAll(/at node\:.*?:\d+:\d+/g, "")
78+
);
6979
}

0 commit comments

Comments
 (0)