Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Args forwarding with pnpm run test and pnpm test is inconsistent #4821

@axelboc

Description

@axelboc

pnpm version: 7

Code to reproduce the issue:

In package.json:

"scripts": {
  "test": "jest"
}

Expected behavior:

As of pnpm@7, pnpm run forwards CLI arguments without the need for the extra -- separator.

Since pnpm test really feels like a shortcut for pnpm run test, both of these commands should, in my opinion, run jest "Foo" "--watchAll":

$ pnpm run test Foo --watchAll
jest "Foo" "--watchAll"

$ pnpm test Foo --watchAll
jest "Foo" "--watchAll"

Actual behavior:

$ pnpm test Foo --watchAll
ERROR  Unknown option: 'watchAll'

Foo is a regex filter for Jest. The result is the same if I remove it.

To make it work, I have to pass the -- separator like with pnpm@6:

$ pnpm test -- Foo --watchAll
jest "Foo" "--watchAll"

Note that I can pass the separator after Foo and Foo still gets forwarded:

$ pnpm test Foo -- --watchAll
jest "Foo" "--watchAll"

Additional information:

  • node -v prints: v16.5.0
  • Windows, macOS, or Linux?: Linux, but I noticed the same behaviour on Windows too

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions