Skip to content

Test runner with junit reporter and forceExit flag results in incomplete report #54327

@samuelmurray

Description

@samuelmurray

Version

v20.15.0

Platform

Microsoft Windows NT 10.0.22621.0 x64

Subsystem

test

What steps will reproduce the bug?

// index.test.js

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)
    })
});

Run tests:

$ node  --test-reporter junit --test-reporter-destination test-results.xml --test --test-force-exit

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:

<?xml version="1.0" encoding="utf-8"?>
<testsuites>
	<testcase name="Passing test" time="0.001314" classname="test"/>
	<!-- tests 1 -->
	<!-- suites 0 -->
	<!-- pass 1 -->
	<!-- fail 0 -->
	<!-- cancelled 0 -->
	<!-- skipped 0 -->
	<!-- todo 0 -->
	<!-- duration_ms 115.2994 -->
</testsuites>

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:

<?xml version="1.0" encoding="utf-8"?>
<testsuites>

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    test_runnerIssues and PRs related to the test runner subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions