← Back to Discord Forum

Customize webServer.command depending on the '--ui' flag

___kakashi___posted in #help-playwright
Open in Discord

On the playwright.config.ts we can set the webServer.command option like so:

webServer: {
  command: `npx ng serve`,

I would like to be able to:

  1. set the command to npx ng serve --watch false if I run the tests with npx playwright test
  2. set the command to npx ng serve if I run the tests with UI mode by doing npx playwright test --ui

Is there any way that I can find out if the playwright.config.ts is being executed in UI mode?

This thread is trying to answer question "Is there a way to customize the `webServer.command` in `playwright.config.ts` based on the presence of the `--ui` flag when running tests?"

1 reply

I just noticed that if on the playwright.config.ts I do


then I get:

process.argv [
  'C:\\Program Files\\nodejs\\node.exe',

And there I can see the --ui option so I could do logic based on this to detect if I'm running in UI mode.

Is there any other way?

AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email luc@ray.run.