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 @@ + + +Qt Svg Document +Generated with Qt + + + + + + + + + + + + + + + + + + +1) integration-tests/fixture-tests/execution-failure-test/test.ts + + + + + + + +(101ms) + + + +0 passing + + + + (131ms) + + + +1 failing + + + + 1) integration-tests/fixture-tests/execution-failure-test/test.ts: + + + + +Test file execution failed (exit code 1). + + + + + + + + Did you forget to await a promise? + + + 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 @@ + + 1) integration-tests/fixture-tests/execution-failure-test/test.ts (101ms) + + +0 passing (131ms) +1 failing + + 1) integration-tests/fixture-tests/execution-failure-test/test.ts: + + Test file execution failed (exit code 1). +  Did you forget to await a promise? + 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 @@ - -Qt SVG Document +Qt Svg Document Generated with Qt - + + - + - + level 0 + level 1 + level 2 + - + - - + nested test + - - +1) assertion error in nested test - + + + + +2) error with cause in nested test + level 0 + level 1 + level 2 + - - + - - + nested test + - - +3) assertion error in nested test - + + + + +4) error with cause in nested test - + + - - + unawaited test - + + + + - +5) level 2 - + +6) level 1 - - + - +7) level 0 - +3 passing + + + - + (145ms) +7 failing - - + 1) level 0 + level 1 + level 2 + assertion error in nested test: + - +AssertionError: Expected values to be strictly equal + + + + +- Expected + + + + - - ++ Received + + + + + +- 2 + + + - + ++ 1 - - + + - - + at TestContext.<anonymous> (integration-tests/fixture-tests/nested-test/test.ts:12:16) + - - + at Test.runInAsyncScope (node:async_hooks:206:9) - + + + + + at Test.run (node:internal/test_runner/test:856:25) + - - + at Suite.processPendingSubtests (node:internal/test_runner/test:565:18) - + + + + + at Test.postRun (node:internal/test_runner/test:955:19) + - - + at Test.run (node:internal/test_runner/test:898:12) + + + + - + at async Promise.all (index 0) + - + at async Suite.run (node:internal/test_runner/test:1217:7) + + + + + + + + at async Promise.all (index 0) + + + - + + + + + at async Suite.run (node:internal/test_runner/test:1217:7) { + + + + - + generatedMessage: true, - + + + + + code: 'ERR_ASSERTION', + + + + + + + + actual: 1, + + + + + + + + expected: 2, + + + + + + + + operator: 'strictEqual' + + + + + + + +} + + + + 2) level 0 + level 1 + level 2 + error with cause in nested test: + +Error: error with cause + + + + + + + + at TestContext.<anonymous> (integration-tests/fixture-tests/nested-test/test.ts:16:15) + + + + + + + + at Test.runInAsyncScope (node:async_hooks:206:9) + + + + + + + + ... 4 lines matching cause stack trace ... + + + + + + + + at async Suite.processPendingSubtests (node:internal/test_runner/test:565:7) { + + + + + + + + [cause]: Error: cause + + + + + + + + at TestContext.<anonymous> (integration-tests/fixture-tests/nested-test/test.ts:17:18) + + + + + + + + at Test.runInAsyncScope (node:async_hooks:206:9) + + + + + + + + at Test.run (node:internal/test_runner/test:856:25) + + + + + + + + at Suite.processPendingSubtests (node:internal/test_runner/test:565:18) + + + + - - + at Test.postRun (node:internal/test_runner/test:955:19) + + + + + + + + at Test.run (node:internal/test_runner/test:898:12) + + + + + + + + at async Suite.processPendingSubtests (node:internal/test_runner/test:565:7) + + + + + + + +} + + + + 3) level 0 + level 1 + level 2 + level 0 + level 1 + level 2 + assertion error in nested test: + - +AssertionError: Expected values to be strictly equal - + +- Expected + + + + + + + ++ Received - - + + - +- 2 - + ++ 1 - - + + - - + at TestContext.<anonymous> (integration-tests/fixture-tests/nested-test/test.ts:29:22) - + + + + + at Test.runInAsyncScope (node:async_hooks:206:9) - + - + at Test.run (node:internal/test_runner/test:856:25) - - + - - + at Test.start (node:internal/test_runner/test:753:17) - + - + at startSubtest (node:internal/test_runner/harness:252:17) - - + - - + at run (node:internal/test_runner/harness:260:14) - + + + + + at test (node:internal/test_runner/harness:271:12) + + + + - + at TestContext.<anonymous> (integration-tests/fixture-tests/nested-test/test.ts:28:19) + + + + - + at async Test.run (node:internal/test_runner/test:857:9) + + + + - + at async startSubtest (node:internal/test_runner/harness:252:3) { - + + + + + generatedMessage: true, + + + + - + code: 'ERR_ASSERTION', - + + + + + actual: 1, - + + + + + expected: 2, - + + + + + operator: 'strictEqual' + + + + +} + + + + 4) level 0 + level 1 + level 2 + level 0 + level 1 + level 2 + error with cause in nested test: + + + + - +Error: error with cause + + + + - + at TestContext.<anonymous> (integration-tests/fixture-tests/nested-test/test.ts:33:21) - + + + + + at Test.runInAsyncScope (node:async_hooks:206:9) - + + + + + ... 7 lines matching cause stack trace ... + + + + - + at async startSubtest (node:internal/test_runner/harness:252:3) { + + + + - + [cause]: Error: cause + + + + - + at TestContext.<anonymous> (integration-tests/fixture-tests/nested-test/test.ts:34:24) + + + + - + at Test.runInAsyncScope (node:async_hooks:206:9) + - - + at Test.run (node:internal/test_runner/test:856:25) - + + + + + at Test.start (node:internal/test_runner/test:753:17) + - - + at startSubtest (node:internal/test_runner/harness:252:17) - + + + + + at run (node:internal/test_runner/harness:260:14) + - - + at test (node:internal/test_runner/harness:271:12) + + + + - + at TestContext.<anonymous> (integration-tests/fixture-tests/nested-test/test.ts:32:19) + - - + at async Test.run (node:internal/test_runner/test:857:9) + + + + - + at async startSubtest (node:internal/test_runner/harness:252:3) + + + + - +} + + + + 5) level 0 + level 1 + level 2 + level 0 + level 1 + level 2: + +Error [ERR_TEST_FAILURE]: 2 subtests failed - - + - - + at async TestContext.<anonymous> (integration-tests/fixture-tests/nested-test/test.ts:1:424) - + + + + + at async TestContext.<anonymous> (integration-tests/fixture-tests/nested-test/test.ts:1:395) { + + + + - + code: 'ERR_TEST_FAILURE', - + + + + + failureType: 'subtestsFailed', - + + + + + cause: '2 subtests failed' + + + + - +} + 6) level 0 + level 1 + level 2 + level 0 + level 1: + + + + - +Error [ERR_TEST_FAILURE]: 1 subtest failed + + + + - + at async TestContext.<anonymous> (integration-tests/fixture-tests/nested-test/test.ts:1:395) { - + + + + + code: 'ERR_TEST_FAILURE', + + + + - + failureType: 'subtestsFailed', - + + + + + cause: '1 subtest failed' - + + + + +} - + 7) level 0 + level 1 + level 2 + level 0: + + + + +[Error [ERR_TEST_FAILURE]: 1 subtest failed + + + + + + + +] { + + + + + + + + code: 'ERR_TEST_FAILURE', - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + failureType: 'subtestsFailed', - + - + cause: '1 subtest failed' + + + + - +} 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 @@ ✔ nested test 1) assertion error in nested test 2) error with cause in nested test + level 0 + level 1 + level 2 + ✔ nested test + 3) assertion error in nested test + 4) error with cause in nested test + ✔ unawaited test + 5) level 2 -1 passing (118ms) -2 failing + 6) level 1 + + 7) level 0 + + +3 passing (145ms) +7 failing 1) level 0 level 1 @@ -22,15 +35,15 @@ + 1  at TestContext. (integration-tests/fixture-tests/nested-test/test.ts:12:16) -  at Test.runInAsyncScope (node:async_hooks:211:14) -  at Test.run (node:internal/test_runner/test:878:25) -  at Suite.processPendingSubtests (node:internal/test_runner/test:590:18) -  at Test.postRun (node:internal/test_runner/test:974:19) -  at Test.run (node:internal/test_runner/test:917:12) +  at Test.runInAsyncScope (node:async_hooks:206:9) +  at Test.run (node:internal/test_runner/test:856:25) +  at Suite.processPendingSubtests (node:internal/test_runner/test:565:18) +  at Test.postRun (node:internal/test_runner/test:955:19) +  at Test.run (node:internal/test_runner/test:898:12)  at async Promise.all (index 0) -  at async Suite.run (node:internal/test_runner/test:1239:7) +  at async Suite.run (node:internal/test_runner/test:1217:7)  at async Promise.all (index 0) -  at async Suite.run (node:internal/test_runner/test:1239:7) { +  at async Suite.run (node:internal/test_runner/test:1217:7) {  generatedMessage: true,  code: 'ERR_ASSERTION',  actual: 1, @@ -45,16 +58,114 @@ Error: error with cause  at TestContext. (integration-tests/fixture-tests/nested-test/test.ts:16:15) -  at Test.runInAsyncScope (node:async_hooks:211:14) +  at Test.runInAsyncScope (node:async_hooks:206:9)  ... 4 lines matching cause stack trace ... -  at async Suite.processPendingSubtests (node:internal/test_runner/test:590:7) { +  at async Suite.processPendingSubtests (node:internal/test_runner/test:565:7) {  [cause]: Error: cause  at TestContext. (integration-tests/fixture-tests/nested-test/test.ts:17:18) -  at Test.runInAsyncScope (node:async_hooks:211:14) -  at Test.run (node:internal/test_runner/test:878:25) -  at Suite.processPendingSubtests (node:internal/test_runner/test:590:18) -  at Test.postRun (node:internal/test_runner/test:974:19) -  at Test.run (node:internal/test_runner/test:917:12) -  at async Suite.processPendingSubtests (node:internal/test_runner/test:590:7) +  at Test.runInAsyncScope (node:async_hooks:206:9) +  at Test.run (node:internal/test_runner/test:856:25) +  at Suite.processPendingSubtests (node:internal/test_runner/test:565:18) +  at Test.postRun (node:internal/test_runner/test:955:19) +  at Test.run (node:internal/test_runner/test:898:12) +  at async Suite.processPendingSubtests (node:internal/test_runner/test:565:7) + } + + 3) level 0 + level 1 + level 2 + level 0 + level 1 + level 2 + assertion error in nested test: + + AssertionError: Expected values to be strictly equal + - Expected + + Received + + - 2 + + 1 + +  at TestContext. (integration-tests/fixture-tests/nested-test/test.ts:29:22) +  at Test.runInAsyncScope (node:async_hooks:206:9) +  at Test.run (node:internal/test_runner/test:856:25) +  at Test.start (node:internal/test_runner/test:753:17) +  at startSubtest (node:internal/test_runner/harness:252:17) +  at run (node:internal/test_runner/harness:260:14) +  at test (node:internal/test_runner/harness:271:12) +  at TestContext. (integration-tests/fixture-tests/nested-test/test.ts:28:19) +  at async Test.run (node:internal/test_runner/test:857:9) +  at async startSubtest (node:internal/test_runner/harness:252:3) { +  generatedMessage: true, +  code: 'ERR_ASSERTION', +  actual: 1, +  expected: 2, +  operator: 'strictEqual' + } + + 4) level 0 + level 1 + level 2 + level 0 + level 1 + level 2 + error with cause in nested test: + + Error: error with cause +  at TestContext. (integration-tests/fixture-tests/nested-test/test.ts:33:21) +  at Test.runInAsyncScope (node:async_hooks:206:9) +  ... 7 lines matching cause stack trace ... +  at async startSubtest (node:internal/test_runner/harness:252:3) { +  [cause]: Error: cause +  at TestContext. (integration-tests/fixture-tests/nested-test/test.ts:34:24) +  at Test.runInAsyncScope (node:async_hooks:206:9) +  at Test.run (node:internal/test_runner/test:856:25) +  at Test.start (node:internal/test_runner/test:753:17) +  at startSubtest (node:internal/test_runner/harness:252:17) +  at run (node:internal/test_runner/harness:260:14) +  at test (node:internal/test_runner/harness:271:12) +  at TestContext. (integration-tests/fixture-tests/nested-test/test.ts:32:19) +  at async Test.run (node:internal/test_runner/test:857:9) +  at async startSubtest (node:internal/test_runner/harness:252:3) + } + + 5) level 0 + level 1 + level 2 + level 0 + level 1 + level 2: + + Error [ERR_TEST_FAILURE]: 2 subtests failed +  at async TestContext. (integration-tests/fixture-tests/nested-test/test.ts:1:424) +  at async TestContext. (integration-tests/fixture-tests/nested-test/test.ts:1:395) { +  code: 'ERR_TEST_FAILURE', +  failureType: 'subtestsFailed', +  cause: '2 subtests failed' + } + + 6) level 0 + level 1 + level 2 + level 0 + level 1: + + Error [ERR_TEST_FAILURE]: 1 subtest failed +  at async TestContext. (integration-tests/fixture-tests/nested-test/test.ts:1:395) { +  code: 'ERR_TEST_FAILURE', +  failureType: 'subtestsFailed', +  cause: '1 subtest failed' + } + + 7) level 0 + level 1 + level 2 + level 0: + + [Error [ERR_TEST_FAILURE]: 1 subtest failed + ] { +  code: 'ERR_TEST_FAILURE', +  failureType: 'subtestsFailed', +  cause: '1 subtest failed' } 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 @@ + + +Qt Svg Document +Generated with Qt + + + + + + + + + + + + + + + + + + +1) test only + + + + describe only + + + + +2) it + + + + describe + + + + +3) it only + + + +0 passing + + + + (143ms) + + + +3 failing + + + + 1) test only: + + + + +AssertionError: Expected values to be strictly equal + + + + + + + +- Expected + + + + + + + ++ Received + + + + + + + + +- 2 + + + + + + + ++ 1 + + + + + + + + + at TestContext.<anonymous> (integration-tests/fixture-tests/only-test-with-the-flag/test.ts:10:10) + + + + + + + + at Test.runInAsyncScope (node:async_hooks:206:9) + + + + + + + + at Test.run (node:internal/test_runner/test:856:25) + + + + + + + + at Test.processPendingSubtests (node:internal/test_runner/test:565:18) + + + + + + + + at Test.postRun (node:internal/test_runner/test:955:19) + + + + + + + + at node:internal/test_runner/test:792:31 + + + + + + + + at node:internal/process/task_queues:140:7 + + + + + + + + at AsyncResource.runInAsyncScope (node:async_hooks:206:9) + + + + + + + + at AsyncResource.runMicrotask (node:internal/process/task_queues:137:8) { + + + + + + + + generatedMessage: true, + + + + + + + + code: 'ERR_ASSERTION', + + + + + + + + actual: 1, + + + + + + + + expected: 2, + + + + + + + + operator: 'strictEqual' + + + + + + + +} + + + + 2) describe only + it: + + + + +AssertionError: Expected values to be strictly equal + + + + + + + +- Expected + + + + + + + ++ Received + + + + + + + + +- 2 + + + + + + + ++ 1 + + + + + + + + + at TestContext.<anonymous> (integration-tests/fixture-tests/only-test-with-the-flag/test.ts:16:12) + + + + + + + + at Test.runInAsyncScope (node:async_hooks:206:9) + + + + + + + + at Test.run (node:internal/test_runner/test:856:25) + + + + + + + + at Test.start (node:internal/test_runner/test:753:17) + + + + + + + + at node:internal/test_runner/test:1215:71 + + + + + + + + at node:internal/per_context/primordials:488:82 + + + + + + + + at new Promise (<anonymous>) + + + + + + + + at new SafePromise (node:internal/per_context/primordials:456:29) + + + + + + + + at node:internal/per_context/primordials:488:9 + + + + + + + + at Array.map (<anonymous>) { + + + + + + + + generatedMessage: true, + + + + + + + + code: 'ERR_ASSERTION', + + + + + + + + actual: 1, + + + + + + + + expected: 2, + + + + + + + + operator: 'strictEqual' + + + + + + + +} + + + + 3) describe + it only: + + + + +AssertionError: Expected values to be strictly equal + + + + + + + +- Expected + + + + + + + ++ Received + + + + + + + + +- 2 + + + + + + + ++ 1 + + + + + + + + + at TestContext.<anonymous> (integration-tests/fixture-tests/only-test-with-the-flag/test.ts:23:12) + + + + + + + + at Test.runInAsyncScope (node:async_hooks:206:9) + + + + + + + + at Test.run (node:internal/test_runner/test:856:25) + + + + + + + + at Test.start (node:internal/test_runner/test:753:17) + + + + + + + + at node:internal/test_runner/test:1215:71 + + + + + + + + at node:internal/per_context/primordials:488:82 + + + + + + + + at new Promise (<anonymous>) + + + + + + + + at new SafePromise (node:internal/per_context/primordials:456:29) + + + + + + + + at node:internal/per_context/primordials:488:9 + + + + + + + + at Array.map (<anonymous>) { + + + + + + + + generatedMessage: true, + + + + + + + + code: 'ERR_ASSERTION', + + + + + + + + actual: 1, + + + + + + + + expected: 2, + + + + + + + + operator: 'strictEqual' + + + + + + + +} + + + 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 @@ + + 1) test only + + describe only + 2) it + + describe + 3) it only + + +0 passing (143ms) +3 failing + + 1) test only: + + AssertionError: Expected values to be strictly equal + - Expected + + Received + + - 2 + + 1 + +  at TestContext. (integration-tests/fixture-tests/only-test-with-the-flag/test.ts:10:10) +  at Test.runInAsyncScope (node:async_hooks:206:9) +  at Test.run (node:internal/test_runner/test:856:25) +  at Test.processPendingSubtests (node:internal/test_runner/test:565:18) +  at Test.postRun (node:internal/test_runner/test:955:19) +  at node:internal/test_runner/test:792:31 +  at node:internal/process/task_queues:140:7 +  at AsyncResource.runInAsyncScope (node:async_hooks:206:9) +  at AsyncResource.runMicrotask (node:internal/process/task_queues:137:8) { +  generatedMessage: true, +  code: 'ERR_ASSERTION', +  actual: 1, +  expected: 2, +  operator: 'strictEqual' + } + + 2) describe only + it: + + AssertionError: Expected values to be strictly equal + - Expected + + Received + + - 2 + + 1 + +  at TestContext. (integration-tests/fixture-tests/only-test-with-the-flag/test.ts:16:12) +  at Test.runInAsyncScope (node:async_hooks:206:9) +  at Test.run (node:internal/test_runner/test:856:25) +  at Test.start (node:internal/test_runner/test:753:17) +  at node:internal/test_runner/test:1215:71 +  at node:internal/per_context/primordials:488:82 +  at new Promise () +  at new SafePromise (node:internal/per_context/primordials:456:29) +  at node:internal/per_context/primordials:488:9 +  at Array.map () { +  generatedMessage: true, +  code: 'ERR_ASSERTION', +  actual: 1, +  expected: 2, +  operator: 'strictEqual' + } + + 3) describe + it only: + + AssertionError: Expected values to be strictly equal + - Expected + + Received + + - 2 + + 1 + +  at TestContext. (integration-tests/fixture-tests/only-test-with-the-flag/test.ts:23:12) +  at Test.runInAsyncScope (node:async_hooks:206:9) +  at Test.run (node:internal/test_runner/test:856:25) +  at Test.start (node:internal/test_runner/test:753:17) +  at node:internal/test_runner/test:1215:71 +  at node:internal/per_context/primordials:488:82 +  at new Promise () +  at new SafePromise (node:internal/per_context/primordials:456:29) +  at node:internal/per_context/primordials:488:9 +  at Array.map () { +  generatedMessage: true, +  code: 'ERR_ASSERTION', +  actual: 1, +  expected: 2, +  operator: 'strictEqual' + } + 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 @@ + + +Qt Svg Document +Generated with Qt + + + + + + + + + + + + + + + + + + + + + + + test + + + + + + + +1) test only + + + + describe only + + + + +2) it + + + + describe + + + + +3) it only + + + + + + + + + + + + it + + + +2 passing + + + + (185ms) + + + +3 failing + + + + + + + + 'only' and 'runOnly' require the --test-only command-line option. + + + + + + + + 'only' and 'runOnly' require the --test-only command-line option. + + + + + + + + 'only' and 'runOnly' require the --test-only command-line option. + 1) test only: + + + + +AssertionError: Expected values to be strictly equal + + + + + + + +- Expected + + + + + + + ++ Received + + + + + + + + +- 2 + + + + + + + ++ 1 + + + + + + + + + at TestContext.<anonymous> (integration-tests/fixture-tests/only-test-without-the-flag/test.ts:10:10) + + + + + + + + at Test.runInAsyncScope (node:async_hooks:206:9) + + + + + + + + at Test.run (node:internal/test_runner/test:856:25) + + + + + + + + at Test.processPendingSubtests (node:internal/test_runner/test:565:18) + + + + + + + + at Test.postRun (node:internal/test_runner/test:955:19) + + + + + + + + at Test.run (node:internal/test_runner/test:898:12) + + + + + + + + at async Test.processPendingSubtests (node:internal/test_runner/test:565:7) { + + + + + + + + generatedMessage: true, + + + + + + + + code: 'ERR_ASSERTION', + + + + + + + + actual: 1, + + + + + + + + expected: 2, + + + + + + + + operator: 'strictEqual' + + + + + + + +} + + + + 2) describe only + it: + + + + +AssertionError: Expected values to be strictly equal + + + + + + + +- Expected + + + + + + + ++ Received + + + + + + + + +- 2 + + + + + + + ++ 1 + + + + + + + + + at TestContext.<anonymous> (integration-tests/fixture-tests/only-test-without-the-flag/test.ts:16:12) + + + + + + + + at Test.runInAsyncScope (node:async_hooks:206:9) + + + + + + + + at Test.run (node:internal/test_runner/test:856:25) + + + + + + + + at Test.start (node:internal/test_runner/test:753:17) + + + + + + + + at node:internal/test_runner/test:1215:71 + + + + + + + + at node:internal/per_context/primordials:488:82 + + + + + + + + at new Promise (<anonymous>) + + + + + + + + at new SafePromise (node:internal/per_context/primordials:456:29) + + + + + + + + at node:internal/per_context/primordials:488:9 + + + + + + + + at Array.map (<anonymous>) { + + + + + + + + generatedMessage: true, + + + + + + + + code: 'ERR_ASSERTION', + + + + + + + + actual: 1, + + + + + + + + expected: 2, + + + + + + + + operator: 'strictEqual' + + + + + + + +} + + + + 3) describe + it only: + + + + +AssertionError: Expected values to be strictly equal + + + + + + + +- Expected + + + + + + + ++ Received + + + + + + + + +- 2 + + + + + + + ++ 1 + + + + + + + + + at TestContext.<anonymous> (integration-tests/fixture-tests/only-test-without-the-flag/test.ts:23:12) + + + + + + + + at Test.runInAsyncScope (node:async_hooks:206:9) + + + + + + + + at Test.run (node:internal/test_runner/test:856:25) + + + + + + + + at Test.start (node:internal/test_runner/test:753:17) + + + + + + + + at node:internal/test_runner/test:1215:71 + + + + + + + + at node:internal/per_context/primordials:488:82 + + + + + + + + at new Promise (<anonymous>) + + + + + + + + at new SafePromise (node:internal/per_context/primordials:456:29) + + + + + + + + at node:internal/per_context/primordials:488:9 + + + + + + + + at Array.map (<anonymous>) { + + + + + + + + generatedMessage: true, + + + + + + + + code: 'ERR_ASSERTION', + + + + + + + + actual: 1, + + + + + + + + expected: 2, + + + + + + + + operator: 'strictEqual' + + + + + + + +} + + + 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 @@ + + ✔ test + + 1) test only + + describe only + 2) it + + describe + 3) it only + ✔ it + + +2 passing (185ms) +3 failing +ℹ 'only' and 'runOnly' require the --test-only command-line option. +ℹ 'only' and 'runOnly' require the --test-only command-line option. +ℹ 'only' and 'runOnly' require the --test-only command-line option. + + 1) test only: + + AssertionError: Expected values to be strictly equal + - Expected + + Received + + - 2 + + 1 + +  at TestContext. (integration-tests/fixture-tests/only-test-without-the-flag/test.ts:10:10) +  at Test.runInAsyncScope (node:async_hooks:206:9) +  at Test.run (node:internal/test_runner/test:856:25) +  at Test.processPendingSubtests (node:internal/test_runner/test:565:18) +  at Test.postRun (node:internal/test_runner/test:955:19) +  at Test.run (node:internal/test_runner/test:898:12) +  at async Test.processPendingSubtests (node:internal/test_runner/test:565:7) { +  generatedMessage: true, +  code: 'ERR_ASSERTION', +  actual: 1, +  expected: 2, +  operator: 'strictEqual' + } + + 2) describe only + it: + + AssertionError: Expected values to be strictly equal + - Expected + + Received + + - 2 + + 1 + +  at TestContext. (integration-tests/fixture-tests/only-test-without-the-flag/test.ts:16:12) +  at Test.runInAsyncScope (node:async_hooks:206:9) +  at Test.run (node:internal/test_runner/test:856:25) +  at Test.start (node:internal/test_runner/test:753:17) +  at node:internal/test_runner/test:1215:71 +  at node:internal/per_context/primordials:488:82 +  at new Promise () +  at new SafePromise (node:internal/per_context/primordials:456:29) +  at node:internal/per_context/primordials:488:9 +  at Array.map () { +  generatedMessage: true, +  code: 'ERR_ASSERTION', +  actual: 1, +  expected: 2, +  operator: 'strictEqual' + } + + 3) describe + it only: + + AssertionError: Expected values to be strictly equal + - Expected + + Received + + - 2 + + 1 + +  at TestContext. (integration-tests/fixture-tests/only-test-without-the-flag/test.ts:23:12) +  at Test.runInAsyncScope (node:async_hooks:206:9) +  at Test.run (node:internal/test_runner/test:856:25) +  at Test.start (node:internal/test_runner/test:753:17) +  at node:internal/test_runner/test:1215:71 +  at node:internal/per_context/primordials:488:82 +  at new Promise () +  at new SafePromise (node:internal/per_context/primordials:456:29) +  at node:internal/per_context/primordials:488:9 +  at Array.map () { +  generatedMessage: true, +  code: 'ERR_ASSERTION', +  actual: 1, +  expected: 2, +  operator: 'strictEqual' + } + 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 @@ - - -Qt SVG Document -Generated with Qt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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 @@ - - 1) top level test - - -0 passing (116ms) -1 failing -ℹ 'only' and 'runOnly' require the --test-only command-line option. - - 1) top level test: - - AssertionError: Expected values to be strictly equal - - Expected - + Received - - - 2 - + 1 - -  at TestContext. (integration-tests/fixture-tests/only-test/test.ts:6:10) -  at Test.runInAsyncScope (node:async_hooks:211:14) -  at Test.run (node:internal/test_runner/test:878:25) -  at Test.processPendingSubtests (node:internal/test_runner/test:590:18) -  at node:internal/test_runner/harness:252:20 -  at node:internal/process/task_queues:151:7 -  at AsyncResource.runInAsyncScope (node:async_hooks:211:14) -  at AsyncResource.runMicrotask (node:internal/process/task_queues:148:8) { -  generatedMessage: true, -  code: 'ERR_ASSERTION', -  actual: 1, -  expected: 2, -  operator: 'strictEqual' - } - 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 @@ - -Qt SVG Document +Qt Svg Document Generated with Qt - - - - - - - - - - + + - + - - - - - - - - + - +1) todo with a callback - + - - ++ todo without a callback - - - - +0 passing - - + (143ms) - +2 todo + 1) todo with a callback: + - - - - - - +AssertionError: Expected values to be strictly equal - + - +- Expected - - + - ++ Received - - - - - - - - + + - +- 2 - + ++ 1 - - + + - - + at TestContext.<anonymous> (integration-tests/fixture-tests/todo-test/test.ts:5:10) - + - - + at Test.runInAsyncScope (node:async_hooks:206:9) - + - - - - - - + at Test.run (node:internal/test_runner/test:856:25) - + - + at Test.processPendingSubtests (node:internal/test_runner/test:565:18) - - + - - + at node:internal/test_runner/harness:248:12 - + - - + at node:internal/process/task_queues:140:7 - + - - + at AsyncResource.runInAsyncScope (node:async_hooks:206:9) - + - - + at AsyncResource.runMicrotask (node:internal/process/task_queues:137:8) { - + - - + generatedMessage: true, - + - - + code: 'ERR_ASSERTION', - + - - + actual: 1, - + - - + expected: 2, - + - - - - - - - - - - - - - - - - + operator: 'strictEqual' - - - - + - +} 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 @@ - 1) top level test + 1) todo with a callback + + todo without a callback -0 passing (114ms) -1 todo - 1) top level test: +0 passing (143ms) +2 todo + + 1) todo with a callback: AssertionError: Expected values to be strictly equal - Expected @@ -15,13 +17,13 @@ + 1  at TestContext. (integration-tests/fixture-tests/todo-test/test.ts:5:10) -  at Test.runInAsyncScope (node:async_hooks:211:14) -  at Test.run (node:internal/test_runner/test:878:25) -  at Test.processPendingSubtests (node:internal/test_runner/test:590:18) -  at node:internal/test_runner/harness:252:20 -  at node:internal/process/task_queues:151:7 -  at AsyncResource.runInAsyncScope (node:async_hooks:211:14) -  at AsyncResource.runMicrotask (node:internal/process/task_queues:148:8) { +  at Test.runInAsyncScope (node:async_hooks:206:9) +  at Test.run (node:internal/test_runner/test:856:25) +  at Test.processPendingSubtests (node:internal/test_runner/test:565:18) +  at node:internal/test_runner/harness:248:12 +  at node:internal/process/task_queues:140:7 +  at AsyncResource.runInAsyncScope (node:async_hooks:206:9) +  at AsyncResource.runMicrotask (node:internal/process/task_queues:137:8) {  generatedMessage: true,  code: 'ERR_ASSERTION',  actual: 1, 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 @@ - -Qt SVG Document +Qt Svg Document Generated with Qt - + + - + - + - + - - + top level test - + - +1) assertion error in top level test - - + - - +2) error with cause in top level test - + +3) error with nested cause in top level test - - +1 passing + + + + (174ms) - +3 failing - + 1) assertion error in top level test: + +AssertionError: Expected values to be strictly equal - - + - - +- Expected - + - ++ Received + + + - + + +- 2 + + + - + ++ 1 - - + + - - + at TestContext.<anonymous> (integration-tests/fixture-tests/top-level-test/test.ts:9:10) + - - + at Test.runInAsyncScope (node:async_hooks:206:9) - + + + + + at Test.run (node:internal/test_runner/test:856:25) - + - + at Test.processPendingSubtests (node:internal/test_runner/test:565:18) - - + - - + at Test.postRun (node:internal/test_runner/test:955:19) - + - + at Test.run (node:internal/test_runner/test:898:12) - - + - - + at async Test.processPendingSubtests (node:internal/test_runner/test:565:7) { - + - + generatedMessage: true, - - + - - + code: 'ERR_ASSERTION', + + + + - + actual: 1, - + - + expected: 2, - - + - - + operator: 'strictEqual' - + - +} - - + 2) error with cause in top level test: + - +Error: error with cause - + + + + + at TestContext.<anonymous> (integration-tests/fixture-tests/top-level-test/test.ts:13:9) - + + + + + at Test.runInAsyncScope (node:async_hooks:206:9) + + + + - + ... 4 lines matching cause stack trace ... - + + + + + at async Test.processPendingSubtests (node:internal/test_runner/test:565:7) { - + + + + + [cause]: Error: cause + + + + - + at TestContext.<anonymous> (integration-tests/fixture-tests/top-level-test/test.ts:14:12) + + + + - + at Test.runInAsyncScope (node:async_hooks:206:9) - + + + + + at Test.run (node:internal/test_runner/test:856:25) - + + + + + at Test.processPendingSubtests (node:internal/test_runner/test:565:18) + + + + - + at Test.postRun (node:internal/test_runner/test:955:19) - + + + + + at Test.run (node:internal/test_runner/test:898:12) - + + + + + at async Test.processPendingSubtests (node:internal/test_runner/test:565:7) + + + + - +} - + 3) error with nested cause in top level test: + + + + +Error: error with cause + - - + at TestContext.<anonymous> (integration-tests/fixture-tests/top-level-test/test.ts:19:9) - + + + + + at Test.runInAsyncScope (node:async_hooks:206:9) - + - + ... 4 lines matching cause stack trace ... - - + - - + at async Test.processPendingSubtests (node:internal/test_runner/test:565:7) { + + + + - + [cause]: Error: cause + + + + - + at TestContext.<anonymous> (integration-tests/fixture-tests/top-level-test/test.ts:20:12) - + + + + + at Test.runInAsyncScope (node:async_hooks:206:9) - + + + + + ... 4 lines matching cause stack trace ... + + + + - + at async Test.processPendingSubtests (node:internal/test_runner/test:565:7) { - + + + + + [cause]: Error: nested cause - + + + + + at TestContext.<anonymous> (integration-tests/fixture-tests/top-level-test/test.ts:21:14) + + + + - + at Test.runInAsyncScope (node:async_hooks:206:9) - + + + + + at Test.run (node:internal/test_runner/test:856:25) - + + + + + at Test.processPendingSubtests (node:internal/test_runner/test:565:18) + + + + - + at Test.postRun (node:internal/test_runner/test:955:19) - + + + + + at Test.run (node:internal/test_runner/test:898:12) + + + + - + at async Test.processPendingSubtests (node:internal/test_runner/test:565:7) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + } - + - +} 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 @@ 2) error with cause in top level test + 3) error with nested cause in top level test -1 passing (120ms) -2 failing + +1 passing (174ms) +3 failing 1) assertion error in top level test: @@ -19,12 +21,12 @@ + 1  at TestContext. (integration-tests/fixture-tests/top-level-test/test.ts:9:10) -  at Test.runInAsyncScope (node:async_hooks:211:14) -  at Test.run (node:internal/test_runner/test:878:25) -  at Test.processPendingSubtests (node:internal/test_runner/test:590:18) -  at Test.postRun (node:internal/test_runner/test:974:19) -  at Test.run (node:internal/test_runner/test:917:12) -  at async Test.processPendingSubtests (node:internal/test_runner/test:590:7) { +  at Test.runInAsyncScope (node:async_hooks:206:9) +  at Test.run (node:internal/test_runner/test:856:25) +  at Test.processPendingSubtests (node:internal/test_runner/test:565:18) +  at Test.postRun (node:internal/test_runner/test:955:19) +  at Test.run (node:internal/test_runner/test:898:12) +  at async Test.processPendingSubtests (node:internal/test_runner/test:565:7) {  generatedMessage: true,  code: 'ERR_ASSERTION',  actual: 1, @@ -36,16 +38,39 @@ Error: error with cause  at TestContext. (integration-tests/fixture-tests/top-level-test/test.ts:13:9) -  at Test.runInAsyncScope (node:async_hooks:211:14) +  at Test.runInAsyncScope (node:async_hooks:206:9)  ... 4 lines matching cause stack trace ... -  at async Test.processPendingSubtests (node:internal/test_runner/test:590:7) { +  at async Test.processPendingSubtests (node:internal/test_runner/test:565:7) {  [cause]: Error: cause  at TestContext. (integration-tests/fixture-tests/top-level-test/test.ts:14:12) -  at Test.runInAsyncScope (node:async_hooks:211:14) -  at Test.run (node:internal/test_runner/test:878:25) -  at Test.processPendingSubtests (node:internal/test_runner/test:590:18) -  at Test.postRun (node:internal/test_runner/test:974:19) -  at Test.run (node:internal/test_runner/test:917:12) -  at async Test.processPendingSubtests (node:internal/test_runner/test:590:7) +  at Test.runInAsyncScope (node:async_hooks:206:9) +  at Test.run (node:internal/test_runner/test:856:25) +  at Test.processPendingSubtests (node:internal/test_runner/test:565:18) +  at Test.postRun (node:internal/test_runner/test:955:19) +  at Test.run (node:internal/test_runner/test:898:12) +  at async Test.processPendingSubtests (node:internal/test_runner/test:565:7) + } + + 3) error with nested cause in top level test: + + Error: error with cause +  at TestContext. (integration-tests/fixture-tests/top-level-test/test.ts:19:9) +  at Test.runInAsyncScope (node:async_hooks:206:9) +  ... 4 lines matching cause stack trace ... +  at async Test.processPendingSubtests (node:internal/test_runner/test:565:7) { +  [cause]: Error: cause +  at TestContext. (integration-tests/fixture-tests/top-level-test/test.ts:20:12) +  at Test.runInAsyncScope (node:async_hooks:206:9) +  ... 4 lines matching cause stack trace ... +  at async Test.processPendingSubtests (node:internal/test_runner/test:565:7) { +  [cause]: Error: nested cause +  at TestContext. (integration-tests/fixture-tests/top-level-test/test.ts:21:14) +  at Test.runInAsyncScope (node:async_hooks:206:9) +  at Test.run (node:internal/test_runner/test:856:25) +  at Test.processPendingSubtests (node:internal/test_runner/test:565:18) +  at Test.postRun (node:internal/test_runner/test:955:19) +  at Test.run (node:internal/test_runner/test:898:12) +  at async Test.processPendingSubtests (node:internal/test_runner/test:565:7) +  } } 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;