Skip to content

Commit

Permalink
feat: report node 20 features
Browse files Browse the repository at this point in the history
  • Loading branch information
MoLow committed May 30, 2023
1 parent 8775b1f commit c99a76c
Show file tree
Hide file tree
Showing 10 changed files with 87 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node: [v19, v18]
node: [v19, v18, v20]
steps:
- uses: actions/checkout@v3
with:
Expand Down
3 changes: 2 additions & 1 deletion packages/github/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ const parseStack = (error, file) => {

const DIAGNOSTIC_KEYS = {
tests: 'Total Tests',
suites: 'Suites 📂',
pass: 'Passed ✅',
fail: 'Failed ❌',
cancelled: 'Canceled 🚫',
skipped: 'Skipped ⏭️',
todo: 'Todo 📝',
duration_ms: 'Duration',
duration_ms: 'Duration 🕐',
};

const DIAGNOSTIC_VALUES = {
Expand Down
3 changes: 2 additions & 1 deletion packages/github/tests/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ const assert = require('assert');
const path = require('path');
const { readFileSync, writeFileSync } = require('fs');
const { compareLines } = require('../../../tests/utils');
const output = require('./output');
// eslint-disable-next-line import/no-dynamic-require
const output = require(`./output.${process.version.split('.')[0]}`);

const GITHUB_STEP_SUMMARY = join(tmpdir(), 'github-actions-test-reporter');
writeFileSync(GITHUB_STEP_SUMMARY, '');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ module.exports = {
::debug::completed running is ok
::debug::completed running more tests
::group::Test results \\(4 passed, 2 failed\\)
::notice::Total Tests: 2%0APassed ✅: 1%0AFailed ❌: 1%0ACanceled 🚫: 0%0ASkipped ⏭️: 0%0ATodo 📝: 0%0ADuration: .*ms
::notice::Total Tests: 2%0APassed ✅: 1%0AFailed ❌: 1%0ACanceled 🚫: 0%0ASkipped ⏭️: 0%0ATodo 📝: 0%0ADuration 🕐: .*ms
::endgroup::
`,
summary: `<h1>Test Results</h1>
<table><tr><td>Total Tests</td><td>2</td></tr><tr><td>Passed ✅</td><td>1</td></tr><tr><td>Failed ❌</td><td>1</td></tr><tr><td>Canceled 🚫</td><td>0</td></tr><tr><td>Skipped ⏭️</td><td>0</td></tr><tr><td>Todo 📝</td><td>0</td></tr><tr><td>Duration</td><td>.*ms</td></tr></table>
<table><tr><td>Total Tests</td><td>2</td></tr><tr><td>Passed ✅</td><td>1</td></tr><tr><td>Failed ❌</td><td>1</td></tr><tr><td>Canceled 🚫</td><td>0</td></tr><tr><td>Skipped ⏭️</td><td>0</td></tr><tr><td>Todo 📝</td><td>0</td></tr><tr><td>Duration 🕐</td><td>.*ms</td></tr></table>
`,
};
22 changes: 22 additions & 0 deletions packages/github/tests/output.v19.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
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::\\[Error \\[ERR_TEST_FAILURE\\]: this is an error\\] {%0A failureType: 'testCodeFailure',%0A cause: Error: this is an error%0A at .*.<anonymous> (.*/example.js:6:11).*
::debug::starting to run is a diagnostic
::debug::completed running is a diagnostic
::notice file=tests/example.js::this is a diagnostic
::error title=tests,file=tests/example.js::\\[Error \\[ERR_TEST_FAILURE\\]: 1 subtest failed\\] { failureType: 'subtestsFailed', cause: '1 subtest failed', code: 'ERR_TEST_FAILURE' }
::debug::starting to run more tests
::debug::starting to run is ok
::debug::completed running is ok
::debug::completed running more tests
::group::Test results \\(4 passed, 2 failed\\)
::notice::Total Tests: 4%0ASuites 📂: 2%0APassed ✅: 3%0AFailed ❌: 1%0ACanceled 🚫: 0%0ASkipped ⏭️: 0%0ATodo 📝: 0%0ADuration 🕐: .*ms
::endgroup::
`,
summary: `<h1>Test Results</h1>
<table><tr><td>Total Tests</td><td>4</td></tr><tr><td>Suites 📂</td><td>2</td></tr><tr><td>Passed ✅</td><td>3</td></tr><tr><td>Failed ❌</td><td>1</td></tr><tr><td>Canceled 🚫</td><td>0</td></tr><tr><td>Skipped ⏭️</td><td>0</td></tr><tr><td>Todo 📝</td><td>0</td></tr><tr><td>Duration 🕐</td><td>.*ms</td></tr></table>
`,
};
22 changes: 22 additions & 0 deletions packages/github/tests/output.v20.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
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::\\[Error \\[ERR_TEST_FAILURE\\]: this is an error\\] {%0A failureType: 'testCodeFailure',%0A cause: Error: this is an error%0A at .*.<anonymous> (.*/example.js:6:11).*
::debug::starting to run is a diagnostic
::debug::completed running is a diagnostic
::notice file=tests/example.js::this is a diagnostic
::error title=tests,file=tests/example.js::\\[Error \\[ERR_TEST_FAILURE\\]: 1 subtest failed\\] { failureType: 'subtestsFailed', cause: '1 subtest failed', code: 'ERR_TEST_FAILURE' }
::debug::starting to run more tests
::debug::starting to run is ok
::debug::completed running is ok
::debug::completed running more tests
::group::Test results \\(4 passed, 2 failed\\)
::notice::Total Tests: 4%0ASuites 📂: 2%0APassed ✅: 3%0AFailed ❌: 1%0ACanceled 🚫: 0%0ASkipped ⏭️: 0%0ATodo 📝: 0%0ADuration 🕐: .*ms
::endgroup::
`,
summary: `<h1>Test Results</h1>
<table><tr><td>Total Tests</td><td>4</td></tr><tr><td>Suites 📂</td><td>2</td></tr><tr><td>Passed ✅</td><td>3</td></tr><tr><td>Failed ❌</td><td>1</td></tr><tr><td>Canceled 🚫</td><td>0</td></tr><tr><td>Skipped ⏭️</td><td>0</td></tr><tr><td>Todo 📝</td><td>0</td></tr><tr><td>Duration 🕐</td><td>.*ms</td></tr></table>
`,
};
2 changes: 1 addition & 1 deletion packages/junit/tests/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const { compareLines } = require('../../../tests/utils');
// eslint-disable-next-line import/no-dynamic-require
const output = require(`./output.${process.version.split('.')[0]}`);

const child = spawnSync(process.execPath, ['--test-reporter', './index.js', '../../tests/example']);
const child = spawnSync(process.execPath, ['--test-reporter', './index.js', '../../tests/example'], { env: {} });

assert.strictEqual(child.stderr?.toString(), '');
compareLines(child.stdout?.toString(), output.stdout);
4 changes: 3 additions & 1 deletion packages/junit/tests/output.v18.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ module.exports = {
\\[Error \\[ERR_TEST_FAILURE\\]: this is an error\\] {
failureType: 'testCodeFailure',
cause: Error: this is an error
at Object.&lt;anonymous&gt; (.*)
.*
.*
.*
.*
.*
.*
Expand Down
31 changes: 31 additions & 0 deletions packages/junit/tests/output.v20.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
module.exports = {
stdout: `<\\?xml version="1.0" encoding="utf-8"\\?>
<testsuites>
\t<testsuite name="tests" time=".*" disabled="0" errors="0" tests="3" failures="1" skipped="0" hostname=".*">
\t\t<testcase name="is ok" time=".*" classname="test"/>
\t\t<testcase name="fails" time=".*" classname="test" failure="this is an error">
\t\t\t<failure type="testCodeFailure" message="this is an error">
\\[Error \\[ERR_TEST_FAILURE\\]: this is an error\\] {
failureType: 'testCodeFailure',
cause: Error: this is an error
.*
.*
.*
.*
.*
.*
.*
.*
.*
code: 'ERR_TEST_FAILURE'
}
\t\t\t</failure>
\t\t</testcase>
\t\t<testcase name="is a diagnostic" time=".*" classname="test"/>
\t</testsuite>
\t<testsuite name="more tests" time=".*" disabled="0" errors="0" tests="1" failures="0" skipped="0" hostname=".*">
\t\t<testcase name="is ok" time=".*" classname="test"/>
\t</testsuite>
</testsuites>
`,
};
2 changes: 1 addition & 1 deletion packages/silent/tests/index.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { spawnSync } = require('child_process');
const assert = require('assert');

const child = spawnSync(process.execPath, ['--test-reporter', './index.js', '../../tests/example']);
const child = spawnSync(process.execPath, ['--test-reporter', './index.js', '../../tests/example'], { env: {} });

assert.strictEqual(child.stderr?.toString(), '');
assert.strictEqual(child.stdout?.toString(), '');

0 comments on commit c99a76c

Please sign in to comment.