diff --git a/.release-please-manifest.json b/.release-please-manifest.json index f796ce8..3750865 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1 +1 @@ -{"packages/github":"1.5.4","packages/junit":"1.2.6","packages/silent":"1.2.4","packages/bail":"1.1.4","packages/testwatch":"1.4.3","packages/slow":"1.0.0"} +{"packages/github":"1.7.0","packages/junit":"1.3.1","packages/silent":"1.2.5","packages/bail":"1.2.0","packages/testwatch":"1.4.3","packages/slow":"1.0.1","packages/mocha":"1.0.1"} diff --git a/README.md b/README.md index 18eaa4b..95c923d 100644 --- a/README.md +++ b/README.md @@ -15,9 +15,10 @@ node --test \ Available reporters: +- [bail](https://www.npmjs.com/package/@reporters/bail) - bail on first failure - [github](https://www.npmjs.com/package/@reporters/github) - report to github actions - [jUnit](https://www.npmjs.com/package/@reporters/junit) - report to jUnit +- [mocha](https://www.npmjs.com/package/@reporters/mocha) - use any mocha reporter with `node:test` - [silent](https://www.npmjs.com/package/@reporters/silent) - a silent reporter -- [bail](https://www.npmjs.com/package/@reporters/bail) - bail on first failure -- [testwatch](https://www.npmjs.com/package/@reporters/testwatch) - An interactive REPL for `node:test` watch mode. - [slow](https://www.npmjs.com/package/@reporters/slow) - report slow tests +- [testwatch](https://www.npmjs.com/package/@reporters/testwatch) - An interactive REPL for `node:test` watch mode. diff --git a/package.json b/package.json index f5b1562..314d6f9 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ }, "homepage": "https://github.com/MoLow/reporters#readme", "devDependencies": { + "@matteo.collina/snap": "^0.2.1", "c8": "^7.13.0", "eslint": "^7.32.0 || ^8.2.0", "eslint-config-airbnb-base": "^15.0.0", diff --git a/packages/bail/.snapshots/bc72bb2843f04838a97cba748b6c200f/0.json b/packages/bail/.snapshots/bc72bb2843f04838a97cba748b6c200f/0.json new file mode 100644 index 0000000..06976e1 --- /dev/null +++ b/packages/bail/.snapshots/bc72bb2843f04838a97cba748b6c200f/0.json @@ -0,0 +1,5 @@ +{ + "stderr": "", + "stdout": ".\n", + "exitCode": 0 +} \ No newline at end of file diff --git a/packages/bail/.snapshots/bc72bb2843f04838a97cba748b6c200f/1.json b/packages/bail/.snapshots/bc72bb2843f04838a97cba748b6c200f/1.json new file mode 100644 index 0000000..57164ff --- /dev/null +++ b/packages/bail/.snapshots/bc72bb2843f04838a97cba748b6c200f/1.json @@ -0,0 +1,5 @@ +{ + "stderr": "node:internal/test_runner/harness:*\n throw err;\n ^\n\nError: Bail\n *\n at bail.next ()\n *\n *\n *\n *\n *\n *\n *\n *\nEmitted 'error' event on Duplex instance at:\n *\n *\n *\n\nNode.js *\n", + "stdout": "X\n\u001b[31m✖ Bailing on failed test: fail\u001b[0m\n", + "exitCode": 7 +} \ No newline at end of file diff --git a/packages/bail/CHANGELOG.md b/packages/bail/CHANGELOG.md index c0b6f9f..39171ce 100644 --- a/packages/bail/CHANGELOG.md +++ b/packages/bail/CHANGELOG.md @@ -1,5 +1,17 @@ # Changelog +## [1.2.0](https://github.com/MoLow/reporters/compare/bail-v1.1.4...bail-v1.2.0) (2024-03-14) + + +### Features + +* add mocha reporter ([#116](https://github.com/MoLow/reporters/issues/116)) ([90ef449](https://github.com/MoLow/reporters/commit/90ef4490665e19cab1ceebf8a77e78b54e38f668)) + + +### Tests + +* migrate snapshots to snap ([#114](https://github.com/MoLow/reporters/issues/114)) ([1d3ca6a](https://github.com/MoLow/reporters/commit/1d3ca6ad12b4abb5c47adc775b47c205a4214e0a)) + ## [1.1.4](https://github.com/MoLow/reporters/compare/bail-v1.1.3...bail-v1.1.4) (2024-01-04) diff --git a/packages/bail/index.js b/packages/bail/index.js index 2155668..059c0ce 100644 --- a/packages/bail/index.js +++ b/packages/bail/index.js @@ -3,8 +3,10 @@ module.exports = async function* bail(source) { for await (const event of source) { if (event.type === 'test:fail') { + /* c8 ignore start */ yield `\n\u001b[31m✖ Bailing on failed test: ${event.data.name}\u001b[0m\n`; throw new Error('Bail'); } + /* c8 ignore stop */ } }; diff --git a/packages/bail/package.json b/packages/bail/package.json index 05fed13..6136cfb 100644 --- a/packages/bail/package.json +++ b/packages/bail/package.json @@ -1,6 +1,6 @@ { "name": "@reporters/bail", - "version": "1.1.4", + "version": "1.2.0", "description": "A Bail library for `node:test`", "type": "commonjs", "keywords": [ diff --git a/packages/bail/tests/index.test.js b/packages/bail/tests/index.test.js index 3537c57..85f0a89 100644 --- a/packages/bail/tests/index.test.js +++ b/packages/bail/tests/index.test.js @@ -2,24 +2,23 @@ const { test } = require('node:test'); const { spawnSync } = require('child_process'); -const assert = require('assert'); +const { Snap } = require('../../../tests/utils'); -test('pass should not interfere with passing test', () => { +const snapshot = Snap(__filename); +test('pass should not interfere with passing test', async () => { const child = spawnSync(process.execPath, [ '--test-reporter', 'dot', '--test-reporter-destination', 'stdout', '--test-reporter', './index.js', '--test-reporter-destination', 'stdout', 'tests/fixtures/pass.js', ], { env: {} }); - assert.strictEqual(child.stderr?.toString(), ''); - assert.strictEqual(child.stdout?.toString(), '.\n'); - assert.strictEqual(child.status, 0); + + await snapshot(child); }); -test('fail should stop after failed test', () => { +test('fail should stop after failed test', async () => { const child = spawnSync(process.execPath, [ '--test-reporter', 'dot', '--test-reporter-destination', 'stdout', '--test-reporter', './index.js', '--test-reporter-destination', 'stdout', 'tests/fixtures/fail.js', 'tests/fixtures/pass.js', ], { env: {} }); - assert.strictEqual(child.stdout?.toString(), 'X\n\x1B[31m✖ Bailing on failed test: fail\x1B[0m\n'); - assert.strictEqual(child.status, 7); + await snapshot(child); }); diff --git a/packages/github/.snapshots/1f0f93c51b9f571a9d899160525b1bcb/0.json b/packages/github/.snapshots/1f0f93c51b9f571a9d899160525b1bcb/0.json new file mode 100644 index 0000000..45fae9b --- /dev/null +++ b/packages/github/.snapshots/1f0f93c51b9f571a9d899160525b1bcb/0.json @@ -0,0 +1,5 @@ +{ + "stderr": "", + "stdout": "::debug::starting to run tests\n::debug::starting to run is ok\n::debug::completed running is ok\n::debug::starting to run fails\n::error title=fails,file=tests/example.js,line=9,col=11::Error [ERR_TEST_FAILURE]: this is an error%0A at async Promise.all (index 0) {%0A code: 'ERR_TEST_FAILURE',%0A failureType: 'testCodeFailure',%0A cause: Error: this is an error%0A at TestContext. (CWD/tests/example.js:9:11)%0A at Test.runInAsyncScope (node:async_hooks:206:9)%0A at Test.run (node:internal/test_runner/test:639:25)%0A at Suite.processPendingSubtests (node:internal/test_runner/test:382:18)%0A at Test.postRun (node:internal/test_runner/test:730:19)%0A at Test.run (node:internal/test_runner/test:688:12)%0A at async Promise.all (index 0)%0A at async Suite.run (node:internal/test_runner/test:964:7)%0A at async startSubtest (node:internal/test_runner/harness:218:3)%0A}\n::debug::starting to run is a diagnostic\n::debug::completed running is a diagnostic\n::notice file=tests/example.js,line=11,col=3::this is a diagnostic\n::debug::starting to run should fail\n::error title=should fail,file=tests/example.js,line=12,col=31::[Error [ERR_TEST_FAILURE]: The expression evaluated to a falsy value:%0A%0A assert(false)%0A] {%0A code: 'ERR_TEST_FAILURE',%0A failureType: 'testCodeFailure',%0A cause: AssertionError [ERR_ASSERTION]: The expression evaluated to a falsy value:%0A %0A assert(false)%0A %0A at TestContext. (CWD/tests/example.js:12:31)%0A at Test.runInAsyncScope (node:async_hooks:206:9)%0A at Test.run (node:internal/test_runner/test:639:25)%0A at Suite.processPendingSubtests (node:internal/test_runner/test:382:18)%0A at Test.postRun (node:internal/test_runner/test:730:19)%0A at Test.run (node:internal/test_runner/test:688:12)%0A at async Suite.processPendingSubtests (node:internal/test_runner/test:382:7) {%0A generatedMessage: true,%0A code: 'ERR_ASSERTION',%0A actual: false,%0A expected: true,%0A operator: '=='%0A }%0A}\n::debug::starting to run more tests\n::debug::starting to run is ok\n::debug::completed running is ok\n::debug::completed running more tests\n::debug::starting to run is skipped\n::debug::completed running is skipped\n::debug::starting to run is a todo\n::debug::completed running is a todo\n::debug::starting to run top level diagnostic\n::debug::completed running top level diagnostic\n::notice file=tests/example.js,line=21,col=1::top level diagnostic\n::group::Test results (4 passed, 2 failed)\n::notice::Total Tests: 8%0ASuites 📂: 2%0APassed ✅: 4%0AFailed ❌: 2%0ACanceled 🚫: 0%0ASkipped ⏭️: 1%0ATodo 📝: 1%0ADuration 🕐: *ms\n::endgroup::\n", + "exitCode": 1 +} \ No newline at end of file diff --git a/packages/github/.snapshots/1f0f93c51b9f571a9d899160525b1bcb/1.json b/packages/github/.snapshots/1f0f93c51b9f571a9d899160525b1bcb/1.json new file mode 100644 index 0000000..d99140f --- /dev/null +++ b/packages/github/.snapshots/1f0f93c51b9f571a9d899160525b1bcb/1.json @@ -0,0 +1 @@ +"

Test Results

\n
Total Tests8
Suites 📂2
Passed ✅4
Failed ❌2
Canceled 🚫0
Skipped ⏭️1
Todo 📝1
Duration 🕐*ms
\n" \ No newline at end of file diff --git a/packages/github/.snapshots/1f0f93c51b9f571a9d899160525b1bcb/2.json b/packages/github/.snapshots/1f0f93c51b9f571a9d899160525b1bcb/2.json new file mode 100644 index 0000000..23d6841 --- /dev/null +++ b/packages/github/.snapshots/1f0f93c51b9f571a9d899160525b1bcb/2.json @@ -0,0 +1,5 @@ +{ + "stderr": "", + "stdout": "::debug::starting to run should fail\n::error title=should fail,file=tests/example.mjs,line=5,col=3::[Error [ERR_TEST_FAILURE]: The expression evaluated to a falsy value:%0A%0A assert(false)%0A] {%0A code: 'ERR_TEST_FAILURE',%0A failureType: 'testCodeFailure',%0A cause: AssertionError [ERR_ASSERTION]: The expression evaluated to a falsy value:%0A %0A assert(false)%0A %0A at TestContext. (file://CWD/tests/example.mjs:5:3)%0A at Test.runInAsyncScope (node:async_hooks:206:9)%0A at Test.run (node:internal/test_runner/test:639:25)%0A at Test.start (node:internal/test_runner/test:550:17)%0A at startSubtest (node:internal/test_runner/harness:218:17) {%0A generatedMessage: true,%0A code: 'ERR_ASSERTION',%0A actual: false,%0A expected: true,%0A operator: '=='%0A }%0A}\n::debug::starting to run should pass\n::debug::completed running should pass\n::group::Test results (1 passed, 1 failed)\n::notice::Total Tests: 2%0ASuites 📂: 0%0APassed ✅: 1%0AFailed ❌: 1%0ACanceled 🚫: 0%0ASkipped ⏭️: 0%0ATodo 📝: 0%0ADuration 🕐: *ms\n::endgroup::\n", + "exitCode": 1 +} \ No newline at end of file diff --git a/packages/github/.snapshots/1f0f93c51b9f571a9d899160525b1bcb/3.json b/packages/github/.snapshots/1f0f93c51b9f571a9d899160525b1bcb/3.json new file mode 100644 index 0000000..d046fe4 --- /dev/null +++ b/packages/github/.snapshots/1f0f93c51b9f571a9d899160525b1bcb/3.json @@ -0,0 +1 @@ +"

Test Results

\n
Total Tests2
Suites 📂0
Passed ✅1
Failed ❌1
Canceled 🚫0
Skipped ⏭️0
Todo 📝0
Duration 🕐*ms
\n" \ No newline at end of file diff --git a/packages/github/.snapshots/1f0f93c51b9f571a9d899160525b1bcb/4.json b/packages/github/.snapshots/1f0f93c51b9f571a9d899160525b1bcb/4.json new file mode 100644 index 0000000..6b29232 --- /dev/null +++ b/packages/github/.snapshots/1f0f93c51b9f571a9d899160525b1bcb/4.json @@ -0,0 +1,5 @@ +{ + "stderr": "", + "stdout": "", + "exitCode": 1 +} \ No newline at end of file diff --git a/packages/github/.snapshots/4353502ed400317a687af8c8312f2662/0.json b/packages/github/.snapshots/4353502ed400317a687af8c8312f2662/0.json new file mode 100644 index 0000000..3c2b389 --- /dev/null +++ b/packages/github/.snapshots/4353502ed400317a687af8c8312f2662/0.json @@ -0,0 +1,5 @@ +{ + "stderr": "", + "stdout": "::debug::starting to run tests\n::debug::starting to run is ok\n::debug::completed running is ok\n::debug::starting to run fails\n::error title=fails,file=tests/example.js,line=9,col=11::[Error [ERR_TEST_FAILURE]: this is an error] {%0A failureType: 'testCodeFailure',%0A cause: Error: this is an error%0A at TestContext. (CWD/tests/example.js:9:11)%0A at Test.runInAsyncScope (node:async_hooks:203:9)%0A at Test.run (node:internal/test_runner/test:631:25)%0A at Suite.processPendingSubtests (node:internal/test_runner/test:374:18)%0A at Test.postRun (node:internal/test_runner/test:715:19)%0A at Test.run (node:internal/test_runner/test:673:12)%0A at async Promise.all (index 0)%0A at async Suite.run (node:internal/test_runner/test:948:7)%0A at async startSubtest (node:internal/test_runner/harness:214:3),%0A code: 'ERR_TEST_FAILURE'%0A}\n::debug::starting to run is a diagnostic\n::debug::completed running is a diagnostic\n::notice file=tests/example.js,line=11,col=3::this is a diagnostic\n::debug::starting to run should fail\n::error title=should fail,file=tests/example.js,line=12,col=31::[Error [ERR_TEST_FAILURE]: The expression evaluated to a falsy value:%0A%0A assert(false)%0A] {%0A failureType: 'testCodeFailure',%0A cause: AssertionError [ERR_ASSERTION]: The expression evaluated to a falsy value:%0A %0A assert(false)%0A %0A at TestContext. (CWD/tests/example.js:12:31)%0A at Test.runInAsyncScope (node:async_hooks:203:9)%0A at Test.run (node:internal/test_runner/test:631:25)%0A at Suite.processPendingSubtests (node:internal/test_runner/test:374:18)%0A at Test.postRun (node:internal/test_runner/test:715:19)%0A at Test.run (node:internal/test_runner/test:673:12)%0A at async Suite.processPendingSubtests (node:internal/test_runner/test:374:7) {%0A generatedMessage: true,%0A code: 'ERR_ASSERTION',%0A actual: false,%0A expected: true,%0A operator: '=='%0A },%0A code: 'ERR_TEST_FAILURE'%0A}\n::debug::starting to run more tests\n::debug::starting to run is ok\n::debug::completed running is ok\n::debug::completed running more tests\n::debug::starting to run is skipped\n::debug::completed running is skipped\n::debug::starting to run is a todo\n::debug::completed running is a todo\n::debug::starting to run top level diagnostic\n::debug::completed running top level diagnostic\n::notice file=tests/example.js,line=21,col=1::top level diagnostic\n::group::Test results (4 passed, 2 failed)\n::notice::Total Tests: 8%0ASuites 📂: 2%0APassed ✅: 4%0AFailed ❌: 2%0ACanceled 🚫: 0%0ASkipped ⏭️: 1%0ATodo 📝: 1%0ADuration 🕐: *ms\n::endgroup::\n", + "exitCode": 1 +} \ No newline at end of file diff --git a/packages/github/.snapshots/4353502ed400317a687af8c8312f2662/1.json b/packages/github/.snapshots/4353502ed400317a687af8c8312f2662/1.json new file mode 100644 index 0000000..d99140f --- /dev/null +++ b/packages/github/.snapshots/4353502ed400317a687af8c8312f2662/1.json @@ -0,0 +1 @@ +"

Test Results

\n
Total Tests8
Suites 📂2
Passed ✅4
Failed ❌2
Canceled 🚫0
Skipped ⏭️1
Todo 📝1
Duration 🕐*ms
\n" \ No newline at end of file diff --git a/packages/github/.snapshots/4353502ed400317a687af8c8312f2662/2.json b/packages/github/.snapshots/4353502ed400317a687af8c8312f2662/2.json new file mode 100644 index 0000000..3df42bd --- /dev/null +++ b/packages/github/.snapshots/4353502ed400317a687af8c8312f2662/2.json @@ -0,0 +1,5 @@ +{ + "stderr": "", + "stdout": "::debug::starting to run should fail\n::error title=should fail,file=tests/example.mjs,line=5,col=3::[Error [ERR_TEST_FAILURE]: false == true] {%0A failureType: 'testCodeFailure',%0A cause: AssertionError [ERR_ASSERTION]: false == true%0A at TestContext. (file://CWD/tests/example.mjs:5:3)%0A at Test.runInAsyncScope (node:async_hooks:203:9)%0A at Test.run (node:internal/test_runner/test:631:25)%0A at Test.start (node:internal/test_runner/test:542:17)%0A at startSubtest (node:internal/test_runner/harness:214:17) {%0A generatedMessage: true,%0A code: 'ERR_ASSERTION',%0A actual: false,%0A expected: true,%0A operator: '=='%0A },%0A code: 'ERR_TEST_FAILURE'%0A}\n::debug::starting to run should pass\n::debug::completed running should pass\n::group::Test results (1 passed, 1 failed)\n::notice::Total Tests: 2%0ASuites 📂: 0%0APassed ✅: 1%0AFailed ❌: 1%0ACanceled 🚫: 0%0ASkipped ⏭️: 0%0ATodo 📝: 0%0ADuration 🕐: *ms\n::endgroup::\n", + "exitCode": 1 +} \ No newline at end of file diff --git a/packages/github/.snapshots/4353502ed400317a687af8c8312f2662/3.json b/packages/github/.snapshots/4353502ed400317a687af8c8312f2662/3.json new file mode 100644 index 0000000..d046fe4 --- /dev/null +++ b/packages/github/.snapshots/4353502ed400317a687af8c8312f2662/3.json @@ -0,0 +1 @@ +"

Test Results

\n
Total Tests2
Suites 📂0
Passed ✅1
Failed ❌1
Canceled 🚫0
Skipped ⏭️0
Todo 📝0
Duration 🕐*ms
\n" \ No newline at end of file diff --git a/packages/github/.snapshots/4353502ed400317a687af8c8312f2662/4.json b/packages/github/.snapshots/4353502ed400317a687af8c8312f2662/4.json new file mode 100644 index 0000000..6b29232 --- /dev/null +++ b/packages/github/.snapshots/4353502ed400317a687af8c8312f2662/4.json @@ -0,0 +1,5 @@ +{ + "stderr": "", + "stdout": "", + "exitCode": 1 +} \ No newline at end of file diff --git a/packages/github/.snapshots/dc3fc117f81a81ae79e191693864201a/0.json b/packages/github/.snapshots/dc3fc117f81a81ae79e191693864201a/0.json new file mode 100644 index 0000000..af52572 --- /dev/null +++ b/packages/github/.snapshots/dc3fc117f81a81ae79e191693864201a/0.json @@ -0,0 +1,5 @@ +{ + "stderr": "", + "stdout": "::debug::starting to run tests\n::debug::starting to run is ok\n::debug::completed running is ok\n::debug::starting to run fails\n::error title=fails,file=tests/example.js,line=9,col=11::[Error [ERR_TEST_FAILURE]: this is an error] {%0A code: 'ERR_TEST_FAILURE',%0A failureType: 'testCodeFailure',%0A cause: Error: this is an error%0A at TestContext. (CWD/tests/example.js:9:11)%0A at Test.runInAsyncScope (node:async_hooks:206:9)%0A at Test.run (node:internal/test_runner/test:631:25)%0A at Suite.processPendingSubtests (node:internal/test_runner/test:374:18)%0A at Test.postRun (node:internal/test_runner/test:715:19)%0A at Test.run (node:internal/test_runner/test:673:12)%0A at async Promise.all (index 0)%0A at async Suite.run (node:internal/test_runner/test:948:7)%0A at async startSubtest (node:internal/test_runner/harness:216:3)%0A}\n::debug::starting to run is a diagnostic\n::debug::completed running is a diagnostic\n::notice file=tests/example.js,line=11,col=3::this is a diagnostic\n::debug::starting to run should fail\n::error title=should fail,file=tests/example.js,line=12,col=31::[Error [ERR_TEST_FAILURE]: The expression evaluated to a falsy value:%0A%0A assert(false)%0A] {%0A code: 'ERR_TEST_FAILURE',%0A failureType: 'testCodeFailure',%0A cause: AssertionError [ERR_ASSERTION]: The expression evaluated to a falsy value:%0A %0A assert(false)%0A %0A at TestContext. (CWD/tests/example.js:12:31)%0A at Test.runInAsyncScope (node:async_hooks:206:9)%0A at Test.run (node:internal/test_runner/test:631:25)%0A at Suite.processPendingSubtests (node:internal/test_runner/test:374:18)%0A at Test.postRun (node:internal/test_runner/test:715:19)%0A at Test.run (node:internal/test_runner/test:673:12)%0A at async Suite.processPendingSubtests (node:internal/test_runner/test:374:7) {%0A generatedMessage: true,%0A code: 'ERR_ASSERTION',%0A actual: false,%0A expected: true,%0A operator: '=='%0A }%0A}\n::debug::starting to run more tests\n::debug::starting to run is ok\n::debug::completed running is ok\n::debug::completed running more tests\n::debug::starting to run is skipped\n::debug::completed running is skipped\n::debug::starting to run is a todo\n::debug::completed running is a todo\n::debug::starting to run top level diagnostic\n::debug::completed running top level diagnostic\n::notice file=tests/example.js,line=21,col=1::top level diagnostic\n::group::Test results (4 passed, 2 failed)\n::notice::Total Tests: 8%0ASuites 📂: 2%0APassed ✅: 4%0AFailed ❌: 2%0ACanceled 🚫: 0%0ASkipped ⏭️: 1%0ATodo 📝: 1%0ADuration 🕐: *ms\n::endgroup::\n", + "exitCode": 1 +} \ No newline at end of file diff --git a/packages/github/.snapshots/dc3fc117f81a81ae79e191693864201a/1.json b/packages/github/.snapshots/dc3fc117f81a81ae79e191693864201a/1.json new file mode 100644 index 0000000..d99140f --- /dev/null +++ b/packages/github/.snapshots/dc3fc117f81a81ae79e191693864201a/1.json @@ -0,0 +1 @@ +"

Test Results

\n
Total Tests8
Suites 📂2
Passed ✅4
Failed ❌2
Canceled 🚫0
Skipped ⏭️1
Todo 📝1
Duration 🕐*ms
\n" \ No newline at end of file diff --git a/packages/github/.snapshots/dc3fc117f81a81ae79e191693864201a/2.json b/packages/github/.snapshots/dc3fc117f81a81ae79e191693864201a/2.json new file mode 100644 index 0000000..83b5627 --- /dev/null +++ b/packages/github/.snapshots/dc3fc117f81a81ae79e191693864201a/2.json @@ -0,0 +1,5 @@ +{ + "stderr": "", + "stdout": "::debug::starting to run should fail\n::error title=should fail,file=tests/example.mjs,line=5,col=3::[Error [ERR_TEST_FAILURE]: The expression evaluated to a falsy value:%0A%0A assert(false)%0A] {%0A code: 'ERR_TEST_FAILURE',%0A failureType: 'testCodeFailure',%0A cause: AssertionError [ERR_ASSERTION]: The expression evaluated to a falsy value:%0A %0A assert(false)%0A %0A at TestContext. (file://CWD/tests/example.mjs:5:3)%0A at Test.runInAsyncScope (node:async_hooks:206:9)%0A at Test.run (node:internal/test_runner/test:631:25)%0A at Test.start (node:internal/test_runner/test:542:17)%0A at startSubtest (node:internal/test_runner/harness:216:17) {%0A generatedMessage: true,%0A code: 'ERR_ASSERTION',%0A actual: false,%0A expected: true,%0A operator: '=='%0A }%0A}\n::debug::starting to run should pass\n::debug::completed running should pass\n::group::Test results (1 passed, 1 failed)\n::notice::Total Tests: 2%0ASuites 📂: 0%0APassed ✅: 1%0AFailed ❌: 1%0ACanceled 🚫: 0%0ASkipped ⏭️: 0%0ATodo 📝: 0%0ADuration 🕐: *ms\n::endgroup::\n", + "exitCode": 1 +} \ No newline at end of file diff --git a/packages/github/.snapshots/dc3fc117f81a81ae79e191693864201a/3.json b/packages/github/.snapshots/dc3fc117f81a81ae79e191693864201a/3.json new file mode 100644 index 0000000..d046fe4 --- /dev/null +++ b/packages/github/.snapshots/dc3fc117f81a81ae79e191693864201a/3.json @@ -0,0 +1 @@ +"

Test Results

\n
Total Tests2
Suites 📂0
Passed ✅1
Failed ❌1
Canceled 🚫0
Skipped ⏭️0
Todo 📝0
Duration 🕐*ms
\n" \ No newline at end of file diff --git a/packages/github/.snapshots/dc3fc117f81a81ae79e191693864201a/4.json b/packages/github/.snapshots/dc3fc117f81a81ae79e191693864201a/4.json new file mode 100644 index 0000000..6b29232 --- /dev/null +++ b/packages/github/.snapshots/dc3fc117f81a81ae79e191693864201a/4.json @@ -0,0 +1,5 @@ +{ + "stderr": "", + "stdout": "", + "exitCode": 1 +} \ No newline at end of file diff --git a/packages/github/CHANGELOG.md b/packages/github/CHANGELOG.md index d0421ee..26ca35d 100644 --- a/packages/github/CHANGELOG.md +++ b/packages/github/CHANGELOG.md @@ -1,5 +1,29 @@ # Changelog +## [1.7.0](https://github.com/MoLow/reporters/compare/github-v1.6.0...github-v1.7.0) (2024-03-14) + + +### Features + +* add mocha reporter ([#116](https://github.com/MoLow/reporters/issues/116)) ([90ef449](https://github.com/MoLow/reporters/commit/90ef4490665e19cab1ceebf8a77e78b54e38f668)) + + +### Tests + +* migrate snapshots to snap ([#114](https://github.com/MoLow/reporters/issues/114)) ([1d3ca6a](https://github.com/MoLow/reporters/commit/1d3ca6ad12b4abb5c47adc775b47c205a4214e0a)) + +## [1.6.0](https://github.com/MoLow/reporters/compare/github-v1.5.4...github-v1.6.0) (2024-02-01) + + +### Features + +* add location to notify ([#111](https://github.com/MoLow/reporters/issues/111)) ([e63d34a](https://github.com/MoLow/reporters/commit/e63d34a5b4fb040a4cb63d4db15c87d4128e7c4c)) + + +### Bug Fixes + +* remove diagnostics from summary ([#113](https://github.com/MoLow/reporters/issues/113)) ([1e95cf0](https://github.com/MoLow/reporters/commit/1e95cf0bab16785073715238b42b9fb8baebbc43)) + ## [1.5.4](https://github.com/MoLow/reporters/compare/github-v1.5.3...github-v1.5.4) (2024-01-04) diff --git a/packages/github/index.js b/packages/github/index.js index 073631b..97adf8c 100644 --- a/packages/github/index.js +++ b/packages/github/index.js @@ -43,6 +43,21 @@ const DIAGNOSTIC_VALUES = { duration_ms: (value) => `${Number(value).toFixed(3)}ms`, }; +function extractLocation(data) { + let { line, column, file } = data; + const error = data.details?.error; + file = getFilePath(file); + + if (error) { + const errorLocation = parseStack(error, file); + file = getFilePath(errorLocation?.file ?? file) ?? file; + line = errorLocation?.line ?? line; + column = errorLocation?.column ?? column; + } + + return { file, startLine: line, startColumn: column }; +} + module.exports = async function githubReporter(source) { if (!process.env.GITHUB_ACTIONS) { // eslint-disable-next-line no-unused-vars @@ -67,22 +82,19 @@ module.exports = async function githubReporter(source) { // no need to re-annotate the file itself break; } - let filePath = getFilePath(event.data.file); - const location = parseStack(error, filePath); - filePath = getFilePath(location?.file ?? filePath) ?? filePath; core.error(util.inspect(error, { colors: false, breakLength: Infinity }), { - file: filePath, - startLine: location?.line, - startColumn: location?.column, + ...extractLocation(event.data), title: event.data.name, }); counter.fail += 1; break; } case 'test:diagnostic': - if (event.data.nesting === 0) { + if (event.data.file === undefined + || event.data.line === undefined + || event.data.column === undefined) { diagnostics.push(event.data.message); } else { - core.notice(event.data.message, { file: getFilePath(event.data.file) }); + core.notice(event.data.message, extractLocation(event.data)); } break; default: diff --git a/packages/github/package.json b/packages/github/package.json index 265b76d..1c5f4fa 100644 --- a/packages/github/package.json +++ b/packages/github/package.json @@ -1,6 +1,6 @@ { "name": "@reporters/github", - "version": "1.5.4", + "version": "1.7.0", "description": "A github actions reporter for `node:test`", "type": "commonjs", "keywords": [ diff --git a/packages/github/tests/index.test.js b/packages/github/tests/index.test.js index 05a7b72..02d253b 100644 --- a/packages/github/tests/index.test.js +++ b/packages/github/tests/index.test.js @@ -4,47 +4,36 @@ const { test, describe, beforeEach } = require('node:test'); const { spawnSync } = require('child_process'); const { tmpdir } = require('os'); const { join } = require('path'); -const assert = require('assert'); const path = require('path'); const { readFileSync, writeFileSync } = require('fs'); -const { compareLines } = require('../../../tests/utils'); -const output = require('./output'); -const outputESM = require('./output-esm'); +const { Snap, nodeMajor } = require('../../../tests/utils'); +const snapshot = Snap(`${__filename}.${nodeMajor}`); const GITHUB_STEP_SUMMARY = join(tmpdir(), 'github-actions-test-reporter'); -const nodeMajor = process.versions.node.split('.')[0]; describe('github reporter', () => { beforeEach(() => { writeFileSync(GITHUB_STEP_SUMMARY, ''); }); - test('spawn with reporter', () => { + test('spawn with reporter', async () => { const child = spawnSync(process.execPath, ['--test-reporter', './index.js', '../../tests/example'], { env: { GITHUB_ACTIONS: true, GITHUB_STEP_SUMMARY, GITHUB_WORKSPACE: path.resolve(__dirname, '../../../') }, }); - assert.strictEqual(child.stderr?.toString(), ''); - compareLines(child.stdout?.toString(), output.overrides[nodeMajor]?.stdout ?? output.stdout); - compareLines(readFileSync(GITHUB_STEP_SUMMARY).toString(), output.summary); + await snapshot(child, readFileSync(GITHUB_STEP_SUMMARY).toString('utf-8')); }); - test('spawn with reporter - esm', () => { + test('spawn with reporter - esm', async () => { const child = spawnSync(process.execPath, ['--test-reporter', './index.js', '../../tests/example.mjs'], { env: { GITHUB_ACTIONS: true, GITHUB_STEP_SUMMARY, GITHUB_WORKSPACE: path.resolve(__dirname, '../../../') }, }); - assert.strictEqual(child.stderr?.toString(), ''); - compareLines( - child.stdout?.toString(), - outputESM.overrides[nodeMajor]?.stdout ?? outputESM.stdout, - ); - compareLines(readFileSync(GITHUB_STEP_SUMMARY).toString(), outputESM.summary); + await snapshot(child, readFileSync(GITHUB_STEP_SUMMARY).toString('utf-8')); }); - test('should noop if not in github actions', () => { + test('should noop if not in github actions', async () => { const silentChild = spawnSync(process.execPath, ['--test-reporter', './index.js', '../../tests/example'], { env: { } }); - assert.strictEqual(silentChild.stderr?.toString(), ''); - assert.strictEqual(silentChild.stdout?.toString(), ''); + await snapshot(silentChild); }); }); diff --git a/packages/github/tests/output-esm.js b/packages/github/tests/output-esm.js deleted file mode 100644 index 0a70bfd..0000000 --- a/packages/github/tests/output-esm.js +++ /dev/null @@ -1,37 +0,0 @@ -'use strict'; - -module.exports = { - stdout: `::debug::starting to run should fail -:error title=should fail,file=tests/example.mjs,line=5,col=3::\\[Error \\[ERR_TEST_FAILURE\\]: false == true\\] {%0A code: 'ERR_TEST_FAILURE',%0A failureType: 'testCodeFailure',%0A cause: AssertionError \\[ERR_ASSERTION\\]: false == true%0A at TestContext. \\(file:///.*/example.mjs:5:3\\)%0A.* {%0A generatedMessage: true,%0A code: 'ERR_ASSERTION',%0A actual: false,%0A expected: true,%0A operator: '=='%0A }%0A} -::debug::starting to run should pass -::debug::completed running should pass -::group::Test results \\(1 passed, 1 failed\\) -::notice::Total Tests: 2%0ASuites 📂: 0%0APassed ✅: 1%0AFailed ❌: 1%0ACanceled 🚫: 0%0ASkipped ⏭️: 0%0ATodo 📝: 0%0ADuration 🕐: .*ms -::endgroup:: -`, - summary: `

Test Results

-
Total Tests2
Suites 📂0
Passed ✅1
Failed ❌1
Canceled 🚫0
Skipped ⏭️0
Todo 📝0
Duration 🕐.*ms
-`, - overrides: { - 18: { - stdout: `::debug::starting to run should fail -::error title=should fail,file=tests/example.mjs,line=5,col=3::\\[Error \\[ERR_TEST_FAILURE\\]: false == true\\] {%0A failureType: 'testCodeFailure',%0A cause: AssertionError \\[ERR_ASSERTION\\]: false == true%0A.* {%0A generatedMessage: true,%0A code: 'ERR_ASSERTION',%0A actual: false,%0A expected: true,%0A operator: '=='%0A },%0A code: 'ERR_TEST_FAILURE'%0A} -::debug::starting to run should pass -::debug::completed running should pass -::group::Test results \\(1 passed, 1 failed\\) -::notice::Total Tests: 2%0ASuites 📂: 0%0APassed ✅: 1%0AFailed ❌: 1%0ACanceled 🚫: 0%0ASkipped ⏭️: 0%0ATodo 📝: 0%0ADuration 🕐: .*ms -::endgroup:: -`, - }, - 21: { - stdout: `::debug::starting to run should fail -::error title=should fail,file=tests/example.mjs,line=5,col=3::\\[Error \\[ERR_TEST_FAILURE\\]: The expression evaluated to a falsy value:%0A%0A assert\\(false\\)%0A\\] {%0A code: 'ERR_TEST_FAILURE',%0A failureType: 'testCodeFailure',%0A cause: AssertionError \\[ERR_ASSERTION\\]: The expression evaluated to a falsy value:%0A %0A assert\\(false\\)%0A %0A at TestContext. \\(file:///.*/example.mjs:5:3\\)%0A.* {%0A generatedMessage: true,%0A code: 'ERR_ASSERTION',%0A actual: false,%0A expected: true,%0A operator: '=='%0A }%0A} -::debug::starting to run should pass -::debug::completed running should pass -::group::Test results \\(1 passed, 1 failed\\) -::notice::Total Tests: 2%0ASuites 📂: 0%0APassed ✅: 1%0AFailed ❌: 1%0ACanceled 🚫: 0%0ASkipped ⏭️: 0%0ATodo 📝: 0%0ADuration 🕐: .*ms -::endgroup:: -`, - }, - }, -}; diff --git a/packages/github/tests/output.js b/packages/github/tests/output.js deleted file mode 100644 index 8dcb006..0000000 --- a/packages/github/tests/output.js +++ /dev/null @@ -1,55 +0,0 @@ -'use strict'; - -module.exports = { - stdout: `::debug::starting to run tests -::debug::starting to run is ok -::debug::completed running is ok -::debug::starting to run fails -::error title=fails,file=tests/example.js,line=9,col=11::\\[Error \\[ERR_TEST_FAILURE\\]: this is an error\\] {%0A code: 'ERR_TEST_FAILURE',%0A failureType: 'testCodeFailure',%0A cause: Error: this is an error%0A at TestContext. (.*/example.js:9:11).*%0A} -::debug::starting to run is a diagnostic -::debug::completed running is a diagnostic -::notice file=tests/example.js::this is a diagnostic -::debug::starting to run should fail -::error title=should fail,file=tests/example.js,line=12,col=31::\\[Error \\[ERR_TEST_FAILURE\\]: The expression evaluated to a falsy value:%0A%0A assert\\(false\\)%0A\\] {%0A code: 'ERR_TEST_FAILURE',%0A failureType: 'testCodeFailure',%0A cause: AssertionError \\[ERR_ASSERTION\\]: The expression evaluated to a falsy value:%0A %0A assert\\(false\\)%0A %0A at TestContext. (.*/example.js:12:31).* -::debug::starting to run more tests -::debug::starting to run is ok -::debug::completed running is ok -::debug::completed running more tests -::debug::starting to run is skipped -::debug::completed running is skipped -::debug::starting to run is a todo -::debug::completed running is a todo -::group::Test results \\(3 passed, 2 failed\\) -::notice::Total Tests: 7%0ASuites 📂: 2%0APassed ✅: 3%0AFailed ❌: 2%0ACanceled 🚫: 0%0ASkipped ⏭️: 1%0ATodo 📝: 1%0ADuration 🕐: .*ms -::endgroup:: -`, - summary: `

Test Results

-
Total Tests7
Suites 📂2
Passed ✅3
Failed ❌2
Canceled 🚫0
Skipped ⏭️1
Todo 📝1
Duration 🕐.*ms
-`, - overrides: { - 18: { - stdout: `::debug::starting to run tests -::debug::starting to run is ok -::debug::completed running is ok -::debug::starting to run fails -::error title=fails,file=tests/example.js,line=9,col=11::\\[Error \\[ERR_TEST_FAILURE\\]: this is an error\\] {%0A failureType: 'testCodeFailure',%0A cause: Error: this is an error%0A at TestContext. (.*/example.js:9:11).* code: 'ERR_TEST_FAILURE'%0A} -::debug::starting to run is a diagnostic -::debug::completed running is a diagnostic -::notice file=tests/example.js::this is a diagnostic -::debug::starting to run should fail -::error title=should fail,file=tests/example.js,line=12,col=31::\\[Error \\[ERR_TEST_FAILURE\\]: The expression evaluated to a falsy value:%0A%0A assert\\(false\\)%0A\\] {%0A failureType: 'testCodeFailure',%0A cause: AssertionError \\[ERR_ASSERTION\\]: The expression evaluated to a falsy value:%0A %0A assert\\(false\\)%0A %0A at TestContext. (.*/example.js:12:31).* -::debug::starting to run more tests -::debug::starting to run is ok -::debug::completed running is ok -::debug::completed running more tests -::debug::starting to run is skipped -::debug::completed running is skipped -::debug::starting to run is a todo -::debug::completed running is a todo -::group::Test results \\(3 passed, 2 failed\\) -::notice::Total Tests: 7%0ASuites 📂: 2%0APassed ✅: 3%0AFailed ❌: 2%0ACanceled 🚫: 0%0ASkipped ⏭️: 1%0ATodo 📝: 1%0ADuration 🕐: .*ms -::endgroup:: -`, - }, - }, -}; diff --git a/packages/junit/.snapshots/1f0f93c51b9f571a9d899160525b1bcb/0.json b/packages/junit/.snapshots/1f0f93c51b9f571a9d899160525b1bcb/0.json new file mode 100644 index 0000000..4d44ab7 --- /dev/null +++ b/packages/junit/.snapshots/1f0f93c51b9f571a9d899160525b1bcb/0.json @@ -0,0 +1,5 @@ +{ + "stderr": "", + "stdout": "\n\n\t\n\t\t\n\t\t\n\t\t\t\nError [ERR_TEST_FAILURE]: this is an error\n at async Promise.all (index 0) {\n code: 'ERR_TEST_FAILURE',\n failureType: 'testCodeFailure',\n cause: Error: this is an error\n *\n *\n *\n *\n *\n *\n at async Promise.all (index 0)\n *\n *\n}\n\t\t\t\n\t\t\n\t\t\n\t\t\n\t\t\t\n[Error [ERR_TEST_FAILURE]: The expression evaluated to a falsy value:\n\n assert(false)\n] {\n code: 'ERR_TEST_FAILURE',\n failureType: 'testCodeFailure',\n cause: AssertionError [ERR_ASSERTION]: The expression evaluated to a falsy value:\n \n assert(false)\n \n *\n *\n *\n *\n *\n *\n * {\n generatedMessage: true,\n code: 'ERR_ASSERTION',\n actual: false,\n expected: true,\n operator: '=='\n }\n}\n\t\t\t\n\t\t\n\t\n\t\n\t\t\n\t\n\t\n\t\t\n\t\n\t\n\t\t\n\t\n\t\n\n", + "exitCode": 1 +} \ No newline at end of file diff --git a/packages/junit/.snapshots/1f0f93c51b9f571a9d899160525b1bcb/1.json b/packages/junit/.snapshots/1f0f93c51b9f571a9d899160525b1bcb/1.json new file mode 100644 index 0000000..8412e9d --- /dev/null +++ b/packages/junit/.snapshots/1f0f93c51b9f571a9d899160525b1bcb/1.json @@ -0,0 +1,5 @@ +{ + "stderr": "", + "stdout": "\n\n\t\n\t\t\n[Error [ERR_TEST_FAILURE]: The expression evaluated to a falsy value:\n\n assert(false)\n] {\n code: 'ERR_TEST_FAILURE',\n failureType: 'testCodeFailure',\n cause: AssertionError [ERR_ASSERTION]: The expression evaluated to a falsy value:\n \n assert(false)\n \n *\n *\n *\n *\n * {\n generatedMessage: true,\n code: 'ERR_ASSERTION',\n actual: false,\n expected: true,\n operator: '=='\n }\n}\n\t\t\n\t\n\t\n\n", + "exitCode": 1 +} \ No newline at end of file diff --git a/packages/junit/.snapshots/1f0f93c51b9f571a9d899160525b1bcb/2.json b/packages/junit/.snapshots/1f0f93c51b9f571a9d899160525b1bcb/2.json new file mode 100644 index 0000000..3f20a94 --- /dev/null +++ b/packages/junit/.snapshots/1f0f93c51b9f571a9d899160525b1bcb/2.json @@ -0,0 +1,5 @@ +[ + "\n", + "\n", + "\n" +] \ No newline at end of file diff --git a/packages/junit/.snapshots/1f0f93c51b9f571a9d899160525b1bcb/3.json b/packages/junit/.snapshots/1f0f93c51b9f571a9d899160525b1bcb/3.json new file mode 100644 index 0000000..9493fc6 --- /dev/null +++ b/packages/junit/.snapshots/1f0f93c51b9f571a9d899160525b1bcb/3.json @@ -0,0 +1,6 @@ +[ + "\n", + "\n", + "\t\n\t\n\t\n", + "\n" +] \ No newline at end of file diff --git a/packages/junit/.snapshots/4353502ed400317a687af8c8312f2662/0.json b/packages/junit/.snapshots/4353502ed400317a687af8c8312f2662/0.json new file mode 100644 index 0000000..411bf85 --- /dev/null +++ b/packages/junit/.snapshots/4353502ed400317a687af8c8312f2662/0.json @@ -0,0 +1,5 @@ +{ + "stderr": "", + "stdout": "\n\n\t\n\t\t\n\t\t\n\t\t\t\n[Error [ERR_TEST_FAILURE]: this is an error] {\n failureType: 'testCodeFailure',\n cause: Error: this is an error\n *\n *\n *\n *\n *\n *\n at async Promise.all (index 0)\n *\n at async startSubtest (node:internal/test_runner/harness:214:3),\n code: 'ERR_TEST_FAILURE'\n}\n\t\t\t\n\t\t\n\t\t\n\t\t\n\t\t\t\n[Error [ERR_TEST_FAILURE]: The expression evaluated to a falsy value:\n\n assert(false)\n] {\n failureType: 'testCodeFailure',\n cause: AssertionError [ERR_ASSERTION]: The expression evaluated to a falsy value:\n \n assert(false)\n \n *\n *\n *\n *\n *\n *\n * {\n generatedMessage: true,\n code: 'ERR_ASSERTION',\n actual: false,\n expected: true,\n operator: '=='\n },\n code: 'ERR_TEST_FAILURE'\n}\n\t\t\t\n\t\t\n\t\n\t\n\t\t\n\t\n\t\n\t\t\n\t\n\t\n\t\t\n\t\n\t\n\n", + "exitCode": 1 +} \ No newline at end of file diff --git a/packages/junit/.snapshots/4353502ed400317a687af8c8312f2662/1.json b/packages/junit/.snapshots/4353502ed400317a687af8c8312f2662/1.json new file mode 100644 index 0000000..9692f7c --- /dev/null +++ b/packages/junit/.snapshots/4353502ed400317a687af8c8312f2662/1.json @@ -0,0 +1,5 @@ +{ + "stderr": "", + "stdout": "\n\n\t\n\t\t\n[Error [ERR_TEST_FAILURE]: false == true] {\n failureType: 'testCodeFailure',\n cause: AssertionError [ERR_ASSERTION]: false == true\n *\n *\n *\n *\n * {\n generatedMessage: true,\n code: 'ERR_ASSERTION',\n actual: false,\n expected: true,\n operator: '=='\n },\n code: 'ERR_TEST_FAILURE'\n}\n\t\t\n\t\n\t\n\n", + "exitCode": 1 +} \ No newline at end of file diff --git a/packages/junit/.snapshots/4353502ed400317a687af8c8312f2662/2.json b/packages/junit/.snapshots/4353502ed400317a687af8c8312f2662/2.json new file mode 100644 index 0000000..3f20a94 --- /dev/null +++ b/packages/junit/.snapshots/4353502ed400317a687af8c8312f2662/2.json @@ -0,0 +1,5 @@ +[ + "\n", + "\n", + "\n" +] \ No newline at end of file diff --git a/packages/junit/.snapshots/4353502ed400317a687af8c8312f2662/3.json b/packages/junit/.snapshots/4353502ed400317a687af8c8312f2662/3.json new file mode 100644 index 0000000..9493fc6 --- /dev/null +++ b/packages/junit/.snapshots/4353502ed400317a687af8c8312f2662/3.json @@ -0,0 +1,6 @@ +[ + "\n", + "\n", + "\t\n\t\n\t\n", + "\n" +] \ No newline at end of file diff --git a/packages/junit/.snapshots/dc3fc117f81a81ae79e191693864201a/0.json b/packages/junit/.snapshots/dc3fc117f81a81ae79e191693864201a/0.json new file mode 100644 index 0000000..303b4db --- /dev/null +++ b/packages/junit/.snapshots/dc3fc117f81a81ae79e191693864201a/0.json @@ -0,0 +1,5 @@ +{ + "stderr": "", + "stdout": "\n\n\t\n\t\t\n\t\t\n\t\t\t\n[Error [ERR_TEST_FAILURE]: this is an error] {\n code: 'ERR_TEST_FAILURE',\n failureType: 'testCodeFailure',\n cause: Error: this is an error\n *\n *\n *\n *\n *\n *\n at async Promise.all (index 0)\n *\n *\n}\n\t\t\t\n\t\t\n\t\t\n\t\t\n\t\t\t\n[Error [ERR_TEST_FAILURE]: The expression evaluated to a falsy value:\n\n assert(false)\n] {\n code: 'ERR_TEST_FAILURE',\n failureType: 'testCodeFailure',\n cause: AssertionError [ERR_ASSERTION]: The expression evaluated to a falsy value:\n \n assert(false)\n \n *\n *\n *\n *\n *\n *\n * {\n generatedMessage: true,\n code: 'ERR_ASSERTION',\n actual: false,\n expected: true,\n operator: '=='\n }\n}\n\t\t\t\n\t\t\n\t\n\t\n\t\t\n\t\n\t\n\t\t\n\t\n\t\n\t\t\n\t\n\t\n\n", + "exitCode": 1 +} \ No newline at end of file diff --git a/packages/junit/.snapshots/dc3fc117f81a81ae79e191693864201a/1.json b/packages/junit/.snapshots/dc3fc117f81a81ae79e191693864201a/1.json new file mode 100644 index 0000000..8412e9d --- /dev/null +++ b/packages/junit/.snapshots/dc3fc117f81a81ae79e191693864201a/1.json @@ -0,0 +1,5 @@ +{ + "stderr": "", + "stdout": "\n\n\t\n\t\t\n[Error [ERR_TEST_FAILURE]: The expression evaluated to a falsy value:\n\n assert(false)\n] {\n code: 'ERR_TEST_FAILURE',\n failureType: 'testCodeFailure',\n cause: AssertionError [ERR_ASSERTION]: The expression evaluated to a falsy value:\n \n assert(false)\n \n *\n *\n *\n *\n * {\n generatedMessage: true,\n code: 'ERR_ASSERTION',\n actual: false,\n expected: true,\n operator: '=='\n }\n}\n\t\t\n\t\n\t\n\n", + "exitCode": 1 +} \ No newline at end of file diff --git a/packages/junit/.snapshots/dc3fc117f81a81ae79e191693864201a/2.json b/packages/junit/.snapshots/dc3fc117f81a81ae79e191693864201a/2.json new file mode 100644 index 0000000..3f20a94 --- /dev/null +++ b/packages/junit/.snapshots/dc3fc117f81a81ae79e191693864201a/2.json @@ -0,0 +1,5 @@ +[ + "\n", + "\n", + "\n" +] \ No newline at end of file diff --git a/packages/junit/.snapshots/dc3fc117f81a81ae79e191693864201a/3.json b/packages/junit/.snapshots/dc3fc117f81a81ae79e191693864201a/3.json new file mode 100644 index 0000000..9493fc6 --- /dev/null +++ b/packages/junit/.snapshots/dc3fc117f81a81ae79e191693864201a/3.json @@ -0,0 +1,6 @@ +[ + "\n", + "\n", + "\t\n\t\n\t\n", + "\n" +] \ No newline at end of file diff --git a/packages/junit/CHANGELOG.md b/packages/junit/CHANGELOG.md index 927b42a..04f0bd3 100644 --- a/packages/junit/CHANGELOG.md +++ b/packages/junit/CHANGELOG.md @@ -1,5 +1,24 @@ # Changelog +## [1.3.1](https://github.com/MoLow/reporters/compare/junit-v1.3.0...junit-v1.3.1) (2024-03-14) + + +### Tests + +* migrate snapshots to snap ([#114](https://github.com/MoLow/reporters/issues/114)) ([1d3ca6a](https://github.com/MoLow/reporters/commit/1d3ca6ad12b4abb5c47adc775b47c205a4214e0a)) + +## [1.3.0](https://github.com/MoLow/reporters/compare/junit-v1.2.6...junit-v1.3.0) (2024-02-01) + + +### Features + +* add location to notify ([#111](https://github.com/MoLow/reporters/issues/111)) ([e63d34a](https://github.com/MoLow/reporters/commit/e63d34a5b4fb040a4cb63d4db15c87d4128e7c4c)) + + +### Bug Fixes + +* remove diagnostics from summary ([#113](https://github.com/MoLow/reporters/issues/113)) ([1e95cf0](https://github.com/MoLow/reporters/commit/1e95cf0bab16785073715238b42b9fb8baebbc43)) + ## [1.2.6](https://github.com/MoLow/reporters/compare/junit-v1.2.5...junit-v1.2.6) (2024-01-04) diff --git a/packages/junit/package.json b/packages/junit/package.json index 29beb1e..ab9c777 100644 --- a/packages/junit/package.json +++ b/packages/junit/package.json @@ -1,6 +1,6 @@ { "name": "@reporters/junit", - "version": "1.2.6", + "version": "1.3.1", "description": "A jUnit reporter for `node:test`", "type": "commonjs", "keywords": [ diff --git a/packages/junit/tests/index.test.js b/packages/junit/tests/index.test.js index 17e6fe6..5234615 100644 --- a/packages/junit/tests/index.test.js +++ b/packages/junit/tests/index.test.js @@ -3,26 +3,19 @@ const { test } = require('node:test'); const { spawnSync } = require('child_process'); const assert = require('assert'); -const { compareLines } = require('../../../tests/utils'); const reporter = require('../index'); -const output = require('./output'); -const outputESM = require('./output-esm'); +const { Snap, nodeMajor } = require('../../../tests/utils'); -const nodeMajor = process.versions.node.split('.')[0]; +const snapshot = Snap(`${__filename}.${nodeMajor}`); -test('spwan with reporter', () => { +test('spwan with reporter', async () => { const child = spawnSync(process.execPath, ['--test-reporter', './index.js', '../../tests/example'], { env: {} }); - assert.strictEqual(child.stderr?.toString(), ''); - compareLines(child.stdout?.toString(), output.overrides[nodeMajor]?.stdout ?? output.stdout); + await snapshot(child); }); -test('spwan with reporter -esm', () => { +test('spwan with reporter - esm', async () => { const child = spawnSync(process.execPath, ['--test-reporter', './index.js', '../../tests/example.mjs'], { env: {} }); - assert.strictEqual(child.stderr?.toString(), ''); - compareLines( - child.stdout?.toString(), - outputESM.overrides[nodeMajor]?.stdout ?? outputESM.stdout, - ); + await snapshot(child); }); test('empty', async () => { @@ -30,11 +23,8 @@ test('empty', async () => { for await (const line of reporter([])) { lines.push(line); } - assert.deepStrictEqual(lines, [ - '\n', - '\n', - '\n', - ]); + + assert.deepStrictEqual(lines, await snapshot.snap(lines)); }); test('single test', async () => { @@ -42,10 +32,5 @@ test('single test', async () => { for await (const line of reporter([{ type: 'test:pass', data: { name: 'test', nesting: 0, details: { duration_ms: 100 } } }])) { lines.push(line); } - assert.deepStrictEqual(lines, [ - '\n', - '\n', - '\t\n\t\n\t\n', - '\n', - ]); + assert.deepStrictEqual(lines, await snapshot.snap(lines)); }); diff --git a/packages/junit/tests/output-esm.js b/packages/junit/tests/output-esm.js deleted file mode 100644 index 637293a..0000000 --- a/packages/junit/tests/output-esm.js +++ /dev/null @@ -1,91 +0,0 @@ -'use strict'; - -module.exports = { - stdout: `<\\?xml version="1.0" encoding="utf-8"\\?> - -\t -\t\t -\\[Error \\[ERR_TEST_FAILURE\\]: false == true\\] { - code: 'ERR_TEST_FAILURE', - failureType: 'testCodeFailure', - cause: AssertionError \\[ERR_ASSERTION\\]: false == true - at TestContext.*/example.mjs:5:3\\) - at .* - at .* - at .* - at .* { - generatedMessage: true, - code: 'ERR_ASSERTION', - actual: false, - expected: true, - operator: '==' - } -} -\t\t -\t -\t - -`, - overrides: { - 21: { - stdout: `<\\?xml version="1.0" encoding="utf-8"\\?> - -\t -\t\t -\\[Error \\[ERR_TEST_FAILURE\\]: The expression evaluated to a falsy value: - - assert\\(false\\) -] { - code: 'ERR_TEST_FAILURE', - failureType: 'testCodeFailure', - cause: AssertionError \\[ERR_ASSERTION\\]: The expression evaluated to a falsy value: - - assert\\(false\\) - - at .* - at .* - at .* - at .* - at .* { - generatedMessage: true, - code: 'ERR_ASSERTION', - actual: false, - expected: true, - operator: '==' - } -} -\t\t -\t -\t - -`, - }, - 18: { - stdout: `<\\?xml version="1.0" encoding="utf-8"\\?> - -\t -\t\t -\\[Error \\[ERR_TEST_FAILURE\\]: false == true\\] { - failureType: 'testCodeFailure', - cause: AssertionError \\[ERR_ASSERTION\\]: false == true - at TestContext.*/example.mjs:5:3\\) - at .* - at .* - at .* - at .* { - generatedMessage: true, - code: 'ERR_ASSERTION', - actual: false, - expected: true, - operator: '==' - }, - code: 'ERR_TEST_FAILURE' -} -\t\t -\t -\t - -`, - }, - }, -}; diff --git a/packages/junit/tests/output.js b/packages/junit/tests/output.js deleted file mode 100644 index 6e6cc1c..0000000 --- a/packages/junit/tests/output.js +++ /dev/null @@ -1,134 +0,0 @@ -'use strict'; - -module.exports = { - stdout: `<\\?xml version="1.0" encoding="utf-8"\\?> - -\t -\t\t -\t\t -\t\t\t -\\[Error \\[ERR_TEST_FAILURE\\]: this is an error\\] { - code: 'ERR_TEST_FAILURE', - failureType: 'testCodeFailure', - cause: Error: this is an error - .* - .* - .* - .* - .* - .* - .* - .* - .* -} -\t\t\t -\t\t -\t\t -\t\t -\t\t -\\[Error \\[ERR_TEST_FAILURE\\]: The expression evaluated to a falsy value: - -assert\\(false\\) -\\] { -code: 'ERR_TEST_FAILURE', -failureType: 'testCodeFailure', -cause: AssertionError \\[ERR_ASSERTION\\]: The expression evaluated to a falsy value: - - assert\\(false\\) - - at TestContext.* \\(.*/example.js:12:31\\) - at .* - at .* - at .* - at .* - at .* - at .* { - generatedMessage: true, - code: 'ERR_ASSERTION', - actual: false, - expected: true, - operator: '==' -} -} -\t\t\t -\t\t -\t -\t -\t\t -\t -\t -\t\t -\t -\t -\t\t -\t - -`, - overrides: { - 18: { - stdout: `<\\?xml version="1.0" encoding="utf-8"\\?> - -\t -\t\t -\t\t -\t\t\t -\\[Error \\[ERR_TEST_FAILURE\\]: this is an error\\] { - failureType: 'testCodeFailure', - cause: Error: this is an error - .* - .* - .* - .* - .* - .* - .* - .* - .* - code: 'ERR_TEST_FAILURE' -} -\t\t\t -\t\t -\t\t -\t\t -\t\t -\\[Error \\[ERR_TEST_FAILURE\\]: The expression evaluated to a falsy value: - -assert\\(false\\) -\\] { -failureType: 'testCodeFailure', -cause: AssertionError \\[ERR_ASSERTION\\]: The expression evaluated to a falsy value: - - assert\\(false\\) - - at TestContext.* \\(.*/example.js:12:31\\) - at .* - at .* - at .* - at .* - at .* - at .* { - generatedMessage: true, - code: 'ERR_ASSERTION', - actual: false, - expected: true, - operator: '==' -}, -code: 'ERR_TEST_FAILURE' -} -\t\t\t -\t\t -\t -\t -\t\t -\t -\t -\t\t -\t -\t -\t\t -\t - -`, - }, - }, -}; diff --git a/packages/mocha/.snapshots/1f0f93c51b9f571a9d899160525b1bcb/0.json b/packages/mocha/.snapshots/1f0f93c51b9f571a9d899160525b1bcb/0.json new file mode 100644 index 0000000..8f79c1a --- /dev/null +++ b/packages/mocha/.snapshots/1f0f93c51b9f571a9d899160525b1bcb/0.json @@ -0,0 +1,5 @@ +{ + "stderr": "", + "stdout": "\n\n tests\n ✔ is ok\n 1) fails\n ✔ is a diagnostic\n 2) should fail\n\n more tests\n ✔ is ok\n\n - is skipped\n - is a todo\n ✔ top level diagnostic\n\n 4 passing (*ms)\n 2 pending\n 2 failing\n\n 1) \n tests\n fails:\n Error [ERR_TEST_FAILURE]: this is an error\n at async Promise.all (index 0)\n\n 2) \n tests\n should fail:\n Error [ERR_TEST_FAILURE]: The expression evaluated to a falsy value:\n\n assert(false)\n\n \n\n\n\n", + "exitCode": 1 +} \ No newline at end of file diff --git a/packages/mocha/.snapshots/1f0f93c51b9f571a9d899160525b1bcb/1.json b/packages/mocha/.snapshots/1f0f93c51b9f571a9d899160525b1bcb/1.json new file mode 100644 index 0000000..b04c233 --- /dev/null +++ b/packages/mocha/.snapshots/1f0f93c51b9f571a9d899160525b1bcb/1.json @@ -0,0 +1,5 @@ +{ + "stderr": "", + "stdout": "\n\n 1) should fail\n ✔ should pass\n\n 1 passing (*ms)\n 1 failing\n\n 1) \n should fail:\n Error [ERR_TEST_FAILURE]: The expression evaluated to a falsy value:\n\n assert(false)\n\n \n\n\n\n", + "exitCode": 1 +} \ No newline at end of file diff --git a/packages/mocha/.snapshots/1f0f93c51b9f571a9d899160525b1bcb/2.json b/packages/mocha/.snapshots/1f0f93c51b9f571a9d899160525b1bcb/2.json new file mode 100644 index 0000000..fcad495 --- /dev/null +++ b/packages/mocha/.snapshots/1f0f93c51b9f571a9d899160525b1bcb/2.json @@ -0,0 +1,5 @@ +{ + "stderr": "", + "stdout": "{\n state: 'passed',\n isPending: false,\n currentRetry: 0,\n fullTitle: ' tests is ok'\n}\n{\n state: 'failed',\n isPending: false,\n currentRetry: 0,\n fullTitle: ' tests fails'\n}\n{\n state: 'passed',\n isPending: false,\n currentRetry: 0,\n fullTitle: ' tests is a diagnostic'\n}\n{\n state: 'failed',\n isPending: false,\n currentRetry: 0,\n fullTitle: ' tests should fail'\n}\n{\n state: 'passed',\n isPending: false,\n currentRetry: 0,\n fullTitle: ' more tests is ok'\n}\n{\n state: 'pending',\n isPending: true,\n currentRetry: 0,\n fullTitle: ' is skipped'\n}\n{\n state: 'pending',\n isPending: true,\n currentRetry: 0,\n fullTitle: ' is a todo'\n}\n{\n state: 'passed',\n isPending: false,\n currentRetry: 0,\n fullTitle: ' top level diagnostic'\n}\n", + "exitCode": 1 +} \ No newline at end of file diff --git a/packages/mocha/.snapshots/1f0f93c51b9f571a9d899160525b1bcb/3.json b/packages/mocha/.snapshots/1f0f93c51b9f571a9d899160525b1bcb/3.json new file mode 100644 index 0000000..fcad495 --- /dev/null +++ b/packages/mocha/.snapshots/1f0f93c51b9f571a9d899160525b1bcb/3.json @@ -0,0 +1,5 @@ +{ + "stderr": "", + "stdout": "{\n state: 'passed',\n isPending: false,\n currentRetry: 0,\n fullTitle: ' tests is ok'\n}\n{\n state: 'failed',\n isPending: false,\n currentRetry: 0,\n fullTitle: ' tests fails'\n}\n{\n state: 'passed',\n isPending: false,\n currentRetry: 0,\n fullTitle: ' tests is a diagnostic'\n}\n{\n state: 'failed',\n isPending: false,\n currentRetry: 0,\n fullTitle: ' tests should fail'\n}\n{\n state: 'passed',\n isPending: false,\n currentRetry: 0,\n fullTitle: ' more tests is ok'\n}\n{\n state: 'pending',\n isPending: true,\n currentRetry: 0,\n fullTitle: ' is skipped'\n}\n{\n state: 'pending',\n isPending: true,\n currentRetry: 0,\n fullTitle: ' is a todo'\n}\n{\n state: 'passed',\n isPending: false,\n currentRetry: 0,\n fullTitle: ' top level diagnostic'\n}\n", + "exitCode": 1 +} \ No newline at end of file diff --git a/packages/mocha/.snapshots/1f0f93c51b9f571a9d899160525b1bcb/4.json b/packages/mocha/.snapshots/1f0f93c51b9f571a9d899160525b1bcb/4.json new file mode 100644 index 0000000..0caf8dc --- /dev/null +++ b/packages/mocha/.snapshots/1f0f93c51b9f571a9d899160525b1bcb/4.json @@ -0,0 +1,5 @@ +{ + "stderr": "Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'invalid' imported from CWD/packages/mocha/index.js\n *\n *\n *\n *\n *\n *\n *\n *\n *\n * {\n code: 'ERR_MODULE_NOT_FOUND'\n}\nError: invalid reporter \"invalid\"\n *\n *\n", + "stdout": "", + "exitCode": 1 +} \ No newline at end of file diff --git a/packages/mocha/.snapshots/4353502ed400317a687af8c8312f2662/0.json b/packages/mocha/.snapshots/4353502ed400317a687af8c8312f2662/0.json new file mode 100644 index 0000000..699c53d --- /dev/null +++ b/packages/mocha/.snapshots/4353502ed400317a687af8c8312f2662/0.json @@ -0,0 +1,5 @@ +{ + "stderr": "", + "stdout": "\n\n tests\n ✔ is ok\n 1) fails\n ✔ is a diagnostic\n 2) should fail\n\n more tests\n ✔ is ok\n\n - is skipped\n - is a todo\n ✔ top level diagnostic\n\n 4 passing (*ms)\n 2 pending\n 2 failing\n\n 1) \n tests\n fails:\n Error [ERR_TEST_FAILURE]: this is an error\n \n\n 2) \n tests\n should fail:\n Error [ERR_TEST_FAILURE]: The expression evaluated to a falsy value:\n\n assert(false)\n\n \n\n\n\n", + "exitCode": 1 +} \ No newline at end of file diff --git a/packages/mocha/.snapshots/4353502ed400317a687af8c8312f2662/1.json b/packages/mocha/.snapshots/4353502ed400317a687af8c8312f2662/1.json new file mode 100644 index 0000000..14612cf --- /dev/null +++ b/packages/mocha/.snapshots/4353502ed400317a687af8c8312f2662/1.json @@ -0,0 +1,5 @@ +{ + "stderr": "", + "stdout": "\n\n 1) should fail\n ✔ should pass\n\n 1 passing (*ms)\n 1 failing\n\n 1) \n should fail:\n Error [ERR_TEST_FAILURE]: false == true\n \n\n\n\n", + "exitCode": 1 +} \ No newline at end of file diff --git a/packages/mocha/.snapshots/4353502ed400317a687af8c8312f2662/2.json b/packages/mocha/.snapshots/4353502ed400317a687af8c8312f2662/2.json new file mode 100644 index 0000000..fcad495 --- /dev/null +++ b/packages/mocha/.snapshots/4353502ed400317a687af8c8312f2662/2.json @@ -0,0 +1,5 @@ +{ + "stderr": "", + "stdout": "{\n state: 'passed',\n isPending: false,\n currentRetry: 0,\n fullTitle: ' tests is ok'\n}\n{\n state: 'failed',\n isPending: false,\n currentRetry: 0,\n fullTitle: ' tests fails'\n}\n{\n state: 'passed',\n isPending: false,\n currentRetry: 0,\n fullTitle: ' tests is a diagnostic'\n}\n{\n state: 'failed',\n isPending: false,\n currentRetry: 0,\n fullTitle: ' tests should fail'\n}\n{\n state: 'passed',\n isPending: false,\n currentRetry: 0,\n fullTitle: ' more tests is ok'\n}\n{\n state: 'pending',\n isPending: true,\n currentRetry: 0,\n fullTitle: ' is skipped'\n}\n{\n state: 'pending',\n isPending: true,\n currentRetry: 0,\n fullTitle: ' is a todo'\n}\n{\n state: 'passed',\n isPending: false,\n currentRetry: 0,\n fullTitle: ' top level diagnostic'\n}\n", + "exitCode": 1 +} \ No newline at end of file diff --git a/packages/mocha/.snapshots/4353502ed400317a687af8c8312f2662/3.json b/packages/mocha/.snapshots/4353502ed400317a687af8c8312f2662/3.json new file mode 100644 index 0000000..fcad495 --- /dev/null +++ b/packages/mocha/.snapshots/4353502ed400317a687af8c8312f2662/3.json @@ -0,0 +1,5 @@ +{ + "stderr": "", + "stdout": "{\n state: 'passed',\n isPending: false,\n currentRetry: 0,\n fullTitle: ' tests is ok'\n}\n{\n state: 'failed',\n isPending: false,\n currentRetry: 0,\n fullTitle: ' tests fails'\n}\n{\n state: 'passed',\n isPending: false,\n currentRetry: 0,\n fullTitle: ' tests is a diagnostic'\n}\n{\n state: 'failed',\n isPending: false,\n currentRetry: 0,\n fullTitle: ' tests should fail'\n}\n{\n state: 'passed',\n isPending: false,\n currentRetry: 0,\n fullTitle: ' more tests is ok'\n}\n{\n state: 'pending',\n isPending: true,\n currentRetry: 0,\n fullTitle: ' is skipped'\n}\n{\n state: 'pending',\n isPending: true,\n currentRetry: 0,\n fullTitle: ' is a todo'\n}\n{\n state: 'passed',\n isPending: false,\n currentRetry: 0,\n fullTitle: ' top level diagnostic'\n}\n", + "exitCode": 1 +} \ No newline at end of file diff --git a/packages/mocha/.snapshots/4353502ed400317a687af8c8312f2662/4.json b/packages/mocha/.snapshots/4353502ed400317a687af8c8312f2662/4.json new file mode 100644 index 0000000..0caf8dc --- /dev/null +++ b/packages/mocha/.snapshots/4353502ed400317a687af8c8312f2662/4.json @@ -0,0 +1,5 @@ +{ + "stderr": "Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'invalid' imported from CWD/packages/mocha/index.js\n *\n *\n *\n *\n *\n *\n *\n *\n *\n * {\n code: 'ERR_MODULE_NOT_FOUND'\n}\nError: invalid reporter \"invalid\"\n *\n *\n", + "stdout": "", + "exitCode": 1 +} \ No newline at end of file diff --git a/packages/mocha/.snapshots/dc3fc117f81a81ae79e191693864201a/0.json b/packages/mocha/.snapshots/dc3fc117f81a81ae79e191693864201a/0.json new file mode 100644 index 0000000..699c53d --- /dev/null +++ b/packages/mocha/.snapshots/dc3fc117f81a81ae79e191693864201a/0.json @@ -0,0 +1,5 @@ +{ + "stderr": "", + "stdout": "\n\n tests\n ✔ is ok\n 1) fails\n ✔ is a diagnostic\n 2) should fail\n\n more tests\n ✔ is ok\n\n - is skipped\n - is a todo\n ✔ top level diagnostic\n\n 4 passing (*ms)\n 2 pending\n 2 failing\n\n 1) \n tests\n fails:\n Error [ERR_TEST_FAILURE]: this is an error\n \n\n 2) \n tests\n should fail:\n Error [ERR_TEST_FAILURE]: The expression evaluated to a falsy value:\n\n assert(false)\n\n \n\n\n\n", + "exitCode": 1 +} \ No newline at end of file diff --git a/packages/mocha/.snapshots/dc3fc117f81a81ae79e191693864201a/1.json b/packages/mocha/.snapshots/dc3fc117f81a81ae79e191693864201a/1.json new file mode 100644 index 0000000..b04c233 --- /dev/null +++ b/packages/mocha/.snapshots/dc3fc117f81a81ae79e191693864201a/1.json @@ -0,0 +1,5 @@ +{ + "stderr": "", + "stdout": "\n\n 1) should fail\n ✔ should pass\n\n 1 passing (*ms)\n 1 failing\n\n 1) \n should fail:\n Error [ERR_TEST_FAILURE]: The expression evaluated to a falsy value:\n\n assert(false)\n\n \n\n\n\n", + "exitCode": 1 +} \ No newline at end of file diff --git a/packages/mocha/.snapshots/dc3fc117f81a81ae79e191693864201a/2.json b/packages/mocha/.snapshots/dc3fc117f81a81ae79e191693864201a/2.json new file mode 100644 index 0000000..fcad495 --- /dev/null +++ b/packages/mocha/.snapshots/dc3fc117f81a81ae79e191693864201a/2.json @@ -0,0 +1,5 @@ +{ + "stderr": "", + "stdout": "{\n state: 'passed',\n isPending: false,\n currentRetry: 0,\n fullTitle: ' tests is ok'\n}\n{\n state: 'failed',\n isPending: false,\n currentRetry: 0,\n fullTitle: ' tests fails'\n}\n{\n state: 'passed',\n isPending: false,\n currentRetry: 0,\n fullTitle: ' tests is a diagnostic'\n}\n{\n state: 'failed',\n isPending: false,\n currentRetry: 0,\n fullTitle: ' tests should fail'\n}\n{\n state: 'passed',\n isPending: false,\n currentRetry: 0,\n fullTitle: ' more tests is ok'\n}\n{\n state: 'pending',\n isPending: true,\n currentRetry: 0,\n fullTitle: ' is skipped'\n}\n{\n state: 'pending',\n isPending: true,\n currentRetry: 0,\n fullTitle: ' is a todo'\n}\n{\n state: 'passed',\n isPending: false,\n currentRetry: 0,\n fullTitle: ' top level diagnostic'\n}\n", + "exitCode": 1 +} \ No newline at end of file diff --git a/packages/mocha/.snapshots/dc3fc117f81a81ae79e191693864201a/3.json b/packages/mocha/.snapshots/dc3fc117f81a81ae79e191693864201a/3.json new file mode 100644 index 0000000..fcad495 --- /dev/null +++ b/packages/mocha/.snapshots/dc3fc117f81a81ae79e191693864201a/3.json @@ -0,0 +1,5 @@ +{ + "stderr": "", + "stdout": "{\n state: 'passed',\n isPending: false,\n currentRetry: 0,\n fullTitle: ' tests is ok'\n}\n{\n state: 'failed',\n isPending: false,\n currentRetry: 0,\n fullTitle: ' tests fails'\n}\n{\n state: 'passed',\n isPending: false,\n currentRetry: 0,\n fullTitle: ' tests is a diagnostic'\n}\n{\n state: 'failed',\n isPending: false,\n currentRetry: 0,\n fullTitle: ' tests should fail'\n}\n{\n state: 'passed',\n isPending: false,\n currentRetry: 0,\n fullTitle: ' more tests is ok'\n}\n{\n state: 'pending',\n isPending: true,\n currentRetry: 0,\n fullTitle: ' is skipped'\n}\n{\n state: 'pending',\n isPending: true,\n currentRetry: 0,\n fullTitle: ' is a todo'\n}\n{\n state: 'passed',\n isPending: false,\n currentRetry: 0,\n fullTitle: ' top level diagnostic'\n}\n", + "exitCode": 1 +} \ No newline at end of file diff --git a/packages/mocha/.snapshots/dc3fc117f81a81ae79e191693864201a/4.json b/packages/mocha/.snapshots/dc3fc117f81a81ae79e191693864201a/4.json new file mode 100644 index 0000000..0caf8dc --- /dev/null +++ b/packages/mocha/.snapshots/dc3fc117f81a81ae79e191693864201a/4.json @@ -0,0 +1,5 @@ +{ + "stderr": "Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'invalid' imported from CWD/packages/mocha/index.js\n *\n *\n *\n *\n *\n *\n *\n *\n *\n * {\n code: 'ERR_MODULE_NOT_FOUND'\n}\nError: invalid reporter \"invalid\"\n *\n *\n", + "stdout": "", + "exitCode": 1 +} \ No newline at end of file diff --git a/packages/mocha/CHANGELOG.md b/packages/mocha/CHANGELOG.md new file mode 100644 index 0000000..0638c0c --- /dev/null +++ b/packages/mocha/CHANGELOG.md @@ -0,0 +1,20 @@ +# Changelog + +## [1.0.1](https://github.com/MoLow/reporters/compare/mocha-v1.0.0...mocha-v1.0.1) (2024-03-14) + + +### Bug Fixes + +* mochaawsome broken ([#122](https://github.com/MoLow/reporters/issues/122)) ([6b9dced](https://github.com/MoLow/reporters/commit/6b9dced7219fd24af5d3fe2e810806b265ac1007)) + + +### Documentation + +* fix .mocharc example ([#119](https://github.com/MoLow/reporters/issues/119)) ([348e806](https://github.com/MoLow/reporters/commit/348e8060be26632dbdd2df824f92815039cbce75)) + +## 1.0.0 (2024-03-14) + + +### Features + +* add mocha reporter ([#116](https://github.com/MoLow/reporters/issues/116)) ([90ef449](https://github.com/MoLow/reporters/commit/90ef4490665e19cab1ceebf8a77e78b54e38f668)) diff --git a/packages/mocha/README.md b/packages/mocha/README.md new file mode 100644 index 0000000..0d36af2 --- /dev/null +++ b/packages/mocha/README.md @@ -0,0 +1,32 @@ +[![npm version](https://img.shields.io/npm/v/@reporters/mocha)](https://www.npmjs.com/package/@reporters/mocha) ![tests](https://github.com/MoLow/reporters/actions/workflows/test.yaml/badge.svg?branch=main) [![codecov](https://codecov.io/gh/MoLow/reporters/branch/main/graph/badge.svg?token=0LFVC8SCQV)](https://codecov.io/gh/MoLow/reporters) + +# Mocha reporters for `node:test` +Use this custom reporter to use [mocha reporters](https://mochajs.org/#reporters) with `node:test`. +Both built-in and custom mocha reporters such as [mochawesome](https://www.npmjs.com/package/mochawesome) are supported. + +## Installation + +```bash +npm install --save-dev @reporters/mocha +``` +or +```bash +yarn add --dev @reporters/mocha +``` + +## Usage + +Specify the desired mocha reporter inside the [mocha configuration file](https://mochajs.org/#configuring-mocha-nodejs), e.g. `.mocharc.js`: +```js +module.exports = { + reporter: 'nyan' +} +``` + +Then run the tests with `node:test`: + +```bash +node --test --test-reporter=@reporters/mocha +``` + + diff --git a/packages/mocha/index.js b/packages/mocha/index.js new file mode 100644 index 0000000..2906834 --- /dev/null +++ b/packages/mocha/index.js @@ -0,0 +1,241 @@ +/* eslint-disable class-methods-use-this */ +/* eslint-disable no-underscore-dangle */ +/* eslint-disable max-classes-per-file */ + +'use strict'; + +const { EventEmitter } = require('node:events'); +const Mocha = require('mocha'); +const { loadOptions } = require('mocha/lib/cli'); + +const { + EVENT_RUN_BEGIN, + EVENT_RUN_END, + EVENT_TEST_FAIL, + EVENT_TEST_PENDING, + EVENT_TEST_PASS, + EVENT_TEST_BEGIN, + EVENT_TEST_END, + EVENT_SUITE_BEGIN, + EVENT_SUITE_END, +} = Mocha.Runner.constants; + +const { + STATE_FAILED, + STATE_PASSED, + STATE_PENDING, +} = Mocha.Runnable.constants; + +class Test { + #mochaOptions; + + constructor(parent = null, mochaOptions = {}) { + this.title = ''; + this.file = ''; + this.pending = false; + this.duration = 0; + this.err = null; + this.nesting = 0; + this.parent = parent; + this.root = !parent; + this.children = []; + this.#mochaOptions = mochaOptions; + + this.body = ''; + this._beforeAll = []; + this._beforeEach = []; + this._afterAll = []; + this._afterEach = []; + } + + applyTestEvent(event, passed) { + this.title = event.data.name; + this.file = event.data.file; + this.pending = Boolean(event.data.skip || event.data.todo); + this.duration = event.data.details?.duration_ms; + this.err = event.data.details?.error; + this.passed = passed; + this.nesting = event.data.nesting; + } + + get state() { + if (this.pending) { + return STATE_PENDING; + } + if (this.passed) { + return STATE_PASSED; + } + return STATE_FAILED; + } + + isPending() { + return this.pending; + } + + slow() { + return this.#mochaOptions.slow ?? 75; + } + + currentRetry() { + return 0; + } + + titlePath() { + const parentTitle = this.parent?.titlePath() ?? []; + return parentTitle.concat(this.title); + } + + fullTitle() { + return this.titlePath().join(' '); + } + + finalize() { + this.suites = this._suites; + this.tests = this._tests; + } + + get _suites() { + return this.children.filter((child) => child.children.length > 0); + } + + get _tests() { + return this.children.filter((child) => child.children.length === 0); + } +} + +class Runner extends EventEmitter { + stats = { + suites: 0, + tests: 0, + passes: 0, + pending: 0, + failures: 0, + start: new Date(), + end: null, + duration: null, + }; + + #reporter; + + #root = new Test(); + + #current = this.#root; + + #mochaOptions = loadOptions([]); + + async init() { + const reporterName = this.#mochaOptions.reporter ?? 'spec'; + let Reporter; + if (typeof reporterName === 'function') { + Reporter = reporterName; + } else if (Mocha.reporters[reporterName]) { + Reporter = Mocha.reporters[reporterName]; + } else { + try { + Reporter = await import(reporterName).then((m) => m.default || m); + } catch (err) { + console.error(err); + } + } + if (!Reporter) { + console.error(new Error(`invalid reporter "${reporterName}"`)); + return; + } + this.#reporter = new Reporter(this, this.#mochaOptions); + this.emit(EVENT_RUN_BEGIN); + } + + get suite() { + return this.#current; + } + + end() { + if (!this.#reporter) { + return; + } + this.stats.end = new Date(); + this.stats.duration = this.stats.end - this.stats.start; + this.#report(); + this.emit(EVENT_RUN_END); + if (typeof this.#reporter.done === 'function') { + this.#reporter.done(this.stats.failures, () => {}); + } + } + + #report(suite = this.#root) { + /* Not like mocha, node:test runs tests as soon as they are encountered + so the exact structure is unkown until all suites end */ + this.emit(EVENT_SUITE_BEGIN, suite); + suite.finalize(); + for (const s of suite.suites) { + this.#report(s); + } + for (const test of suite.tests) { + this.emit(EVENT_TEST_BEGIN, test); + if (test.pending) { + this.emit(EVENT_TEST_PENDING, test); + } else if (!test.passed) { + this.emit(EVENT_TEST_FAIL, test, test.err); + } else { + this.emit(EVENT_TEST_PASS, test); + } + this.emit(EVENT_TEST_END, test); + } + this.emit(EVENT_SUITE_END, suite); + } + + addChild(event, passed) { + const current = this.#current; + this.#current = new Test(current); + this.#current.applyTestEvent(event, passed); + current.children.push(this.#current); + } + + isNewTest(event) { + return this.#current.title !== event.data.name || this.#current.nesting !== event.data.nesting; + } + + childCompleted(event, passed) { + this.#current.applyTestEvent(event, passed); + if (this.#current?.nesting === event.data.nesting) { + if (this.#current.children.length > 0) { + this.stats.suites += 1; + } else if (this.#current.pending) { + this.stats.tests += 1; + this.stats.pending += 1; + } else if (!this.#current.passed) { + this.stats.tests += 1; + this.stats.failures += 1; + } else { + this.stats.tests += 1; + this.stats.passes += 1; + } + this.#current = this.#current.parent; + } + } +} + +module.exports = async function mochaReporter(source) { + const runner = new Runner(); + await runner.init(); + + for await (const event of source) { + switch (event.type) { + case 'test:start': + runner.addChild(event, false); + break; + case 'test:pass': + case 'test:fail': { + if (runner.isNewTest(event)) { + runner.addChild(event, event.type === 'test:pass'); + } + runner.childCompleted(event, event.type === 'test:pass'); + break; + } + default: + break; + } + } + + runner.end(); +}; diff --git a/packages/mocha/package.json b/packages/mocha/package.json new file mode 100644 index 0000000..acaffb5 --- /dev/null +++ b/packages/mocha/package.json @@ -0,0 +1,30 @@ +{ + "name": "@reporters/mocha", + "version": "1.0.1", + "description": "use any mocha reporter with `node:test`", + "type": "commonjs", + "keywords": [ + "node:test", + "test", + "mocha", + "reporter", + "reporters" + ], + "files": [ + "./index.js" + ], + "scripts": { + "test": "node --test-reporter=spec --test-reporter-destination=stdout --test-reporter=../github/index.js --test-reporter-destination=stdout --test" + }, + "bugs": { + "url": "https://github.com/MoLow/reporters/issues" + }, + "main": "index.js", + "homepage": "https://github.com/MoLow/reporters/tree/main/packages/mocha", + "repository": "https://github.com/MoLow/reporters.git", + "author": "Moshe Atlow", + "license": "MIT", + "dependencies": { + "mocha": "^10.3.0" + } +} diff --git a/packages/mocha/tests/.mocharc.json b/packages/mocha/tests/.mocharc.json new file mode 100644 index 0000000..f1ef82d --- /dev/null +++ b/packages/mocha/tests/.mocharc.json @@ -0,0 +1,3 @@ +{ + "reporter": "list" +} \ No newline at end of file diff --git a/packages/mocha/tests/customReporter/.mocharc.js b/packages/mocha/tests/customReporter/.mocharc.js new file mode 100644 index 0000000..356f3b2 --- /dev/null +++ b/packages/mocha/tests/customReporter/.mocharc.js @@ -0,0 +1,5 @@ +const Reporter = require('./reporter.js'); + +module.exports = { + reporter: Reporter +}; diff --git a/packages/mocha/tests/customReporter/reporter.js b/packages/mocha/tests/customReporter/reporter.js new file mode 100644 index 0000000..9a10c33 --- /dev/null +++ b/packages/mocha/tests/customReporter/reporter.js @@ -0,0 +1,25 @@ +/* eslint-disable class-methods-use-this */ + +'use strict'; + +const assert = require('assert'); + +class Reporter { + constructor(runner) { + assert(runner.suite, 'missing root suite'); + runner.on('test end', (test) => { + console.log({ + state: test.state, + isPending: test.isPending(), + currentRetry: test.currentRetry(), + fullTitle: test.fullTitle(), + }); + }); + } + + done(failures, fn) { + fn(); + } +} + +module.exports = Reporter; diff --git a/packages/mocha/tests/importReporter/.mocharc.json b/packages/mocha/tests/importReporter/.mocharc.json new file mode 100644 index 0000000..2f2d60f --- /dev/null +++ b/packages/mocha/tests/importReporter/.mocharc.json @@ -0,0 +1,3 @@ +{ + "reporter": "./tests/customReporter/reporter.js" +} \ No newline at end of file diff --git a/packages/mocha/tests/index.test.js b/packages/mocha/tests/index.test.js new file mode 100644 index 0000000..f6ffb9a --- /dev/null +++ b/packages/mocha/tests/index.test.js @@ -0,0 +1,43 @@ +'use strict'; + +const { test } = require('node:test'); +const { resolve } = require('node:path'); +const { spawnSync } = require('node:child_process'); +const assert = require('assert'); +const { Snap, nodeMajor } = require('../../../tests/utils'); +const reporter = require('../index'); + +const snapshot = Snap(`${__filename}.${nodeMajor}`); + +test('spwan with reporter', async () => { + const child = spawnSync(process.execPath, ['--test-reporter', './index.js', '../../tests/example'], { env: {} }); + await snapshot(child); +}); + +test('spwan with reporter - esm', async () => { + const child = spawnSync(process.execPath, ['--test-reporter', './index.js', '../../tests/example.mjs'], { env: {} }); + await snapshot(child); +}); + +test('custom reporter - file', async () => { + const child = spawnSync(process.execPath, ['--test-reporter', '../../index.js', '../../../../tests/example.js'], { env: {}, cwd: resolve('./tests/customReporter') }); + await snapshot(child); +}); + +test('custom reporter - function', async () => { + const child = spawnSync(process.execPath, ['--test-reporter', '../../index.js', '../../../../tests/example.js'], { env: {}, cwd: resolve('./tests/importReporter') }); + await snapshot(child); +}); + +test('reporter not found', async () => { + const child = spawnSync(process.execPath, ['--test-reporter', '../../index.js', '../../../../tests/example.js'], { env: {}, cwd: resolve('./tests/invalidReporter') }); + await snapshot(child); +}); + +test('empty', async () => { + await assert.doesNotReject(reporter([])); +}); + +test('single test', async () => { + await assert.doesNotReject(reporter([{ type: 'test:pass', data: { name: 'test', nesting: 0, details: { duration_ms: 100 } } }])); +}); diff --git a/packages/mocha/tests/invalidReporter/.mocharc.json b/packages/mocha/tests/invalidReporter/.mocharc.json new file mode 100644 index 0000000..2ea6345 --- /dev/null +++ b/packages/mocha/tests/invalidReporter/.mocharc.json @@ -0,0 +1,3 @@ +{ + "reporter": "invalid" +} \ No newline at end of file diff --git a/packages/silent/.snapshots/bc72bb2843f04838a97cba748b6c200f/0.json b/packages/silent/.snapshots/bc72bb2843f04838a97cba748b6c200f/0.json new file mode 100644 index 0000000..6b29232 --- /dev/null +++ b/packages/silent/.snapshots/bc72bb2843f04838a97cba748b6c200f/0.json @@ -0,0 +1,5 @@ +{ + "stderr": "", + "stdout": "", + "exitCode": 1 +} \ No newline at end of file diff --git a/packages/silent/.snapshots/bc72bb2843f04838a97cba748b6c200f/1.json b/packages/silent/.snapshots/bc72bb2843f04838a97cba748b6c200f/1.json new file mode 100644 index 0000000..6b29232 --- /dev/null +++ b/packages/silent/.snapshots/bc72bb2843f04838a97cba748b6c200f/1.json @@ -0,0 +1,5 @@ +{ + "stderr": "", + "stdout": "", + "exitCode": 1 +} \ No newline at end of file diff --git a/packages/silent/CHANGELOG.md b/packages/silent/CHANGELOG.md index 1ce0e25..6f2a03b 100644 --- a/packages/silent/CHANGELOG.md +++ b/packages/silent/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## [1.2.5](https://github.com/MoLow/reporters/compare/silent-v1.2.4...silent-v1.2.5) (2024-03-14) + + +### Tests + +* migrate snapshots to snap ([#114](https://github.com/MoLow/reporters/issues/114)) ([1d3ca6a](https://github.com/MoLow/reporters/commit/1d3ca6ad12b4abb5c47adc775b47c205a4214e0a)) + ## [1.2.4](https://github.com/MoLow/reporters/compare/silent-v1.2.3...silent-v1.2.4) (2023-09-26) diff --git a/packages/silent/package.json b/packages/silent/package.json index 53b8bc2..23e2bba 100644 --- a/packages/silent/package.json +++ b/packages/silent/package.json @@ -1,6 +1,6 @@ { "name": "@reporters/silent", - "version": "1.2.4", + "version": "1.2.5", "description": "A silent reporter for `node:test`", "type": "commonjs", "keywords": [ diff --git a/packages/silent/tests/index.test.js b/packages/silent/tests/index.test.js index ef8707b..698ceeb 100644 --- a/packages/silent/tests/index.test.js +++ b/packages/silent/tests/index.test.js @@ -2,16 +2,16 @@ const { test } = require('node:test'); const { spawnSync } = require('child_process'); -const assert = require('assert'); +const { Snap } = require('../../../tests/utils'); -test('spwan with reporter', () => { +const snapshot = Snap(__filename); + +test('spwan with reporter', async () => { const child = spawnSync(process.execPath, ['--test-reporter', './index.js', '../../tests/example'], { env: {} }); - assert.strictEqual(child.stderr?.toString(), ''); - assert.strictEqual(child.stdout?.toString(), ''); + await snapshot(child); }); -test('spwan with reporter - esm', () => { +test('spwan with reporter - esm', async () => { const child = spawnSync(process.execPath, ['--test-reporter', './index.js', '../../tests/example.mjs'], { env: {} }); - assert.strictEqual(child.stderr?.toString(), ''); - assert.strictEqual(child.stdout?.toString(), ''); + await snapshot(child); }); diff --git a/packages/slow/.snapshots/bc72bb2843f04838a97cba748b6c200f/0.json b/packages/slow/.snapshots/bc72bb2843f04838a97cba748b6c200f/0.json new file mode 100644 index 0000000..b28a11c --- /dev/null +++ b/packages/slow/.snapshots/bc72bb2843f04838a97cba748b6c200f/0.json @@ -0,0 +1,5 @@ +{ + "stderr": "", + "stdout": "file: CWD/tests/slow_tests.js has slow tests:\n *\n *\n *\n", + "exitCode": 1 +} \ No newline at end of file diff --git a/packages/slow/CHANGELOG.md b/packages/slow/CHANGELOG.md index ef4a5ac..f3b6ef5 100644 --- a/packages/slow/CHANGELOG.md +++ b/packages/slow/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## [1.0.1](https://github.com/MoLow/reporters/compare/slow-v1.0.0...slow-v1.0.1) (2024-03-14) + + +### Tests + +* migrate snapshots to snap ([#114](https://github.com/MoLow/reporters/issues/114)) ([1d3ca6a](https://github.com/MoLow/reporters/commit/1d3ca6ad12b4abb5c47adc775b47c205a4214e0a)) + ## 1.0.0 (2024-01-04) diff --git a/packages/slow/package.json b/packages/slow/package.json index 3b95c11..3309f87 100644 --- a/packages/slow/package.json +++ b/packages/slow/package.json @@ -1,6 +1,6 @@ { "name": "@reporters/slow", - "version": "1.0.0", + "version": "1.0.1", "description": "A slow tests reporter for `node:test`", "type": "commonjs", "keywords": [ diff --git a/packages/slow/tests/index.test.js b/packages/slow/tests/index.test.js index a9be7fd..6a4d6b7 100644 --- a/packages/slow/tests/index.test.js +++ b/packages/slow/tests/index.test.js @@ -1,17 +1,12 @@ 'use strict'; -const assert = require('assert'); const { test } = require('node:test'); const { spawnSync } = require('child_process'); -const { compareLines } = require('../../../tests/utils'); +const { Snap } = require('../../../tests/utils'); -test('spwan with reporter', () => { +const snapshot = Snap(__filename); + +test('spwan with reporter', async () => { const child = spawnSync(process.execPath, ['--test-reporter', './index.js', '../../tests/slow_tests.js'], { env: { FORCE_COLOR: 1 } }); - assert.strictEqual(child.stderr?.toString(), ''); - compareLines(child.stdout?.toString(), `\ -file: .*tests/slow_tests\\.js has slow tests: - \\\x1B\\[31m-\\\x1B\\[0m is too slow \\[\x1B\\[31m1s\\\x1B\\[0m\\] \\(\\\x1B\\[0m.*tests/slow_tests\\.js:9:3\\) - \\\x1B\\[38;5;215m-\\\x1B\\[0m is pretty slow \\[\\\x1B\\[38;5;215m.*ms\\\x1B\\[0m\\] \\(\\\x1B\\[0m.*tests/slow_tests\\.js:8:3\\) - \\\x1B\\[33m-\\\x1B\\[0m is a little slow \\[\x1B\\[33m.*ms\\\x1B\\[0m\\] \\(\\\x1B\\[0m.*tests/slow_tests\\.js:7:3\\) -`); + await snapshot(child); }); diff --git a/release-please-config.json b/release-please-config.json index 98c13f0..0ecfb92 100644 --- a/release-please-config.json +++ b/release-please-config.json @@ -19,6 +19,7 @@ "packages/silent": {}, "packages/bail": {}, "packages/testwatch": {}, - "packages/slow": {} + "packages/slow": {}, + "packages/mocha": {} } } diff --git a/tests/example.js b/tests/example.js index 7a0e9b7..da9e06b 100644 --- a/tests/example.js +++ b/tests/example.js @@ -17,3 +17,5 @@ describe('more tests', () => { }); it.skip('is skipped', () => {}); it.todo('is a todo'); + +test('top level diagnostic', async (t) => { t.diagnostic('top level diagnostic'); }); diff --git a/tests/utils.js b/tests/utils.js index f711434..06350f4 100644 --- a/tests/utils.js +++ b/tests/utils.js @@ -1,23 +1,44 @@ 'use strict'; -/* eslint-disable no-console */ -const assert = require('assert'); +const assert = require('node:assert'); +const { hostname } = require('node:os'); +const { resolve } = require('node:path'); +// eslint-disable-next-line import/no-unresolved +const Snap = require('@matteo.collina/snap'); -function compareLines(output = '', expected = '') { - const outputLines = output.split(/\r?\n/); - const expectedLines = expected.split(/\r?\n/); - if (outputLines.length !== expectedLines.length) { - console.log(output); - console.log(expected); - assert.strictEqual(outputLines.length, expectedLines.length, 'Output and expected have different number of lines'); - } - for (let i = 0; i < expectedLines.length; i += 1) { - const expectedRegex = new RegExp(expectedLines[i]); - assert.match(outputLines[i], expectedRegex, `Line ${i} did not match`); +const nodeMajor = process.versions.node.split('.')[0]; + +function sanitize(str) { + return str + .replaceAll(resolve(process.cwd(), '../../'), 'CWD') + .replaceAll(process.version, '*') + .replaceAll(/[0-9.]+ms/g, '*ms') + .replaceAll(hostname(), 'HOSTNAME') + .replaceAll(/time="[0-9.]+"/g, 'time="*"') + .replaceAll(/test_runner\/harness:[0-9.]+\n/g, 'test_runner/harness:*\n') + .replace(/(?<=\n)(\s+)((.+?)\s+\()?(?:\(?(.+?):(\d+)(?::(\d+))?)\)?(\s+\{)?(\[\d+m)?(\n|$)/g, '$1*$7$8\n'); +} + +function snapshot(filename) { + const snap = Snap(filename); + async function test(child, ...args) { + const actual = { + stderr: sanitize(child.stderr?.toString() ?? ''), + stdout: sanitize(child.stdout?.toString() ?? ''), + exitCode: child.status, + }; + assert.deepStrictEqual(actual, await snap(actual)); + for (const arg of args) { + const a = typeof arg === 'string' ? sanitize(arg) : arg; + // eslint-disable-next-line no-await-in-loop + assert.deepStrictEqual(a, await snap(a)); + } } - return true; + test.snap = snap; + return test; } module.exports = { - compareLines, + Snap: snapshot, + nodeMajor, }; diff --git a/yarn.lock b/yarn.lock index d63f22c..1795546 100644 --- a/yarn.lock +++ b/yarn.lock @@ -91,6 +91,14 @@ "@jridgewell/resolve-uri" "3.1.0" "@jridgewell/sourcemap-codec" "1.4.14" +"@matteo.collina/snap@^0.2.1": + version "0.2.1" + resolved "https://registry.yarnpkg.com/@matteo.collina/snap/-/snap-0.2.1.tgz#597b2aaa27098930d7e54b9f8fa4fb0bab2e0783" + integrity sha512-rXCDKwOhAHzjmHUxEjKcmhvuhzF6gY0JWhpol9lTA+n5V1yTrbKNHNCe5ovxZjPw25PusmIEbYBIswC3ZUjhNQ== + dependencies: + find-up "^7.0.0" + slash "^5.1.0" + "@nodelib/fs.scandir@2.1.5": version "2.1.5" resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5" @@ -147,6 +155,11 @@ ajv@^6.10.0, ajv@^6.12.4: json-schema-traverse "^0.4.1" uri-js "^4.2.2" +ansi-colors@4.1.1: + version "4.1.1" + resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-4.1.1.tgz#cbb9ae256bf750af1eab344f229aa27fe94ba348" + integrity sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA== + ansi-regex@^5.0.1: version "5.0.1" resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304" @@ -169,6 +182,14 @@ ansi-styles@^6.1.0: resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-6.2.1.tgz#0e62320cf99c21afff3b3012192546aacbfb05c5" integrity sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug== +anymatch@~3.1.2: + version "3.1.3" + resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-3.1.3.tgz#790c58b19ba1720a84205b57c618d5ad8524973e" + integrity sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw== + dependencies: + normalize-path "^3.0.0" + picomatch "^2.0.4" + argparse@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/argparse/-/argparse-2.0.1.tgz#246f50f3ca78a3240f6c997e8a9bd1eac49e4b38" @@ -200,6 +221,11 @@ balanced-match@^1.0.0: resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== +binary-extensions@^2.0.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.2.0.tgz#75f502eeaf9ffde42fc98829645be4ea76bd9e2d" + integrity sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA== + brace-expansion@^1.1.7: version "1.1.11" resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" @@ -215,6 +241,18 @@ brace-expansion@^2.0.1: dependencies: balanced-match "^1.0.0" +braces@~3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107" + integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A== + dependencies: + fill-range "^7.0.1" + +browser-stdout@1.3.1: + version "1.3.1" + resolved "https://registry.yarnpkg.com/browser-stdout/-/browser-stdout-1.3.1.tgz#baa559ee14ced73452229bad7326467c61fabd60" + integrity sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw== + c8@^7.13.0: version "7.13.0" resolved "https://registry.yarnpkg.com/c8/-/c8-7.13.0.tgz#a2a70a851278709df5a9247d62d7f3d4bcb5f2e4" @@ -246,7 +284,12 @@ callsites@^3.0.0: resolved "https://registry.yarnpkg.com/callsites/-/callsites-3.1.0.tgz#b3630abd8943432f54b3f0519238e33cd7df2f73" integrity sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ== -chalk@^4.0.0, chalk@^4.1.1: +camelcase@^6.0.0: + version "6.3.0" + resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-6.3.0.tgz#5685b95eb209ac9c0c177467778c9c84df58ba9a" + integrity sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA== + +chalk@^4.0.0, chalk@^4.1.0, chalk@^4.1.1: version "4.1.2" resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01" integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA== @@ -254,6 +297,21 @@ chalk@^4.0.0, chalk@^4.1.1: ansi-styles "^4.1.0" supports-color "^7.1.0" +chokidar@3.5.3: + version "3.5.3" + resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.5.3.tgz#1cf37c8707b932bd1af1ae22c0432e2acd1903bd" + integrity sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw== + dependencies: + anymatch "~3.1.2" + braces "~3.0.2" + glob-parent "~5.1.2" + is-binary-path "~2.1.0" + is-glob "~4.0.1" + normalize-path "~3.0.0" + readdirp "~3.6.0" + optionalDependencies: + fsevents "~2.3.2" + cliui@^7.0.2: version "7.0.4" resolved "https://registry.yarnpkg.com/cliui/-/cliui-7.0.4.tgz#a0265ee655476fc807aea9df3df8df7783808b4f" @@ -299,6 +357,13 @@ cross-spawn@^7.0.0, cross-spawn@^7.0.2: shebang-command "^2.0.0" which "^2.0.1" +debug@4.3.4, debug@^4.1.1, debug@^4.3.2: + version "4.3.4" + resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865" + integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ== + dependencies: + ms "2.1.2" + debug@^2.6.9: version "2.6.9" resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" @@ -313,12 +378,10 @@ debug@^3.2.7: dependencies: ms "^2.1.1" -debug@^4.1.1, debug@^4.3.2: - version "4.3.4" - resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865" - integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ== - dependencies: - ms "2.1.2" +decamelize@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-4.0.0.tgz#aa472d7bf660eb15f3494efd531cab7f2a709837" + integrity sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ== deep-is@^0.1.3: version "0.1.4" @@ -333,6 +396,11 @@ define-properties@^1.1.3, define-properties@^1.1.4: has-property-descriptors "^1.0.0" object-keys "^1.1.1" +diff@5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/diff/-/diff-5.0.0.tgz#7ed6ad76d859d030787ec35855f5b1daf31d852b" + integrity sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w== + doctrine@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-2.1.0.tgz#5cd01fc101621b42c4cd7f5d1a66243716d3f39d" @@ -414,16 +482,16 @@ escalade@^3.1.1: resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.1.tgz#d8cfdc7000965c5a0174b4a82eaa5c0552742e40" integrity sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw== +escape-string-regexp@4.0.0, escape-string-regexp@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34" + integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA== + escape-string-regexp@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz#a30304e99daa32e23b2fd20f51babd07cffca344" integrity sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w== -escape-string-regexp@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34" - integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA== - eslint-config-airbnb-base@^15.0.0: version "15.0.0" resolved "https://registry.yarnpkg.com/eslint-config-airbnb-base/-/eslint-config-airbnb-base-15.0.0.tgz#6b09add90ac79c2f8d723a2580e07f3925afd236" @@ -600,7 +668,14 @@ file-entry-cache@^6.0.1: dependencies: flat-cache "^3.0.4" -find-up@^5.0.0: +fill-range@^7.0.1: + version "7.0.1" + resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.0.1.tgz#1919a6a7c75fe38b2c7c77e5198535da9acdda40" + integrity sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ== + dependencies: + to-regex-range "^5.0.1" + +find-up@5.0.0, find-up@^5.0.0: version "5.0.0" resolved "https://registry.yarnpkg.com/find-up/-/find-up-5.0.0.tgz#4c92819ecb7083561e4f4a240a86be5198f536fc" integrity sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng== @@ -608,6 +683,15 @@ find-up@^5.0.0: locate-path "^6.0.0" path-exists "^4.0.0" +find-up@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/find-up/-/find-up-7.0.0.tgz#e8dec1455f74f78d888ad65bf7ca13dd2b4e66fb" + integrity sha512-YyZM99iHrqLKjmt4LJDj58KI+fYyufRLBSYcqycxf//KpBk9FoewoGX0450m9nB44qrZnovzC2oeP5hUibxc/g== + dependencies: + locate-path "^7.2.0" + path-exists "^5.0.0" + unicorn-magic "^0.1.0" + flat-cache@^3.0.4: version "3.0.4" resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-3.0.4.tgz#61b0338302b2fe9f957dcc32fc2a87f1c3048b11" @@ -616,6 +700,11 @@ flat-cache@^3.0.4: flatted "^3.1.0" rimraf "^3.0.2" +flat@^5.0.2: + version "5.0.2" + resolved "https://registry.yarnpkg.com/flat/-/flat-5.0.2.tgz#8ca6fe332069ffa9d324c327198c598259ceb241" + integrity sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ== + flatted@^3.1.0: version "3.2.7" resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.2.7.tgz#609f39207cb614b89d0765b477cb2d437fbf9787" @@ -642,6 +731,11 @@ fs.realpath@^1.0.0: resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw== +fsevents@~2.3.2: + version "2.3.3" + resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.3.tgz#cac6407785d03675a2a5e1a5305c697b347d90d6" + integrity sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw== + function-bind@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d" @@ -691,6 +785,24 @@ glob-parent@^6.0.2: dependencies: is-glob "^4.0.3" +glob-parent@~5.1.2: + version "5.1.2" + resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4" + integrity sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow== + dependencies: + is-glob "^4.0.1" + +glob@8.1.0: + version "8.1.0" + resolved "https://registry.yarnpkg.com/glob/-/glob-8.1.0.tgz#d388f656593ef708ee3e34640fdfb99a9fd1c33e" + integrity sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ== + dependencies: + fs.realpath "^1.0.0" + inflight "^1.0.4" + inherits "2" + minimatch "^5.0.1" + once "^1.3.0" + glob@^10.2.6: version "10.2.6" resolved "https://registry.yarnpkg.com/glob/-/glob-10.2.6.tgz#1e27edbb3bbac055cb97113e27a066c100a4e5e1" @@ -769,6 +881,11 @@ has@^1.0.3: dependencies: function-bind "^1.1.1" +he@1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/he/-/he-1.2.0.tgz#84ae65fa7eafb165fddb61566ae14baf05664f0f" + integrity sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw== + html-escaper@^2.0.0: version "2.0.2" resolved "https://registry.yarnpkg.com/html-escaper/-/html-escaper-2.0.2.tgz#dfd60027da36a36dfcbe236262c00a5822681453" @@ -821,6 +938,13 @@ is-bigint@^1.0.1: dependencies: has-bigints "^1.0.1" +is-binary-path@~2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/is-binary-path/-/is-binary-path-2.1.0.tgz#ea1f7f3b80f064236e83470f86c09c254fb45b09" + integrity sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw== + dependencies: + binary-extensions "^2.0.0" + is-boolean-object@^1.1.0: version "1.1.2" resolved "https://registry.yarnpkg.com/is-boolean-object/-/is-boolean-object-1.1.2.tgz#5c6dc200246dd9321ae4b885a114bb1f75f63719" @@ -858,7 +982,7 @@ is-fullwidth-code-point@^3.0.0: resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz#f116f8064fe90b3f7844a38997c0b75051269f1d" integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg== -is-glob@^4.0.0, is-glob@^4.0.3: +is-glob@^4.0.0, is-glob@^4.0.1, is-glob@^4.0.3, is-glob@~4.0.1: version "4.0.3" resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.3.tgz#64f61e42cbbb2eec2071a9dac0b28ba1e65d5084" integrity sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg== @@ -877,11 +1001,21 @@ is-number-object@^1.0.4: dependencies: has-tostringtag "^1.0.0" +is-number@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b" + integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng== + is-path-inside@^3.0.3: version "3.0.3" resolved "https://registry.yarnpkg.com/is-path-inside/-/is-path-inside-3.0.3.tgz#d231362e53a07ff2b0e0ea7fed049161ffd16283" integrity sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ== +is-plain-obj@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/is-plain-obj/-/is-plain-obj-2.1.0.tgz#45e42e37fccf1f40da8e5f76ee21515840c09287" + integrity sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA== + is-regex@^1.1.4: version "1.1.4" resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.1.4.tgz#eef5663cd59fa4c0ae339505323df6854bb15958" @@ -911,6 +1045,11 @@ is-symbol@^1.0.2, is-symbol@^1.0.3: dependencies: has-symbols "^1.0.2" +is-unicode-supported@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz#3f26c76a809593b52bfa2ecb5710ed2779b522a7" + integrity sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw== + is-weakref@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/is-weakref/-/is-weakref-1.0.2.tgz#9529f383a9338205e89765e0392efc2f100f06f2" @@ -959,7 +1098,7 @@ js-sdsl@^4.1.4: resolved "https://registry.yarnpkg.com/js-sdsl/-/js-sdsl-4.2.0.tgz#278e98b7bea589b8baaf048c20aeb19eb7ad09d0" integrity sha512-dyBIzQBDkCqCu+0upx25Y2jGdbTGxE9fshMsCdK0ViOongpV+n5tXRcZY9v7CaVQ79AGS9KA1KHtojxiM7aXSQ== -js-yaml@^4.1.0: +js-yaml@4.1.0, js-yaml@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-4.1.0.tgz#c1fb65f8f5017901cdd2c951864ba18458a10602" integrity sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA== @@ -998,11 +1137,26 @@ locate-path@^6.0.0: dependencies: p-locate "^5.0.0" +locate-path@^7.2.0: + version "7.2.0" + resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-7.2.0.tgz#69cb1779bd90b35ab1e771e1f2f89a202c2a8a8a" + integrity sha512-gvVijfZvn7R+2qyPX8mAuKcFGDf6Nc61GdvGafQsHL0sBIxfKzA+usWn4GFC/bk+QdwPUD4kWFJLhElipq+0VA== + dependencies: + p-locate "^6.0.0" + lodash.merge@^4.6.2: version "4.6.2" resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a" integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ== +log-symbols@4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/log-symbols/-/log-symbols-4.1.0.tgz#3fbdbb95b4683ac9fc785111e792e558d4abd503" + integrity sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg== + dependencies: + chalk "^4.1.0" + is-unicode-supported "^0.1.0" + lru-cache@^9.1.1: version "9.1.1" resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-9.1.1.tgz#c58a93de58630b688de39ad04ef02ef26f1902f1" @@ -1015,6 +1169,13 @@ make-dir@^3.0.0: dependencies: semver "^6.0.0" +minimatch@5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-5.0.1.tgz#fb9022f7528125187c92bd9e9b6366be1cf3415b" + integrity sha512-nLDxIFRyhDblz3qMuq+SoRZED4+miJ/G+tdDrjkkkRnjAsBexeGpgjLEQ0blJy7rHhR2b93rhQY4SvyWu9v03g== + dependencies: + brace-expansion "^2.0.1" + minimatch@^3.0.4, minimatch@^3.0.5, minimatch@^3.1.1, minimatch@^3.1.2: version "3.1.2" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b" @@ -1022,6 +1183,13 @@ minimatch@^3.0.4, minimatch@^3.0.5, minimatch@^3.1.1, minimatch@^3.1.2: dependencies: brace-expansion "^1.1.7" +minimatch@^5.0.1: + version "5.1.6" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-5.1.6.tgz#1cfcb8cf5522ea69952cd2af95ae09477f122a96" + integrity sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g== + dependencies: + brace-expansion "^2.0.1" + minimatch@^9.0.1: version "9.0.1" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-9.0.1.tgz#8a555f541cf976c622daf078bb28f29fb927c253" @@ -1039,6 +1207,32 @@ minimist@^1.2.0, minimist@^1.2.6: resolved "https://registry.yarnpkg.com/minipass/-/minipass-6.0.2.tgz#542844b6c4ce95b202c0995b0a471f1229de4c81" integrity sha512-MzWSV5nYVT7mVyWCwn2o7JH13w2TBRmmSqSRCKzTw+lmft9X4z+3wjvs06Tzijo5z4W/kahUCDpRXTF+ZrmF/w== +mocha@^10.3.0: + version "10.3.0" + resolved "https://registry.yarnpkg.com/mocha/-/mocha-10.3.0.tgz#0e185c49e6dccf582035c05fa91084a4ff6e3fe9" + integrity sha512-uF2XJs+7xSLsrmIvn37i/wnc91nw7XjOQB8ccyx5aEgdnohr7n+rEiZP23WkCYHjilR6+EboEnbq/ZQDz4LSbg== + dependencies: + ansi-colors "4.1.1" + browser-stdout "1.3.1" + chokidar "3.5.3" + debug "4.3.4" + diff "5.0.0" + escape-string-regexp "4.0.0" + find-up "5.0.0" + glob "8.1.0" + he "1.2.0" + js-yaml "4.1.0" + log-symbols "4.1.0" + minimatch "5.0.1" + ms "2.1.3" + serialize-javascript "6.0.0" + strip-json-comments "3.1.1" + supports-color "8.1.1" + workerpool "6.2.1" + yargs "16.2.0" + yargs-parser "20.2.4" + yargs-unparser "2.0.0" + ms@2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" @@ -1049,7 +1243,7 @@ ms@2.1.2: resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== -ms@^2.1.1, ms@^2.1.3: +ms@2.1.3, ms@^2.1.1, ms@^2.1.3: version "2.1.3" resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2" integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== @@ -1059,6 +1253,11 @@ natural-compare@^1.4.0: resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7" integrity sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw== +normalize-path@^3.0.0, normalize-path@~3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65" + integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA== + object-inspect@^1.12.2, object-inspect@^1.9.0: version "1.12.2" resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.12.2.tgz#c0641f26394532f28ab8d796ab954e43c009a8ea" @@ -1123,6 +1322,13 @@ p-limit@^3.0.2: dependencies: yocto-queue "^0.1.0" +p-limit@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-4.0.0.tgz#914af6544ed32bfa54670b061cafcbd04984b644" + integrity sha512-5b0R4txpzjPWVw/cXXUResoD4hb6U/x9BH08L7nw+GN1sezDzPdxeRvpc9c433fZhBan/wusjbCsqwqm4EIBIQ== + dependencies: + yocto-queue "^1.0.0" + p-locate@^5.0.0: version "5.0.0" resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-5.0.0.tgz#83c8315c6785005e3bd021839411c9e110e6d834" @@ -1130,6 +1336,13 @@ p-locate@^5.0.0: dependencies: p-limit "^3.0.2" +p-locate@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-6.0.0.tgz#3da9a49d4934b901089dca3302fa65dc5a05c04f" + integrity sha512-wPrq66Llhl7/4AGC6I+cqxT07LhXvWL08LNXz1fENOw0Ap4sRZZ/gZpTTJ5jpurzzzfS2W/Ge9BY3LgLjCShcw== + dependencies: + p-limit "^4.0.0" + parent-module@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/parent-module/-/parent-module-1.0.1.tgz#691d2709e78c79fae3a156622452d00762caaaa2" @@ -1142,6 +1355,11 @@ path-exists@^4.0.0: resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-4.0.0.tgz#513bdbe2d3b95d7762e8c1137efa195c6c61b5b3" integrity sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w== +path-exists@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-5.0.0.tgz#a6aad9489200b21fab31e49cf09277e5116fb9e7" + integrity sha512-RjhtfwJOxzcFmNOi6ltcbcu4Iu+FL3zEj83dk4kAS+fVpTxXLO1b38RvJgT/0QwvV/L3aY9TAnyv0EOqW4GoMQ== + path-is-absolute@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" @@ -1165,6 +1383,11 @@ path-scurry@^1.7.0: lru-cache "^9.1.1" minipass "^5.0.0 || ^6.0.2" +picomatch@^2.0.4, picomatch@^2.2.1: + version "2.3.1" + resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42" + integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA== + prelude-ls@^1.2.1: version "1.2.1" resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396" @@ -1180,6 +1403,20 @@ queue-microtask@^1.2.2: resolved "https://registry.yarnpkg.com/queue-microtask/-/queue-microtask-1.2.3.tgz#4929228bbc724dfac43e0efb058caf7b6cfb6243" integrity sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A== +randombytes@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/randombytes/-/randombytes-2.1.0.tgz#df6f84372f0270dc65cdf6291349ab7a473d4f2a" + integrity sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ== + dependencies: + safe-buffer "^5.1.0" + +readdirp@~3.6.0: + version "3.6.0" + resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.6.0.tgz#74a370bd857116e245b29cc97340cd431a02a6c7" + integrity sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA== + dependencies: + picomatch "^2.2.1" + regexp.prototype.flags@^1.4.3: version "1.4.3" resolved "https://registry.yarnpkg.com/regexp.prototype.flags/-/regexp.prototype.flags-1.4.3.tgz#87cab30f80f66660181a3bb7bf5981a872b367ac" @@ -1232,6 +1469,11 @@ run-parallel@^1.1.9: dependencies: queue-microtask "^1.2.2" +safe-buffer@^5.1.0: + version "5.2.1" + resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" + integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== + safe-regex-test@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/safe-regex-test/-/safe-regex-test-1.0.0.tgz#793b874d524eb3640d1873aad03596db2d4f2295" @@ -1246,6 +1488,13 @@ semver@^6.0.0, semver@^6.3.0: resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d" integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw== +serialize-javascript@6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-6.0.0.tgz#efae5d88f45d7924141da8b5c3a7a7e663fefeb8" + integrity sha512-Qr3TosvguFt8ePWqsvRfrKyQXIiW+nGbYpy8XK24NQHE83caxWt+mIymTT19DGFbNWNLfEwsrkSmN64lVWB9ag== + dependencies: + randombytes "^2.1.0" + shebang-command@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-2.0.0.tgz#ccd0af4f8835fbdc265b82461aaf0c36663f34ea" @@ -1277,6 +1526,11 @@ signal-exit@^4.0.1: resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-4.0.2.tgz#ff55bb1d9ff2114c13b400688fa544ac63c36967" integrity sha512-MY2/qGx4enyjprQnFaZsHib3Yadh3IXyV2C321GY0pjGfVBu4un0uDJkwgdxqO+Rdx8JMT8IfJIRwbYVz3Ob3Q== +slash@^5.1.0: + version "5.1.0" + resolved "https://registry.yarnpkg.com/slash/-/slash-5.1.0.tgz#be3adddcdf09ac38eebe8dcdc7b1a57a75b095ce" + integrity sha512-ZA6oR3T/pEyuqwMgAKT0/hAv8oAXckzbkmR0UkUosQ+Mc4RxGoJkRmwHgHufaenlyAgE1Mxgpdcrf75y6XcnDg== + stack-utils@^2.0.6: version "2.0.6" resolved "https://registry.yarnpkg.com/stack-utils/-/stack-utils-2.0.6.tgz#aaf0748169c02fc33c8232abccf933f54a1cc34f" @@ -1339,11 +1593,18 @@ strip-bom@^3.0.0: resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-3.0.0.tgz#2334c18e9c759f7bdd56fdef7e9ae3d588e68ed3" integrity sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA== -strip-json-comments@^3.1.0, strip-json-comments@^3.1.1: +strip-json-comments@3.1.1, strip-json-comments@^3.1.0, strip-json-comments@^3.1.1: version "3.1.1" resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.1.1.tgz#31f1281b3832630434831c310c01cccda8cbe006" integrity sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig== +supports-color@8.1.1: + version "8.1.1" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-8.1.1.tgz#cd6fc17e28500cff56c1b86c0a7fd4a54a73005c" + integrity sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q== + dependencies: + has-flag "^4.0.0" + supports-color@^7.1.0: version "7.2.0" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.2.0.tgz#1b7dcdcb32b8138801b3e478ba6a51caa89648da" @@ -1370,6 +1631,13 @@ text-table@^0.2.0: resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4" integrity sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw== +to-regex-range@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-5.0.1.tgz#1648c44aae7c8d988a326018ed72f5b4dd0392e4" + integrity sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ== + dependencies: + is-number "^7.0.0" + tsconfig-paths@^3.14.1: version "3.14.1" resolved "https://registry.yarnpkg.com/tsconfig-paths/-/tsconfig-paths-3.14.1.tgz#ba0734599e8ea36c862798e920bcf163277b137a" @@ -1407,6 +1675,11 @@ unbox-primitive@^1.0.2: has-symbols "^1.0.3" which-boxed-primitive "^1.0.2" +unicorn-magic@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/unicorn-magic/-/unicorn-magic-0.1.0.tgz#1bb9a51c823aaf9d73a8bfcd3d1a23dde94b0ce4" + integrity sha512-lRfVq8fE8gz6QMBuDM6a+LO3IAzTi05H6gCVaUpir2E1Rwpo4ZUog45KpNXKC/Mn3Yb9UDuHumeFTo9iV/D9FQ== + uri-js@^4.2.2: version "4.4.1" resolved "https://registry.yarnpkg.com/uri-js/-/uri-js-4.4.1.tgz#9b1a52595225859e55f669d928f88c6c57f2a77e" @@ -1451,6 +1724,11 @@ word-wrap@^1.2.3: resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.3.tgz#610636f6b1f703891bd34771ccb17fb93b47079c" integrity sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ== +workerpool@6.2.1: + version "6.2.1" + resolved "https://registry.yarnpkg.com/workerpool/-/workerpool-6.2.1.tgz#46fc150c17d826b86a008e5a4508656777e9c343" + integrity sha512-ILEIE97kDZvF9Wb9f6h5aXK4swSlKGUcOEGiIYb2OOu/IrDU9iwj0fD//SsA6E5ibwJxpEvhullJY4Sl4GcpAw== + "wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0: version "7.0.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" @@ -1479,12 +1757,27 @@ y18n@^5.0.5: resolved "https://registry.yarnpkg.com/y18n/-/y18n-5.0.8.tgz#7f4934d0f7ca8c56f95314939ddcd2dd91ce1d55" integrity sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA== +yargs-parser@20.2.4: + version "20.2.4" + resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.4.tgz#b42890f14566796f85ae8e3a25290d205f154a54" + integrity sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA== + yargs-parser@^20.2.2, yargs-parser@^20.2.9: version "20.2.9" resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.9.tgz#2eb7dc3b0289718fc295f362753845c41a0c94ee" integrity sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w== -yargs@^16.2.0: +yargs-unparser@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/yargs-unparser/-/yargs-unparser-2.0.0.tgz#f131f9226911ae5d9ad38c432fe809366c2325eb" + integrity sha512-7pRTIA9Qc1caZ0bZ6RYRGbHJthJWuakf+WmHK0rVeLkNrrGhfoabBNdue6kdINI6r4if7ocq9aD/n7xwKOdzOA== + dependencies: + camelcase "^6.0.0" + decamelize "^4.0.0" + flat "^5.0.2" + is-plain-obj "^2.1.0" + +yargs@16.2.0, yargs@^16.2.0: version "16.2.0" resolved "https://registry.yarnpkg.com/yargs/-/yargs-16.2.0.tgz#1c82bf0f6b6a66eafce7ef30e376f49a12477f66" integrity sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw== @@ -1501,3 +1794,8 @@ yocto-queue@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b" integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q== + +yocto-queue@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-1.0.0.tgz#7f816433fb2cbc511ec8bf7d263c3b58a1a3c251" + integrity sha512-9bnSc/HEW2uRy67wc+T8UwauLuPJVn28jb+GtJY16iiKWyvmYJRXVT4UamsAEGQfPohgr2q4Tq0sQbQlxTfi1g==