Skip to content

Unit-test "reporters" schema doesn't work in NX #32618

@Ionaru

Description

@Ionaru

Command

test

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

In the unit test schema, the "items" property of the array type, is a list. The NX schema validator doesn't support lists under the items property, only objects.

"items": [
{
"anyOf": [
{
"type": "string"
},
{
"enum": [
"default",
"verbose",
"dots",
"json",
"junit",
"tap",
"tap-flat",
"html"
]
}
]
},
{
"type": "object"
}
]

This can be easily made compatible again by replacing the list with a oneOf property. This doesn't provide the exact same validation, but it's close.

{
  "type": "array",
  "minItems": 1,
  "maxItems": 2,
  "items": {
    "oneOf": [
      {
        "anyOf": [
          {
            "type": "string"
          },
          {
            "enum": [
              "default", 
              "verbose", 
              "dots", 
              "json", 
              "junit", 
              "tap", 
              "tap-flat", 
              "html"
            ]
          }
        ]
      },
      {
        "type": "object"
      }
    ]
  }
}

Minimal Reproduction

In https://github.com/Ionaru/schema7fail:

  1. Run npm install
  2. Run nx test my-app

Clean repro:

  1. Create an NX project with an Angular application
  2. In project.json add:
    "test": {
      "executor": "@angular/build:unit-test",
      "options": {
        "reporters": [["junit", {"suiteName": "MyApp"}]]
      }
    }
  1. Run nx test <app_name>

Exception or Error

NX   Property 'reporters' does not match the schema.
{
  "oneOf": [
    {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "enum": [
            "default",
            "verbose",
            "dots",
            "json",
            "junit",
            "tap",
            "tap-flat",
            "html"
          ]
        }
      ]
    },
    {
      "type": "array",
      "minItems": 1,
      "maxItems": 2,
      "items": [
        {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "enum": [
                "default",
                "verbose",
                "dots",
                "json",
                "junit",
                "tap",
                "tap-flat",
                "html"
              ]
            }
          ]
        },
        {
          "type": "object"
        }
      ]
    }
  ]
}'

Your Environment

_                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI       : 21.2.0
Angular           : 21.2.0
Node.js           : 24.14.0
Package Manager   : npm 11.11.0
Operating System  : win32 x64

┌───────────────────────────┬───────────────────┬───────────────────┐
│ Package                   │ Installed Version │ Requested Version │
├───────────────────────────┼───────────────────┼───────────────────┤
│ @angular/build            │ 21.2.0            │ ^21.2.0           │
│ @angular/cli              │ 21.2.0            │ ^21.2.0           │
│ @angular/common           │ 21.2.0            │ ^21.2.0           │
│ @angular/compiler         │ 21.2.0            │ ^21.2.0           │
│ @angular/compiler-cli     │ 21.2.0            │ ^21.2.0           │
│ @angular/core             │ 21.2.0            │ ^21.2.0           │
│ @angular/forms            │ 21.2.0            │ ^21.2.0           │
│ @angular/platform-browser │ 21.2.0            │ ^21.2.0           │
│ @angular/router           │ 21.2.0            │ ^21.2.0           │
│ rxjs                      │ 7.8.2             │ ~7.8.0            │
│ typescript                │ 5.9.3             │ ~5.9.2            │
│ vitest                    │ 4.0.18            │ ^4.0.8            │
└───────────────────────────┴───────────────────┴───────────────────┘

Anything else relevant?

See https://github.com/nrwl/nx/blob/77100fac5dd56db91f286dc0aa272b1edfcbd2f4/packages/nx/src/utils/params.ts#L320

Linked to nrwl/nx#34631

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions