nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.47k stars 2.34k forks source link

error: unknown option: --watch for component-tests after updating nx to 18.0.4 #21984

Closed tar-aldev closed 4 months ago

tar-aldev commented 7 months ago

Current Behavior

When trying to run nx component-test --watch it fails with

  error: unknown option: --watch

I can reproduce it both on new and existing project. As a result it is impossible to run cypress tests in watch mode.

Expected Behavior

--watch flag should work for tests. It is also not possible to set it in project.json targets as an option.

GitHub Repo

No response

Steps to Reproduce

  1. create cypresss ocmponent tests
  2. try to run it with --watch

Nx Report

Node   : 18.18.2
   OS     : darwin-arm64
   pnpm   : 8.7.6

   nx                 : 18.0.4
   @nx/js             : 18.0.4
   @nx/jest           : 18.0.4
   @nx/linter         : 18.0.4
   @nx/eslint         : 18.0.4
   @nx/workspace      : 18.0.4
   @nx/cypress        : 18.0.4
   @nx/devkit         : 18.0.4
   @nx/eslint-plugin  : 18.0.4
   @nx/express        : 18.0.4
   @nx/next           : 18.0.4
   @nx/node           : 18.0.4
   @nx/playwright     : 18.0.4
   @nx/react          : 18.0.4
   @nx/storybook      : 18.0.4
   @nrwl/tao          : 18.0.4
   @nx/web            : 18.0.4
   @nx/webpack        : 18.0.4
   typescript         : 5.3.3
   ---------------------------------------
   Community plugins:
   @ago-dev/nx-aws-cdk-v2 : 1.6.1

Failure Logs

No response

Package Manager Version

No response

Operating System

Additional Information

If I put this into project.json

"component-test": {
      "executor": "@nx/cypress:cypress",
      "options": {
        "cypressConfig": "...",
        "skipServe": true,
        "testingType": "component"
      },
      "configurations": {
        "production": {
          "devServerTarget": "..."
        }
      }
    }

then I am able to pass --watch flag. Not sure if this is an expected bahviour or not

DevNebulae commented 7 months ago

In general I have noticed that Cypress doesn't work too well with inferred tasks / Project Crystal. I still need to add all the manual configuration to make either work, even for newly generated projects. Issues ranging from certain commands (i.e. --watch) not working to certain options not being available that are described in the documentation.

andrewalderson commented 7 months ago

Just ran into the same issue with e2e tests. As above, I had to specifically add the target to project.json to make it work.

McGiogen commented 7 months ago

Same here. Probably --watch and other flags doesn't works because infer targets are using nx:run-commands instead of @nx/cypress:cypress as executor and they are custom flags of @nx/cypress plugin.

This is our infer e2e target:

    "e2e": {
      "cache": true,
      "inputs": [
        "default",
        "^production"
      ],
      "outputs": [
        "{workspaceRoot}\\dist\\cypress\\apps\\evohrp-e2e\\videos",
        "{workspaceRoot}\\dist\\cypress\\apps\\evohrp-e2e\\screenshots"
      ],
      "executor": "nx:run-commands",
      "options": {
        "cwd": "apps/evohrp-e2e",
        "command": "cypress run"
      },
      "configurations": {
        "production": {
          "command": "cypress run --env webServerCommand=\"nx run evohrp:serve:production\""
        }
      }
    },

You can check yourself with command nx show project <project-name>.

Unfortunately I have found no way to use cypress open without overriding infer e2e command.

leosvelperez commented 5 months ago

Thanks for reporting this!

We addressed running the e2e tests in watch mode in https://github.com/nrwl/nx/pull/22556 that was released in Nx 18.2.0. The Cypress plugin will now infer an open-cypress task that runs cypress open.

I'll take a look for Component Testing.

leosvelperez commented 5 months ago

@tar-aldev could you update your repo to at least Nx 18.2.0 and try running the newly inferred open-cypress task?

github-actions[bot] commented 5 months ago

This issue has been automatically marked as stale because no results of retrying on the latest version of Nx was provided within 7 days. It will be closed in 21 days if no results are provided. If the issue is still present, please reply to keep it active. If the issue was not present, please close this issue. Thanks for being a part of the Nx community! 🙏

github-actions[bot] commented 3 months ago

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.