nrwl / nx

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

Playwright --grep flag doesn't work with multiple tags when run via nx command #26682

Open ryan-mcginty-alation opened 4 months ago

ryan-mcginty-alation commented 4 months ago

Current Behavior

Playwright accepts multiple tags in grep if they are separated by a pipe and wrapped in quotes. When command is run with nx the quotes are stripped and the command fails.

Both commands below fail:

nx affected -t e2e --grep="@visual-regression|@smoke" nx affected -t e2e -- --grep="@visual-regression|@smoke"

 /bin/sh: @smoke: command not found
      node:events:496
            throw er; // Unhandled 'error' event
            ^
...
Node.js v20.12.2
      Warning: command "npx playwright test --grep=@visual-regression|@smoke" exited with non-zero status code

When run directly with playwright from working directory it succeeds:

npx playwright test --grep "@visual-regression|@smoke"

Expected Behavior

Nx playwright executor should support multiple grep arguments and not strip the quotes

GitHub Repo

No response

Steps to Reproduce

  1. Add a playwright e2e project
  2. Create two tests with different tags
  3. Run the command npx nx affected e2e --grep "@tag1|@tag2"
  4. Notice failure

Nx Report

Node   : 20.12.2
OS     : darwin-arm64
npm    : 10.5.0

nx (global)        : 18.3.1
nx                 : 18.3.1
@nx/js             : 18.3.1
@nx/jest           : 18.3.1
@nx/linter         : 18.3.1
@nx/eslint         : 18.3.1
@nx/workspace      : 18.3.1
@nx/cypress        : 18.3.1
@nx/devkit         : 18.3.1
@nx/eslint-plugin  : 18.3.1
@nx/next           : 18.3.1
@nx/playwright     : 18.3.1
@nx/plugin         : 18.3.1
@nx/react          : 18.3.1
@nx/storybook      : 18.3.1
@nrwl/tao          : 18.3.1
@nx/vite           : 18.3.1
@nx/web            : 18.3.1
@nx/webpack        : 18.3.1
typescript         : 5.3.3
---------------------------------------

Failure Logs

No response

Package Manager Version

No response

Operating System

Additional Information

No response

leosvelperez commented 4 months ago

Thanks for reporting this!

As a workaround until this gets addressed, you can run one of the following:

nx affected -t e2e --grep="\"@visual-regression|@smoke\""
nx affected -t e2e --args="--grep=\"@visual-regression|@smoke\""
ryan-mcginty-alation commented 2 months ago

Thank you @leosvelperez