playwright
playwright copied to clipboard
[Feature] Allow custom command-line arguments in @playwright/test
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.
Environment variables are currently the preferred solution.
Environment variables are currently the preferred solution.
Fair enough.
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.
I also believe custom command-line arguments would be helpful. I also respect the intent to be helpful and provide guidance to those learning to use the tool. However, to empower deeper integrations, even a single new command-line argument named --custom for example would be a welcome addition. With something like that, we could pass some JSON.
Thank you.
Custom command-line arguments feature is much needed, since even in protractor we lot of dependency with this command line arguments. So expecting this feature to be introduced, so it will be added advantage
+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.
+1 to have custom command-line arguments feature. For example, base-url is dynamic in our application and changed every pull-request(PR number is dynamic part of url). So, we need to pass PR number as argument to change base-url. Of course we can do it with scripts, but it would be nice to pass such custom arguments via command-line. @brunomartinspro any updates about it?
+1 . For me it would be great if I can pass arguments to properly configure the test we want to run. One example, I need it to test against different environments + select specific tests
+1. I would use custom arguments to be passed to handle some browserstack related stuff.
+1 Definitely ability to pass custom arguments to test suites
+1. Would be very very useful and avoid having a proliferation of .spec.js files for every single config tweak you want to use for a different scope of tests.
+1. This would be very useful.
+1 - this is frustrating without this ability
Does a solution exist today to scour the data for example: 2 with process.args?
playwright test myfile 2
+1. This would be very useful.
+1
+1
+1
+1
+1
+1
+1
+1
+1, this is must feature
+1 To give an example - we would sometimes like to run with soft exceptions and sometimes with hard (particularly for screenshots) - we assumed we could do this with a custom command line arg and look for the arg in a wrapper function in our own code. IMO Env vars are a little messier (is it set? is it still set? did someone set it and forget it?)
+1 I love to pass environment variables from command line option, something like
npx playwright test -Denv=dev
+1
+1
not yet? :( +1
+1