Skip to content

JUnit XML testcase element has no file attribute #59422

@CuriousStork

Description

@CuriousStork

Version

v24.4.1

Platform

Microsoft Windows NT 10.0.19045.0 x64

Subsystem

test

What steps will reproduce the bug?

  1. Create any failing test, like

    import { suite, test } from "node:test";
    
    await suite('suiteName', () => {
      test('testName', () => {
        throw new Error('Failed')
      });
    });
  2. Run the test via console

    node --test --test-reporter=junit ".\src\junit.test.mts"
  3. Check the report from stdout.

How often does it reproduce? Is there a required condition?

Always. Regardless the suite or test function arguments.

What is the expected behavior? Why is that the expected behavior?

A failed testcase should have file element with source code file of this test case, like "src/junit.test.mts".

For example, GitLab uses file when rendering the test reports: https://docs.gitlab.com/ci/testing/unit_test_reports/#copy-failed-test-names

What do you see instead?

<testcase name="testName" time="0.000414" classname="test" failure="Failed">

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions