Rayrun
← Back to Discord Forum

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

___kakashi___posted in #help-playwright
Open in Discord
___kakashi___
___kakashi___

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
___kakashi___
___kakashi___

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

console.log("process.argv",process.argv);

then I get:

process.argv [
  'C:\\Program Files\\nodejs\\node.exe',
  'C:\\dev\\repos\\playwright-adventures\\demos\\code-coverage-with-monocart-reporter\\node_modules\\@playwright\\test\\cli.js',
  'test',
  '--ui'
]

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?

TwitterGitHubLinkedIn
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.