diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 928f7ee..c8aa83c 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - node: [v18, v19, v20] + node: [v18, v20, v21] steps: - uses: actions/checkout@v3 with: diff --git a/packages/bail/tests/index.test.js b/packages/bail/tests/index.test.js index 7d9a468..3537c57 100644 --- a/packages/bail/tests/index.test.js +++ b/packages/bail/tests/index.test.js @@ -20,7 +20,6 @@ test('fail should stop after failed test', () => { '--test-reporter', './index.js', '--test-reporter-destination', 'stdout', 'tests/fixtures/fail.js', 'tests/fixtures/pass.js', ], { env: {} }); - assert.strictEqual(child.stderr?.toString(), ''); assert.strictEqual(child.stdout?.toString(), 'X\n\x1B[31m✖ Bailing on failed test: fail\x1B[0m\n'); - assert.strictEqual(child.status, 1); + assert.strictEqual(child.status, 7); }); diff --git a/packages/github/tests/index.test.js b/packages/github/tests/index.test.js index ee6d18b..5fc1089 100644 --- a/packages/github/tests/index.test.js +++ b/packages/github/tests/index.test.js @@ -12,6 +12,7 @@ const output = require('./output'); const outputESM = require('./output-esm'); const GITHUB_STEP_SUMMARY = join(tmpdir(), 'github-actions-test-reporter'); +const nodeMajor = process.versions.node.split('.')[0]; describe('github reporter', () => { beforeEach(() => { @@ -34,7 +35,10 @@ describe('github reporter', () => { }); assert.strictEqual(child.stderr?.toString(), ''); - compareLines(child.stdout?.toString(), outputESM.stdout); + compareLines( + child.stdout?.toString(), + outputESM.overrides[nodeMajor]?.stdout ?? outputESM.stdout, + ); compareLines(readFileSync(GITHUB_STEP_SUMMARY).toString(), outputESM.summary); }); diff --git a/packages/github/tests/output-esm.js b/packages/github/tests/output-esm.js index 29d263f..b413524 100644 --- a/packages/github/tests/output-esm.js +++ b/packages/github/tests/output-esm.js @@ -2,7 +2,7 @@ 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 failureType: 'testCodeFailure',%0A cause: AssertionError \\[ERR_ASSERTION\\]: false == true%0A at TestContext. \\(.*/example.mjs:5:3\\).* code: 'ERR_TEST_FAILURE'%0A} +: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\\) @@ -12,4 +12,16 @@ module.exports = { summary: `

Test Results

Total Tests2
Suites 📂0
Passed ✅1
Failed ❌1
Canceled 🚫0
Skipped ⏭️0
Todo 📝0
Duration 🕐.*ms
`, + overrides: { + 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 index 643806c..91c6dc4 100644 --- a/packages/github/tests/output.js +++ b/packages/github/tests/output.js @@ -5,12 +5,12 @@ module.exports = { ::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} +::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 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).* +::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 diff --git a/packages/junit/tests/index.test.js b/packages/junit/tests/index.test.js index 957df82..3926927 100644 --- a/packages/junit/tests/index.test.js +++ b/packages/junit/tests/index.test.js @@ -8,6 +8,8 @@ const reporter = require('../index'); const output = require('./output'); const outputESM = require('./output-esm'); +const nodeMajor = process.versions.node.split('.')[0]; + test('spwan with reporter', () => { const child = spawnSync(process.execPath, ['--test-reporter', './index.js', '../../tests/example'], { env: {} }); assert.strictEqual(child.stderr?.toString(), ''); @@ -17,7 +19,10 @@ test('spwan with reporter', () => { test('spwan with reporter -esm', () => { const child = spawnSync(process.execPath, ['--test-reporter', './index.js', '../../tests/example.mjs'], { env: {} }); assert.strictEqual(child.stderr?.toString(), ''); - compareLines(child.stdout?.toString(), outputESM.stdout); + compareLines( + child.stdout?.toString(), + outputESM.overrides[nodeMajor]?.stdout ?? outputESM.stdout, + ); }); test('empty', async () => { diff --git a/packages/junit/tests/output-esm.js b/packages/junit/tests/output-esm.js index bce329b..b3e7166 100644 --- a/packages/junit/tests/output-esm.js +++ b/packages/junit/tests/output-esm.js @@ -6,6 +6,7 @@ module.exports = { \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\\) @@ -18,12 +19,46 @@ module.exports = { actual: false, expected: true, operator: '==' - }, - code: 'ERR_TEST_FAILURE' + } } \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 + +`, + }, + }, }; diff --git a/packages/junit/tests/output.js b/packages/junit/tests/output.js index 7d46855..83d69ef 100644 --- a/packages/junit/tests/output.js +++ b/packages/junit/tests/output.js @@ -8,6 +8,7 @@ module.exports = { \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 .* @@ -19,7 +20,6 @@ module.exports = { .* .* .* - code: 'ERR_TEST_FAILURE' } \t\t\t \t\t @@ -30,6 +30,7 @@ module.exports = { assert\\(false\\) \\] { +code: 'ERR_TEST_FAILURE', failureType: 'testCodeFailure', cause: AssertionError \\[ERR_ASSERTION\\]: The expression evaluated to a falsy value: @@ -47,8 +48,7 @@ cause: AssertionError \\[ERR_ASSERTION\\]: The expression evaluated to a falsy v actual: false, expected: true, operator: '==' -}, -code: 'ERR_TEST_FAILURE' +} } \t\t\t \t\t