-
Notifications
You must be signed in to change notification settings - Fork 29.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test runner with junit reporter and forceExit flag results in incomplete report #54327
Comments
This comment was marked as outdated.
This comment was marked as outdated.
@RedYetiDev are you sure your setup acutally detects the test file? It looks suspicious that all your reports state 0 tests. Can you try naming the file |
Haha! I forgot to name the file, you are correct, sorry! Reproduction results: import {describe, test} from 'node:test';
import * as assert from 'node:assert/strict';
describe('Suite', () => {
test('Failing test', () => {
assert.fail()
})
test('Passing test', () => {
assert.ok(true)
})
}); $ node --test-reporter junit --test-reporter-destination test-results.xml --test --test-force-exit <?xml version="1.0" encoding="utf-8"?>
<testsuites> $ node --test-reporter junit --test-reporter-destination test-results.xml --test <?xml version="1.0" encoding="utf-8"?>
<testsuites>
<testsuite name="Suite" time="0.002112" disabled="0" errors="0" tests="2" failures="1" skipped="0" hostname="Jedi8-KALI">
<testcase name="Failing test" time="0.001014" classname="test" failure="Failed">
<failure type="testCodeFailure" message="Failed">
Error [ERR_TEST_FAILURE]: Failed
at new Promise (<anonymous>)
at Array.map (<anonymous>) {
code: 'ERR_TEST_FAILURE',
failureType: 'testCodeFailure',
cause: AssertionError [ERR_ASSERTION]: Failed
at TestContext.<anonymous> (file:///xyz/index.test.mjs:8:16)
at Test.runInAsyncScope (node:async_hooks:206:9)
at Test.run (node:internal/test_runner/test:865:25)
at Test.start (node:internal/test_runner/test:762:17)
at node:internal/test_runner/test:1224:71
at node:internal/per_context/primordials:488:82
at new Promise (<anonymous>)
at new SafePromise (node:internal/per_context/primordials:456:29)
at node:internal/per_context/primordials:488:9
at Array.map (<anonymous>) {
generatedMessage: true,
code: 'ERR_ASSERTION',
actual: undefined,
expected: undefined,
operator: 'fail'
}
}
</failure>
</testcase>
<testcase name="Passing test" time="0.000147" classname="test"/>
</testsuite>
<!-- tests 2 -->
<!-- suites 1 -->
<!-- pass 1 -->
<!-- fail 1 -->
<!-- cancelled 0 -->
<!-- skipped 0 -->
<!-- todo 0 -->
<!-- duration_ms 57.794832 -->
</testsuites> $ node --test-reporter tap --test-reporter-destination test-results.tap --test --test-force-exit
$ node --test-reporter tap --test-reporter-destination test-results.tap --test
The file is named I've hidden my older to comment to prevent confusion. |
I'm guessing we need more logic around here when we're using any file destinations. |
I am on vacation without a computer until mid-september, I will give a look when I am back if no one else does before me |
I'm looking into it. It looks like the |
I have a patch. Just gotta add tests |
See #54953 |
This commit updates the test runner to explicitly close and flush all destination file streams when the --test-force-exit flag is used. Fixes: nodejs#54327
This commit updates the test runner to explicitly close and flush all destination file streams when the --test-force-exit flag is used. Fixes: nodejs#54327
This commit updates the test runner to explicitly close and flush all destination file streams when the --test-force-exit flag is used. Fixes: nodejs#54327 PR-URL: nodejs#55099 Reviewed-By: Chemi Atlow <chemi@atlow.co.il> Reviewed-By: Jake Yuesong Li <jake.yuesong@gmail.com>
Version
v20.15.0
Platform
Subsystem
test
What steps will reproduce the bug?
Run tests:
How often does it reproduce? Is there a required condition?
Problem arises every time.
What is the expected behavior? Why is that the expected behavior?
test-results.xml
should have the following content:This is what we get without passing the
--test-force-exit
flag. Also, other test-reporters (e.g.tap
) don't seem to be affected by the flag, i.e. they produce the same report regardless of if the flag is passed or not.What do you see instead?
test-results.xml
is an incomplete file with the following content:Additional information
From what I can understand of #52038, this is supposed to work, i.e. the report should always be complete even if the flag is passed.
The text was updated successfully, but these errors were encountered: