question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Feature] Allow custom command-line arguments in @playwright/test

See original GitHub issue

When using the Playright test runner, I would like to be able to pass a command-line argument to my Playwright test, similar to this:

npx playwright test --build-path=/path/to/my/application/build/

However, this produces the following error:

error: unknown option '--build-path=/path/to/my/application/build/' 

There should be a way to pass custom command-line arguments to Playwright. This Stack Overflow thread shows that others are looking for this too.

Maybe I’m missing something, but it appears that right now, the only way to pass custom arguments is through environment variables, which seems like an awkward solution.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:34
  • Comments:13 (1 by maintainers)

github_iconTop GitHub Comments

10reactions
refactorericcommented, Feb 16, 2022

I’m also interested in custom parameters. From an internal requirements document: Various use cases need to be supported, without change to configuration. Preferably as simple as a command line parameter, since environment variables are not self-explanatory.

  • Testing from developer/tester machine
  • Testing from CI
  • Testing against different environments (master, wip, rc, production, etc.) (various variables are dependent on an environment ‘profile’)
  • Selecting a predefined type of tests to run (smoke, acceptance, technical release tests, …?)
  • Selecting a predefined area of tests to run (bookkeeping, payAndCollect, salesInvoicing, etc.)
  • Selecting specific tests.
  • Option to run without re-creating a company (useful in CI)

Several of these use cases could be solved with existing command line arguments. But some others can’t.

Since Playwright does not have support for custom command line arguments, I was thinking to just create a wrapper script which sets the appropriate environment variables based on command line arguments and then calls ‘playwright test’. But it’s nicer if that’s not needed.

The ideal solution would also display available arguments (for example with a --usage option) and would show a helpful error+usage message if some arguments were incorrect.

6reactions
brunomartinsprocommented, Jun 21, 2022

+1 this is a must, when we have multiple MFEs and we want to do e2e tests we need to pass variables to configure how we want the tests to run. I will try to submit a PR with these changes as soon as possible so you can review.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Does Playwright offer custom args in the command line?
It seems not possible at this moment. I tried to add my option after -- , which terminates original options list, but then...
Read more >
Advanced: configuration | Playwright - CukeTest
To set something up once before running all tests, use globalSetup option in the configuration file. Global setup file must export a single...
Read more >
#005 - Tool Talk: Hello, Command Line | Learn Playwright
emulate mobile browser contexts using supported parameters – see device descriptors for valid values.
Read more >
Playwright Advanced Configuring - Sauce Labs Documentation
Tailoring Your Test File Bundle​. The saucectl command line bundles your root directory ( rootDir parameter of config.yml ) and transmits it ...
Read more >
Quick and easy Javascript testing with PlayWright | by
You can do it by running the Node executable playwright command with the codegen argument followed by the target URL argument. It will...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found