diff --git a/v-next/hardhat-node-test-reporter/.gitignore b/v-next/hardhat-node-test-reporter/.gitignore
index c92f217185..40457ca310 100644
--- a/v-next/hardhat-node-test-reporter/.gitignore
+++ b/v-next/hardhat-node-test-reporter/.gitignore
@@ -6,3 +6,5 @@
# pnpm deploy output
/bundle
+
+/integration-tests/fixture-tests/*/result.actual.txt
diff --git a/v-next/hardhat-node-test-reporter/integration-tests/fixture-tests/execution-failure-test/result.svg b/v-next/hardhat-node-test-reporter/integration-tests/fixture-tests/execution-failure-test/result.svg
new file mode 100644
index 0000000000..603d949990
--- /dev/null
+++ b/v-next/hardhat-node-test-reporter/integration-tests/fixture-tests/execution-failure-test/result.svg
@@ -0,0 +1,103 @@
+
+
diff --git a/v-next/hardhat-node-test-reporter/integration-tests/fixture-tests/execution-failure-test/result.txt b/v-next/hardhat-node-test-reporter/integration-tests/fixture-tests/execution-failure-test/result.txt
new file mode 100644
index 0000000000..2cb3c1bbb9
--- /dev/null
+++ b/v-next/hardhat-node-test-reporter/integration-tests/fixture-tests/execution-failure-test/result.txt
@@ -0,0 +1,12 @@
+
+ [31m1) integration-tests/fixture-tests/execution-failure-test/test.ts[39m [31m[3m(101ms)[23m[39m
+
+
+[32m0 passing[39m[90m (131ms)[39m[31m[39m
+[31m1 failing[39m
+
+ 1) integration-tests/fixture-tests/execution-failure-test/test.ts:
+
+ [31mTest file execution failed (exit code 1).[39m
+ [90m Did you forget to await a promise?[39m
+
diff --git a/v-next/hardhat-node-test-reporter/integration-tests/fixture-tests/execution-failure-test/test.ts b/v-next/hardhat-node-test-reporter/integration-tests/fixture-tests/execution-failure-test/test.ts
new file mode 100644
index 0000000000..d25f8b7f7b
--- /dev/null
+++ b/v-next/hardhat-node-test-reporter/integration-tests/fixture-tests/execution-failure-test/test.ts
@@ -0,0 +1 @@
+throw new Error("error");
diff --git a/v-next/hardhat-node-test-reporter/integration-tests/fixture-tests/nested-test/result.svg b/v-next/hardhat-node-test-reporter/integration-tests/fixture-tests/nested-test/result.svg
index 4701b7a7fa..eab57c06f5 100644
--- a/v-next/hardhat-node-test-reporter/integration-tests/fixture-tests/nested-test/result.svg
+++ b/v-next/hardhat-node-test-reporter/integration-tests/fixture-tests/nested-test/result.svg
@@ -1,766 +1,1588 @@
-
diff --git a/v-next/hardhat-node-test-reporter/integration-tests/fixture-tests/nested-test/result.txt b/v-next/hardhat-node-test-reporter/integration-tests/fixture-tests/nested-test/result.txt
index 47bd78bfe8..a59744154c 100644
--- a/v-next/hardhat-node-test-reporter/integration-tests/fixture-tests/nested-test/result.txt
+++ b/v-next/hardhat-node-test-reporter/integration-tests/fixture-tests/nested-test/result.txt
@@ -4,10 +4,23 @@
[90m[32m✔[39m[90m nested test[39m
[31m1) assertion error in nested test[39m
[31m2) error with cause in nested test[39m
+ level 0
+ level 1
+ level 2
+ [90m[32m✔[39m[90m nested test[39m
+ [31m3) assertion error in nested test[39m
+ [31m4) error with cause in nested test[39m
+ [90m[32m✔[39m[90m unawaited test[39m
+ [31m5) level 2[39m
-[32m1 passing[39m[90m (118ms)[39m[31m[39m
-[31m2 failing[39m
+ [31m6) level 1[39m
+
+ [31m7) level 0[39m
+
+
+[32m3 passing[39m[90m (145ms)[39m[31m[39m
+[31m7 failing[39m
1) level 0
level 1
@@ -22,15 +35,15 @@
[31m+ 1[39m
[90m at TestContext. (integration-tests/fixture-tests/nested-test/test.ts:12:16)[39m
- [90m at Test.runInAsyncScope (node:async_hooks:211:14)[39m
- [90m at Test.run (node:internal/test_runner/test:878:25)[39m
- [90m at Suite.processPendingSubtests (node:internal/test_runner/test:590:18)[39m
- [90m at Test.postRun (node:internal/test_runner/test:974:19)[39m
- [90m at Test.run (node:internal/test_runner/test:917:12)[39m
+ [90m at Test.runInAsyncScope (node:async_hooks:206:9)[39m
+ [90m at Test.run (node:internal/test_runner/test:856:25)[39m
+ [90m at Suite.processPendingSubtests (node:internal/test_runner/test:565:18)[39m
+ [90m at Test.postRun (node:internal/test_runner/test:955:19)[39m
+ [90m at Test.run (node:internal/test_runner/test:898:12)[39m
[90m at async Promise.all (index 0)[39m
- [90m at async Suite.run (node:internal/test_runner/test:1239:7)[39m
+ [90m at async Suite.run (node:internal/test_runner/test:1217:7)[39m
[90m at async Promise.all (index 0)[39m
- [90m at async Suite.run (node:internal/test_runner/test:1239:7) {[39m
+ [90m at async Suite.run (node:internal/test_runner/test:1217:7) {[39m
[90m generatedMessage: true,[39m
[90m code: 'ERR_ASSERTION',[39m
[90m actual: 1,[39m
@@ -45,16 +58,114 @@
[31mError: error with cause[39m
[90m at TestContext. (integration-tests/fixture-tests/nested-test/test.ts:16:15)[39m
- [90m at Test.runInAsyncScope (node:async_hooks:211:14)[39m
+ [90m at Test.runInAsyncScope (node:async_hooks:206:9)[39m
[90m ... 4 lines matching cause stack trace ...[39m
- [90m at async Suite.processPendingSubtests (node:internal/test_runner/test:590:7) {[39m
+ [90m at async Suite.processPendingSubtests (node:internal/test_runner/test:565:7) {[39m
[90m [cause]: Error: cause[39m
[90m at TestContext. (integration-tests/fixture-tests/nested-test/test.ts:17:18)[39m
- [90m at Test.runInAsyncScope (node:async_hooks:211:14)[39m
- [90m at Test.run (node:internal/test_runner/test:878:25)[39m
- [90m at Suite.processPendingSubtests (node:internal/test_runner/test:590:18)[39m
- [90m at Test.postRun (node:internal/test_runner/test:974:19)[39m
- [90m at Test.run (node:internal/test_runner/test:917:12)[39m
- [90m at async Suite.processPendingSubtests (node:internal/test_runner/test:590:7)[39m
+ [90m at Test.runInAsyncScope (node:async_hooks:206:9)[39m
+ [90m at Test.run (node:internal/test_runner/test:856:25)[39m
+ [90m at Suite.processPendingSubtests (node:internal/test_runner/test:565:18)[39m
+ [90m at Test.postRun (node:internal/test_runner/test:955:19)[39m
+ [90m at Test.run (node:internal/test_runner/test:898:12)[39m
+ [90m at async Suite.processPendingSubtests (node:internal/test_runner/test:565:7)[39m
+ [90m}[39m
+
+ 3) level 0
+ level 1
+ level 2
+ level 0
+ level 1
+ level 2
+ assertion error in nested test:
+
+ [31mAssertionError: Expected values to be strictly equal[39m
+ [32m- Expected[39m
+ [31m+ Received[39m
+
+ [32m- 2[39m
+ [31m+ 1[39m
+
+ [90m at TestContext. (integration-tests/fixture-tests/nested-test/test.ts:29:22)[39m
+ [90m at Test.runInAsyncScope (node:async_hooks:206:9)[39m
+ [90m at Test.run (node:internal/test_runner/test:856:25)[39m
+ [90m at Test.start (node:internal/test_runner/test:753:17)[39m
+ [90m at startSubtest (node:internal/test_runner/harness:252:17)[39m
+ [90m at run (node:internal/test_runner/harness:260:14)[39m
+ [90m at test (node:internal/test_runner/harness:271:12)[39m
+ [90m at TestContext. (integration-tests/fixture-tests/nested-test/test.ts:28:19)[39m
+ [90m at async Test.run (node:internal/test_runner/test:857:9)[39m
+ [90m at async startSubtest (node:internal/test_runner/harness:252:3) {[39m
+ [90m generatedMessage: true,[39m
+ [90m code: 'ERR_ASSERTION',[39m
+ [90m actual: 1,[39m
+ [90m expected: 2,[39m
+ [90m operator: 'strictEqual'[39m
+ [90m}[39m
+
+ 4) level 0
+ level 1
+ level 2
+ level 0
+ level 1
+ level 2
+ error with cause in nested test:
+
+ [31mError: error with cause[39m
+ [90m at TestContext. (integration-tests/fixture-tests/nested-test/test.ts:33:21)[39m
+ [90m at Test.runInAsyncScope (node:async_hooks:206:9)[39m
+ [90m ... 7 lines matching cause stack trace ...[39m
+ [90m at async startSubtest (node:internal/test_runner/harness:252:3) {[39m
+ [90m [cause]: Error: cause[39m
+ [90m at TestContext. (integration-tests/fixture-tests/nested-test/test.ts:34:24)[39m
+ [90m at Test.runInAsyncScope (node:async_hooks:206:9)[39m
+ [90m at Test.run (node:internal/test_runner/test:856:25)[39m
+ [90m at Test.start (node:internal/test_runner/test:753:17)[39m
+ [90m at startSubtest (node:internal/test_runner/harness:252:17)[39m
+ [90m at run (node:internal/test_runner/harness:260:14)[39m
+ [90m at test (node:internal/test_runner/harness:271:12)[39m
+ [90m at TestContext. (integration-tests/fixture-tests/nested-test/test.ts:32:19)[39m
+ [90m at async Test.run (node:internal/test_runner/test:857:9)[39m
+ [90m at async startSubtest (node:internal/test_runner/harness:252:3)[39m
+ [90m}[39m
+
+ 5) level 0
+ level 1
+ level 2
+ level 0
+ level 1
+ level 2:
+
+ [31mError [ERR_TEST_FAILURE]: 2 subtests failed[39m
+ [90m at async TestContext. (integration-tests/fixture-tests/nested-test/test.ts:1:424)[39m
+ [90m at async TestContext. (integration-tests/fixture-tests/nested-test/test.ts:1:395) {[39m
+ [90m code: 'ERR_TEST_FAILURE',[39m
+ [90m failureType: 'subtestsFailed',[39m
+ [90m cause: '2 subtests failed'[39m
+ [90m}[39m
+
+ 6) level 0
+ level 1
+ level 2
+ level 0
+ level 1:
+
+ [31mError [ERR_TEST_FAILURE]: 1 subtest failed[39m
+ [90m at async TestContext. (integration-tests/fixture-tests/nested-test/test.ts:1:395) {[39m
+ [90m code: 'ERR_TEST_FAILURE',[39m
+ [90m failureType: 'subtestsFailed',[39m
+ [90m cause: '1 subtest failed'[39m
+ [90m}[39m
+
+ 7) level 0
+ level 1
+ level 2
+ level 0:
+
+ [31m[Error [ERR_TEST_FAILURE]: 1 subtest failed[39m
+ [90m] {[39m
+ [90m code: 'ERR_TEST_FAILURE',[39m
+ [90m failureType: 'subtestsFailed',[39m
+ [90m cause: '1 subtest failed'[39m
[90m}[39m
diff --git a/v-next/hardhat-node-test-reporter/integration-tests/fixture-tests/nested-test/test.ts b/v-next/hardhat-node-test-reporter/integration-tests/fixture-tests/nested-test/test.ts
index 4dea1a4fae..7b97ef035b 100644
--- a/v-next/hardhat-node-test-reporter/integration-tests/fixture-tests/nested-test/test.ts
+++ b/v-next/hardhat-node-test-reporter/integration-tests/fixture-tests/nested-test/test.ts
@@ -17,6 +17,30 @@ describe("level 0", () => {
cause: new Error("cause"),
});
});
+
+ it("level 0", async () => {
+ await it("level 1", async () => {
+ await it("level 2", async () => {
+ await it("nested test", async () => {
+ assert.equal(1, 1);
+ });
+
+ await it("assertion error in nested test", async () => {
+ assert.equal(1, 2);
+ });
+
+ await it("error with cause in nested test", async () => {
+ throw new Error("error with cause", {
+ cause: new Error("cause"),
+ });
+ });
+
+ it("unawaited test", async () => {
+ assert.equal(1, 1);
+ });
+ });
+ });
+ });
});
});
});
diff --git a/v-next/hardhat-node-test-reporter/integration-tests/fixture-tests/only-test-with-the-flag/options.json b/v-next/hardhat-node-test-reporter/integration-tests/fixture-tests/only-test-with-the-flag/options.json
new file mode 100644
index 0000000000..f6643f98cd
--- /dev/null
+++ b/v-next/hardhat-node-test-reporter/integration-tests/fixture-tests/only-test-with-the-flag/options.json
@@ -0,0 +1,3 @@
+{
+ "only": true
+}
diff --git a/v-next/hardhat-node-test-reporter/integration-tests/fixture-tests/only-test-with-the-flag/result.svg b/v-next/hardhat-node-test-reporter/integration-tests/fixture-tests/only-test-with-the-flag/result.svg
new file mode 100644
index 0000000000..5a9f61d666
--- /dev/null
+++ b/v-next/hardhat-node-test-reporter/integration-tests/fixture-tests/only-test-with-the-flag/result.svg
@@ -0,0 +1,981 @@
+
+
diff --git a/v-next/hardhat-node-test-reporter/integration-tests/fixture-tests/only-test-with-the-flag/result.txt b/v-next/hardhat-node-test-reporter/integration-tests/fixture-tests/only-test-with-the-flag/result.txt
new file mode 100644
index 0000000000..9863af2af0
--- /dev/null
+++ b/v-next/hardhat-node-test-reporter/integration-tests/fixture-tests/only-test-with-the-flag/result.txt
@@ -0,0 +1,92 @@
+
+ [31m1) test only[39m
+
+ describe only
+ [31m2) it[39m
+
+ describe
+ [31m3) it only[39m
+
+
+[32m0 passing[39m[90m (143ms)[39m[31m[39m
+[31m3 failing[39m
+
+ 1) test only:
+
+ [31mAssertionError: Expected values to be strictly equal[39m
+ [32m- Expected[39m
+ [31m+ Received[39m
+
+ [32m- 2[39m
+ [31m+ 1[39m
+
+ [90m at TestContext. (integration-tests/fixture-tests/only-test-with-the-flag/test.ts:10:10)[39m
+ [90m at Test.runInAsyncScope (node:async_hooks:206:9)[39m
+ [90m at Test.run (node:internal/test_runner/test:856:25)[39m
+ [90m at Test.processPendingSubtests (node:internal/test_runner/test:565:18)[39m
+ [90m at Test.postRun (node:internal/test_runner/test:955:19)[39m
+ [90m at node:internal/test_runner/test:792:31[39m
+ [90m at node:internal/process/task_queues:140:7[39m
+ [90m at AsyncResource.runInAsyncScope (node:async_hooks:206:9)[39m
+ [90m at AsyncResource.runMicrotask (node:internal/process/task_queues:137:8) {[39m
+ [90m generatedMessage: true,[39m
+ [90m code: 'ERR_ASSERTION',[39m
+ [90m actual: 1,[39m
+ [90m expected: 2,[39m
+ [90m operator: 'strictEqual'[39m
+ [90m}[39m
+
+ 2) describe only
+ it:
+
+ [31mAssertionError: Expected values to be strictly equal[39m
+ [32m- Expected[39m
+ [31m+ Received[39m
+
+ [32m- 2[39m
+ [31m+ 1[39m
+
+ [90m at TestContext. (integration-tests/fixture-tests/only-test-with-the-flag/test.ts:16:12)[39m
+ [90m at Test.runInAsyncScope (node:async_hooks:206:9)[39m
+ [90m at Test.run (node:internal/test_runner/test:856:25)[39m
+ [90m at Test.start (node:internal/test_runner/test:753:17)[39m
+ [90m at node:internal/test_runner/test:1215:71[39m
+ [90m at node:internal/per_context/primordials:488:82[39m
+ [90m at new Promise ()[39m
+ [90m at new SafePromise (node:internal/per_context/primordials:456:29)[39m
+ [90m at node:internal/per_context/primordials:488:9[39m
+ [90m at Array.map () {[39m
+ [90m generatedMessage: true,[39m
+ [90m code: 'ERR_ASSERTION',[39m
+ [90m actual: 1,[39m
+ [90m expected: 2,[39m
+ [90m operator: 'strictEqual'[39m
+ [90m}[39m
+
+ 3) describe
+ it only:
+
+ [31mAssertionError: Expected values to be strictly equal[39m
+ [32m- Expected[39m
+ [31m+ Received[39m
+
+ [32m- 2[39m
+ [31m+ 1[39m
+
+ [90m at TestContext. (integration-tests/fixture-tests/only-test-with-the-flag/test.ts:23:12)[39m
+ [90m at Test.runInAsyncScope (node:async_hooks:206:9)[39m
+ [90m at Test.run (node:internal/test_runner/test:856:25)[39m
+ [90m at Test.start (node:internal/test_runner/test:753:17)[39m
+ [90m at node:internal/test_runner/test:1215:71[39m
+ [90m at node:internal/per_context/primordials:488:82[39m
+ [90m at new Promise ()[39m
+ [90m at new SafePromise (node:internal/per_context/primordials:456:29)[39m
+ [90m at node:internal/per_context/primordials:488:9[39m
+ [90m at Array.map () {[39m
+ [90m generatedMessage: true,[39m
+ [90m code: 'ERR_ASSERTION',[39m
+ [90m actual: 1,[39m
+ [90m expected: 2,[39m
+ [90m operator: 'strictEqual'[39m
+ [90m}[39m
+
diff --git a/v-next/hardhat-node-test-reporter/integration-tests/fixture-tests/only-test-with-the-flag/test.ts b/v-next/hardhat-node-test-reporter/integration-tests/fixture-tests/only-test-with-the-flag/test.ts
new file mode 100644
index 0000000000..a3a0383669
--- /dev/null
+++ b/v-next/hardhat-node-test-reporter/integration-tests/fixture-tests/only-test-with-the-flag/test.ts
@@ -0,0 +1,29 @@
+import assert from "node:assert/strict";
+import { describe, it, test } from "node:test";
+
+test("test", async () => {
+ assert.equal(1, 1);
+});
+
+/* eslint-disable-next-line no-only-tests/no-only-tests -- testing test.only explicitly */
+test.only("test only", async () => {
+ assert.equal(1, 2);
+});
+
+// eslint-disable-next-line no-only-tests/no-only-tests -- testing describe.only explicitly
+describe.only("describe only", async () => {
+ it("it", async () => {
+ assert.equal(1, 2);
+ });
+});
+
+describe("describe", async () => {
+ // eslint-disable-next-line no-only-tests/no-only-tests -- testing it.only explicitly
+ it.only("it only", async () => {
+ assert.equal(1, 2);
+ });
+
+ it("it", async () => {
+ assert.equal(1, 1);
+ });
+});
diff --git a/v-next/hardhat-node-test-reporter/integration-tests/fixture-tests/only-test-without-the-flag/result.svg b/v-next/hardhat-node-test-reporter/integration-tests/fixture-tests/only-test-without-the-flag/result.svg
new file mode 100644
index 0000000000..23e9e37af6
--- /dev/null
+++ b/v-next/hardhat-node-test-reporter/integration-tests/fixture-tests/only-test-without-the-flag/result.svg
@@ -0,0 +1,1032 @@
+
+
diff --git a/v-next/hardhat-node-test-reporter/integration-tests/fixture-tests/only-test-without-the-flag/result.txt b/v-next/hardhat-node-test-reporter/integration-tests/fixture-tests/only-test-without-the-flag/result.txt
new file mode 100644
index 0000000000..3abf0e4498
--- /dev/null
+++ b/v-next/hardhat-node-test-reporter/integration-tests/fixture-tests/only-test-without-the-flag/result.txt
@@ -0,0 +1,96 @@
+
+ [90m[32m✔[39m[90m test[39m
+
+ [31m1) test only[39m
+
+ describe only
+ [31m2) it[39m
+
+ describe
+ [31m3) it only[39m
+ [90m[32m✔[39m[90m it[39m
+
+
+[32m2 passing[39m[90m (185ms)[39m[31m[39m
+[31m3 failing[39m
+[34mℹ[39m 'only' and 'runOnly' require the --test-only command-line option.
+[34mℹ[39m 'only' and 'runOnly' require the --test-only command-line option.
+[34mℹ[39m 'only' and 'runOnly' require the --test-only command-line option.
+
+ 1) test only:
+
+ [31mAssertionError: Expected values to be strictly equal[39m
+ [32m- Expected[39m
+ [31m+ Received[39m
+
+ [32m- 2[39m
+ [31m+ 1[39m
+
+ [90m at TestContext. (integration-tests/fixture-tests/only-test-without-the-flag/test.ts:10:10)[39m
+ [90m at Test.runInAsyncScope (node:async_hooks:206:9)[39m
+ [90m at Test.run (node:internal/test_runner/test:856:25)[39m
+ [90m at Test.processPendingSubtests (node:internal/test_runner/test:565:18)[39m
+ [90m at Test.postRun (node:internal/test_runner/test:955:19)[39m
+ [90m at Test.run (node:internal/test_runner/test:898:12)[39m
+ [90m at async Test.processPendingSubtests (node:internal/test_runner/test:565:7) {[39m
+ [90m generatedMessage: true,[39m
+ [90m code: 'ERR_ASSERTION',[39m
+ [90m actual: 1,[39m
+ [90m expected: 2,[39m
+ [90m operator: 'strictEqual'[39m
+ [90m}[39m
+
+ 2) describe only
+ it:
+
+ [31mAssertionError: Expected values to be strictly equal[39m
+ [32m- Expected[39m
+ [31m+ Received[39m
+
+ [32m- 2[39m
+ [31m+ 1[39m
+
+ [90m at TestContext. (integration-tests/fixture-tests/only-test-without-the-flag/test.ts:16:12)[39m
+ [90m at Test.runInAsyncScope (node:async_hooks:206:9)[39m
+ [90m at Test.run (node:internal/test_runner/test:856:25)[39m
+ [90m at Test.start (node:internal/test_runner/test:753:17)[39m
+ [90m at node:internal/test_runner/test:1215:71[39m
+ [90m at node:internal/per_context/primordials:488:82[39m
+ [90m at new Promise ()[39m
+ [90m at new SafePromise (node:internal/per_context/primordials:456:29)[39m
+ [90m at node:internal/per_context/primordials:488:9[39m
+ [90m at Array.map () {[39m
+ [90m generatedMessage: true,[39m
+ [90m code: 'ERR_ASSERTION',[39m
+ [90m actual: 1,[39m
+ [90m expected: 2,[39m
+ [90m operator: 'strictEqual'[39m
+ [90m}[39m
+
+ 3) describe
+ it only:
+
+ [31mAssertionError: Expected values to be strictly equal[39m
+ [32m- Expected[39m
+ [31m+ Received[39m
+
+ [32m- 2[39m
+ [31m+ 1[39m
+
+ [90m at TestContext. (integration-tests/fixture-tests/only-test-without-the-flag/test.ts:23:12)[39m
+ [90m at Test.runInAsyncScope (node:async_hooks:206:9)[39m
+ [90m at Test.run (node:internal/test_runner/test:856:25)[39m
+ [90m at Test.start (node:internal/test_runner/test:753:17)[39m
+ [90m at node:internal/test_runner/test:1215:71[39m
+ [90m at node:internal/per_context/primordials:488:82[39m
+ [90m at new Promise ()[39m
+ [90m at new SafePromise (node:internal/per_context/primordials:456:29)[39m
+ [90m at node:internal/per_context/primordials:488:9[39m
+ [90m at Array.map () {[39m
+ [90m generatedMessage: true,[39m
+ [90m code: 'ERR_ASSERTION',[39m
+ [90m actual: 1,[39m
+ [90m expected: 2,[39m
+ [90m operator: 'strictEqual'[39m
+ [90m}[39m
+
diff --git a/v-next/hardhat-node-test-reporter/integration-tests/fixture-tests/only-test-without-the-flag/test.ts b/v-next/hardhat-node-test-reporter/integration-tests/fixture-tests/only-test-without-the-flag/test.ts
new file mode 100644
index 0000000000..a3a0383669
--- /dev/null
+++ b/v-next/hardhat-node-test-reporter/integration-tests/fixture-tests/only-test-without-the-flag/test.ts
@@ -0,0 +1,29 @@
+import assert from "node:assert/strict";
+import { describe, it, test } from "node:test";
+
+test("test", async () => {
+ assert.equal(1, 1);
+});
+
+/* eslint-disable-next-line no-only-tests/no-only-tests -- testing test.only explicitly */
+test.only("test only", async () => {
+ assert.equal(1, 2);
+});
+
+// eslint-disable-next-line no-only-tests/no-only-tests -- testing describe.only explicitly
+describe.only("describe only", async () => {
+ it("it", async () => {
+ assert.equal(1, 2);
+ });
+});
+
+describe("describe", async () => {
+ // eslint-disable-next-line no-only-tests/no-only-tests -- testing it.only explicitly
+ it.only("it only", async () => {
+ assert.equal(1, 2);
+ });
+
+ it("it", async () => {
+ assert.equal(1, 1);
+ });
+});
diff --git a/v-next/hardhat-node-test-reporter/integration-tests/fixture-tests/only-test/result.svg b/v-next/hardhat-node-test-reporter/integration-tests/fixture-tests/only-test/result.svg
deleted file mode 100644
index 120950f0d3..0000000000
--- a/v-next/hardhat-node-test-reporter/integration-tests/fixture-tests/only-test/result.svg
+++ /dev/null
@@ -1,425 +0,0 @@
-
-
diff --git a/v-next/hardhat-node-test-reporter/integration-tests/fixture-tests/only-test/result.txt b/v-next/hardhat-node-test-reporter/integration-tests/fixture-tests/only-test/result.txt
deleted file mode 100644
index 6aaeea13f9..0000000000
--- a/v-next/hardhat-node-test-reporter/integration-tests/fixture-tests/only-test/result.txt
+++ /dev/null
@@ -1,32 +0,0 @@
-
- [31m1) top level test[39m
-
-
-[32m0 passing[39m[90m (116ms)[39m[31m[39m
-[31m1 failing[39m
-[34mℹ[39m 'only' and 'runOnly' require the --test-only command-line option.
-
- 1) top level test:
-
- [31mAssertionError: Expected values to be strictly equal[39m
- [32m- Expected[39m
- [31m+ Received[39m
-
- [32m- 2[39m
- [31m+ 1[39m
-
- [90m at TestContext. (integration-tests/fixture-tests/only-test/test.ts:6:10)[39m
- [90m at Test.runInAsyncScope (node:async_hooks:211:14)[39m
- [90m at Test.run (node:internal/test_runner/test:878:25)[39m
- [90m at Test.processPendingSubtests (node:internal/test_runner/test:590:18)[39m
- [90m at node:internal/test_runner/harness:252:20[39m
- [90m at node:internal/process/task_queues:151:7[39m
- [90m at AsyncResource.runInAsyncScope (node:async_hooks:211:14)[39m
- [90m at AsyncResource.runMicrotask (node:internal/process/task_queues:148:8) {[39m
- [90m generatedMessage: true,[39m
- [90m code: 'ERR_ASSERTION',[39m
- [90m actual: 1,[39m
- [90m expected: 2,[39m
- [90m operator: 'strictEqual'[39m
- [90m}[39m
-
diff --git a/v-next/hardhat-node-test-reporter/integration-tests/fixture-tests/only-test/test.ts b/v-next/hardhat-node-test-reporter/integration-tests/fixture-tests/only-test/test.ts
deleted file mode 100644
index 1146ef3bf4..0000000000
--- a/v-next/hardhat-node-test-reporter/integration-tests/fixture-tests/only-test/test.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-import assert from "node:assert/strict";
-import { test } from "node:test";
-
-/* eslint-disable-next-line no-only-tests/no-only-tests -- testing test.only explicitly */
-test.only("top level test", async () => {
- assert.equal(1, 2);
-});
diff --git a/v-next/hardhat-node-test-reporter/integration-tests/fixture-tests/todo-test/result.svg b/v-next/hardhat-node-test-reporter/integration-tests/fixture-tests/todo-test/result.svg
index 6db066da04..69628c4cd1 100644
--- a/v-next/hardhat-node-test-reporter/integration-tests/fixture-tests/todo-test/result.svg
+++ b/v-next/hardhat-node-test-reporter/integration-tests/fixture-tests/todo-test/result.svg
@@ -1,389 +1,345 @@
-
diff --git a/v-next/hardhat-node-test-reporter/integration-tests/fixture-tests/todo-test/result.txt b/v-next/hardhat-node-test-reporter/integration-tests/fixture-tests/todo-test/result.txt
index 0bcac9103b..e24d889d52 100644
--- a/v-next/hardhat-node-test-reporter/integration-tests/fixture-tests/todo-test/result.txt
+++ b/v-next/hardhat-node-test-reporter/integration-tests/fixture-tests/todo-test/result.txt
@@ -1,11 +1,13 @@
- [31m1) top level test[39m
+ [31m1) todo with a callback[39m
+ [34m+ todo without a callback[39m
-[32m0 passing[39m[90m (114ms)[39m[34m[39m
-[34m1 todo[39m
- 1) top level test:
+[32m0 passing[39m[90m (143ms)[39m[34m[39m
+[34m2 todo[39m
+
+ 1) todo with a callback:
[31mAssertionError: Expected values to be strictly equal[39m
[32m- Expected[39m
@@ -15,13 +17,13 @@
[31m+ 1[39m
[90m at TestContext. (integration-tests/fixture-tests/todo-test/test.ts:5:10)[39m
- [90m at Test.runInAsyncScope (node:async_hooks:211:14)[39m
- [90m at Test.run (node:internal/test_runner/test:878:25)[39m
- [90m at Test.processPendingSubtests (node:internal/test_runner/test:590:18)[39m
- [90m at node:internal/test_runner/harness:252:20[39m
- [90m at node:internal/process/task_queues:151:7[39m
- [90m at AsyncResource.runInAsyncScope (node:async_hooks:211:14)[39m
- [90m at AsyncResource.runMicrotask (node:internal/process/task_queues:148:8) {[39m
+ [90m at Test.runInAsyncScope (node:async_hooks:206:9)[39m
+ [90m at Test.run (node:internal/test_runner/test:856:25)[39m
+ [90m at Test.processPendingSubtests (node:internal/test_runner/test:565:18)[39m
+ [90m at node:internal/test_runner/harness:248:12[39m
+ [90m at node:internal/process/task_queues:140:7[39m
+ [90m at AsyncResource.runInAsyncScope (node:async_hooks:206:9)[39m
+ [90m at AsyncResource.runMicrotask (node:internal/process/task_queues:137:8) {[39m
[90m generatedMessage: true,[39m
[90m code: 'ERR_ASSERTION',[39m
[90m actual: 1,[39m
diff --git a/v-next/hardhat-node-test-reporter/integration-tests/fixture-tests/todo-test/test.ts b/v-next/hardhat-node-test-reporter/integration-tests/fixture-tests/todo-test/test.ts
index 1875c39d51..a01cde79fa 100644
--- a/v-next/hardhat-node-test-reporter/integration-tests/fixture-tests/todo-test/test.ts
+++ b/v-next/hardhat-node-test-reporter/integration-tests/fixture-tests/todo-test/test.ts
@@ -1,6 +1,8 @@
import assert from "node:assert/strict";
import { test } from "node:test";
-test.todo("top level test", async () => {
+test.todo("todo with a callback", async () => {
assert.equal(1, 2);
});
+
+test.todo("todo without a callback");
diff --git a/v-next/hardhat-node-test-reporter/integration-tests/fixture-tests/top-level-test/result.svg b/v-next/hardhat-node-test-reporter/integration-tests/fixture-tests/top-level-test/result.svg
index fa8d619977..324923d332 100644
--- a/v-next/hardhat-node-test-reporter/integration-tests/fixture-tests/top-level-test/result.svg
+++ b/v-next/hardhat-node-test-reporter/integration-tests/fixture-tests/top-level-test/result.svg
@@ -1,580 +1,846 @@
-
diff --git a/v-next/hardhat-node-test-reporter/integration-tests/fixture-tests/top-level-test/result.txt b/v-next/hardhat-node-test-reporter/integration-tests/fixture-tests/top-level-test/result.txt
index 4d1adf31d5..b6d28bb034 100644
--- a/v-next/hardhat-node-test-reporter/integration-tests/fixture-tests/top-level-test/result.txt
+++ b/v-next/hardhat-node-test-reporter/integration-tests/fixture-tests/top-level-test/result.txt
@@ -5,9 +5,11 @@
[31m2) error with cause in top level test[39m
+ [31m3) error with nested cause in top level test[39m
-[32m1 passing[39m[90m (120ms)[39m[31m[39m
-[31m2 failing[39m
+
+[32m1 passing[39m[90m (174ms)[39m[31m[39m
+[31m3 failing[39m
1) assertion error in top level test:
@@ -19,12 +21,12 @@
[31m+ 1[39m
[90m at TestContext. (integration-tests/fixture-tests/top-level-test/test.ts:9:10)[39m
- [90m at Test.runInAsyncScope (node:async_hooks:211:14)[39m
- [90m at Test.run (node:internal/test_runner/test:878:25)[39m
- [90m at Test.processPendingSubtests (node:internal/test_runner/test:590:18)[39m
- [90m at Test.postRun (node:internal/test_runner/test:974:19)[39m
- [90m at Test.run (node:internal/test_runner/test:917:12)[39m
- [90m at async Test.processPendingSubtests (node:internal/test_runner/test:590:7) {[39m
+ [90m at Test.runInAsyncScope (node:async_hooks:206:9)[39m
+ [90m at Test.run (node:internal/test_runner/test:856:25)[39m
+ [90m at Test.processPendingSubtests (node:internal/test_runner/test:565:18)[39m
+ [90m at Test.postRun (node:internal/test_runner/test:955:19)[39m
+ [90m at Test.run (node:internal/test_runner/test:898:12)[39m
+ [90m at async Test.processPendingSubtests (node:internal/test_runner/test:565:7) {[39m
[90m generatedMessage: true,[39m
[90m code: 'ERR_ASSERTION',[39m
[90m actual: 1,[39m
@@ -36,16 +38,39 @@
[31mError: error with cause[39m
[90m at TestContext. (integration-tests/fixture-tests/top-level-test/test.ts:13:9)[39m
- [90m at Test.runInAsyncScope (node:async_hooks:211:14)[39m
+ [90m at Test.runInAsyncScope (node:async_hooks:206:9)[39m
[90m ... 4 lines matching cause stack trace ...[39m
- [90m at async Test.processPendingSubtests (node:internal/test_runner/test:590:7) {[39m
+ [90m at async Test.processPendingSubtests (node:internal/test_runner/test:565:7) {[39m
[90m [cause]: Error: cause[39m
[90m at TestContext. (integration-tests/fixture-tests/top-level-test/test.ts:14:12)[39m
- [90m at Test.runInAsyncScope (node:async_hooks:211:14)[39m
- [90m at Test.run (node:internal/test_runner/test:878:25)[39m
- [90m at Test.processPendingSubtests (node:internal/test_runner/test:590:18)[39m
- [90m at Test.postRun (node:internal/test_runner/test:974:19)[39m
- [90m at Test.run (node:internal/test_runner/test:917:12)[39m
- [90m at async Test.processPendingSubtests (node:internal/test_runner/test:590:7)[39m
+ [90m at Test.runInAsyncScope (node:async_hooks:206:9)[39m
+ [90m at Test.run (node:internal/test_runner/test:856:25)[39m
+ [90m at Test.processPendingSubtests (node:internal/test_runner/test:565:18)[39m
+ [90m at Test.postRun (node:internal/test_runner/test:955:19)[39m
+ [90m at Test.run (node:internal/test_runner/test:898:12)[39m
+ [90m at async Test.processPendingSubtests (node:internal/test_runner/test:565:7)[39m
+ [90m}[39m
+
+ 3) error with nested cause in top level test:
+
+ [31mError: error with cause[39m
+ [90m at TestContext. (integration-tests/fixture-tests/top-level-test/test.ts:19:9)[39m
+ [90m at Test.runInAsyncScope (node:async_hooks:206:9)[39m
+ [90m ... 4 lines matching cause stack trace ...[39m
+ [90m at async Test.processPendingSubtests (node:internal/test_runner/test:565:7) {[39m
+ [90m [cause]: Error: cause[39m
+ [90m at TestContext. (integration-tests/fixture-tests/top-level-test/test.ts:20:12)[39m
+ [90m at Test.runInAsyncScope (node:async_hooks:206:9)[39m
+ [90m ... 4 lines matching cause stack trace ...[39m
+ [90m at async Test.processPendingSubtests (node:internal/test_runner/test:565:7) {[39m
+ [90m [cause]: Error: nested cause[39m
+ [90m at TestContext. (integration-tests/fixture-tests/top-level-test/test.ts:21:14)[39m
+ [90m at Test.runInAsyncScope (node:async_hooks:206:9)[39m
+ [90m at Test.run (node:internal/test_runner/test:856:25)[39m
+ [90m at Test.processPendingSubtests (node:internal/test_runner/test:565:18)[39m
+ [90m at Test.postRun (node:internal/test_runner/test:955:19)[39m
+ [90m at Test.run (node:internal/test_runner/test:898:12)[39m
+ [90m at async Test.processPendingSubtests (node:internal/test_runner/test:565:7)[39m
+ [90m }[39m
[90m}[39m
diff --git a/v-next/hardhat-node-test-reporter/integration-tests/fixture-tests/top-level-test/test.ts b/v-next/hardhat-node-test-reporter/integration-tests/fixture-tests/top-level-test/test.ts
index 356e4ebc22..287eaf7cac 100644
--- a/v-next/hardhat-node-test-reporter/integration-tests/fixture-tests/top-level-test/test.ts
+++ b/v-next/hardhat-node-test-reporter/integration-tests/fixture-tests/top-level-test/test.ts
@@ -14,3 +14,11 @@ test("error with cause in top level test", async () => {
cause: new Error("cause"),
});
});
+
+test("error with nested cause in top level test", async () => {
+ throw new Error("error with cause", {
+ cause: new Error("cause", {
+ cause: new Error("nested cause"),
+ }),
+ });
+});
diff --git a/v-next/hardhat-node-test-reporter/integration-tests/index.ts b/v-next/hardhat-node-test-reporter/integration-tests/index.ts
index 6ae43a5008..394c09ec15 100644
--- a/v-next/hardhat-node-test-reporter/integration-tests/index.ts
+++ b/v-next/hardhat-node-test-reporter/integration-tests/index.ts
@@ -1,4 +1,10 @@
-import { readFileSync, readdirSync, statSync } from "node:fs";
+import {
+ existsSync,
+ readFileSync,
+ readdirSync,
+ statSync,
+ writeFileSync,
+} from "node:fs";
import path from "node:path";
import { run } from "node:test";
@@ -56,10 +62,17 @@ for (const entry of entries) {
const outputChunks = [];
+ let options = {};
+ const optionsPath = path.join(entryPath, "options.json");
+ if (existsSync(optionsPath)) {
+ options = JSON.parse(readFileSync(optionsPath, "utf8"));
+ }
+
// We disable github actions annotations, as they are misleading on PRs
// otherwise.
process.env.NO_GITHUB_ACTIONS_ANNOTATIONS = "true";
const reporterStream = run({
+ ...options,
files: testFiles,
}).compose(reporter);
@@ -67,7 +80,14 @@ for (const entry of entries) {
outputChunks.push(chunk);
}
- const output = outputChunks.join("");
+ // We're removing lines until the one that starts with "Node.js" because
+ // that part of the output is not controlled by the reporter.
+ const lines = outputChunks.join("").split("\n");
+ const start = lines.findIndex((l) => l.startsWith("Node.js"));
+ const output = lines.slice(start + 1).join("\n");
+
+ // We're saving the actual outptu in case one needs to access it. It is .gitignored.
+ writeFileSync(entryPath + "/result.actual.txt", output);
const expectedOutput = readFileSync(entryPath + "/result.txt", "utf8");
const normalizedOutput = normalizeOutputs(output);
@@ -107,8 +127,8 @@ function normalizeOutputs(output: string): string {
return match.replaceAll(path.sep, "/");
})
// Remove lines like `at TestHook.run (node:internal/test_runner/test:1107:18)`
- .replace(/^.*?at .*? \(node\:.*?:\d+:\d+\).*?$/gm, "")
+ .replace(/^.*?at .*? \(node\:.*?:\d+:\d+\).*?\n/gm, "")
// Remove lines like `at node:internal/test_runner/test:776:20`
- .replace(/^.*?at node\:.*?:\d+:\d+.*?$/gm, "")
+ .replace(/^.*?at (async )?node\:.*?:\d+:\d+.*?\n/gm, "")
);
}
diff --git a/v-next/hardhat-node-test-reporter/scripts/regenerate-fixtures.sh b/v-next/hardhat-node-test-reporter/scripts/regenerate-fixtures.sh
index 949680932a..e81ef3efbb 100755
--- a/v-next/hardhat-node-test-reporter/scripts/regenerate-fixtures.sh
+++ b/v-next/hardhat-node-test-reporter/scripts/regenerate-fixtures.sh
@@ -15,10 +15,27 @@ which wkhtmltoimage > /dev/null 2>&1 || (echo "Please install wkhtmltoimage usin
# If XDG_RUNTIME_DIR is not set, set it to $HOME to avoid a warning from wkhtmltoimage
export XDG_RUNTIME_DIR="${XDG_RUNTIME_DIR:=$HOME}"
-for dir in integration-tests/fixture-tests/**; do
+if [ -n "${1:-}" ]; then
+ dirs="integration-tests/fixture-tests/$1"
+else
+ dirs="integration-tests/fixture-tests/**"
+fi
+
+for dir in $dirs; do
echo "Regenerating fixtures for $dir"
- node --import tsx/esm --test --test-reporter=./dist/src/reporter.js $dir/*.ts --color > $dir/result.txt || true # Ignore failures, as they are expected
+ options=""
+ if [ -f "$dir/options.json" ]; then
+ if [[ "$(jq .only "$dir/options.json")" == "true" ]]; then
+ options="$options --test-only"
+ fi
+ fi
+
+ node --import tsx/esm --test --test-reporter=./dist/src/reporter.js $options $dir/*.ts --color > $dir/result.txt || true # Ignore failures, as they are expected
+
+ if grep -q '^Node\.js' $dir/result.txt; then
+ sed -i '1,/^Node\.js/d' $dir/result.txt;
+ fi
cat $dir/result.txt | aha --black > $dir/result.html;