Skip to content

@nx/vitest doesn't pass through reporters from target options #34495

@samir-ajdarpasic

Description

@samir-ajdarpasic

Current Behavior

Specifying reporters in the target options is not taken into account even when no reporters are specified in vite config.

This change came from #34113
More specifically this line: 1161c08#diff-e6200efd60b8225d7f6e50c241e422403d361d17e0828bf7cbec13797a507b91R100
it overrides passThroughOptions.reporters and only takes what's in the vite config file

Example nx target config:

"@nx/vitest:test": {
    ...
    "options": {
        ...
        "reporters": ["junit"]
    },
}

Expected Behavior

The @nx/vitest executor should respect the reporters set in the target options, especially if none are set in the vite config

Current implementation

In https://github.com/nrwl/nx/blob/master/packages/vitest/src/executors/test/lib/utils.ts#L100 we have:
reporters: resolved?.config?.['test']?.reporters

Should be:
reporters: resolved?.config?.['test']?.reporters || passThroughOptions.reporters

GitHub Repo

No response

Steps to Reproduce

  1. Define reporters in your @nx/vitest target (like shown above)
  2. Remove reporters from the projects vite config
  3. Run the vitest target
  4. Observe that the reporters defined are completely ignored.

Nx Report

Node           : 22.20.0
OS             : darwin-arm64
Native Target  : aarch64-macos
pnpm           : 10.16.1
daemon         : Available

nx                 : 22.5.1
@nx/js             : 22.5.1
@nx/eslint         : 22.5.1
@nx/workspace      : 22.5.1
@nx/devkit         : 22.5.1
@nx/eslint-plugin  : 22.5.1
@nx/node           : 22.5.1
@nx/playwright     : 22.5.1
@nx/plugin         : 22.5.1
@nx/react          : 22.5.1
@nx/rollup         : 22.5.1
@nx/storybook      : 22.5.1
@nx/vite           : 22.5.1
@nx/vitest         : 22.3.3
@nx/web            : 22.5.1
typescript         : 5.8.3

Failure Logs

Package Manager Version

No response

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

Using reporter like the native vitest cli option makes the test run indefinitely

Metadata

Metadata

Assignees

Labels

priority: mediumMedium Priority (not high, not low priority)scope: testing toolsIssues related to Cypress / Jest / Playwright / Vitest support in Nxtype: bug

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions