Rayrun

How do I fix the 'unknown option --shard=2/3' error when executing Playwright tests in an Azure DevOps pipeline?

Answer

Install Playwright Dependencies

To fix the "unknown option --shard=2/3" error, start by installing Playwright and its dependencies on your build agent. Add a task to your pipeline that installs Playwright using npm or yarn. For example, with npm:

- task: Npm@1
  inputs:
    command: 'install'
    workingDir: '$(System.DefaultWorkingDirectory)'
    verbose: false

Verify Sharding Configuration

The --shard option is for sharding tests between multiple machines. If you're not sharding tests or only have one agent running, remove the --shard option from your command.

If sharding is necessary, ensure the value passed with --shard matches the number of shards specified in your configuration file or command line options. For example, if you have three shards for your test suite using npx playwright test --shard=1/3, make sure each shard value passed with --shard matches one of these values (1/3, 2/3, or 3/3).

Update Playwright Version

Updating Playwright to the latest version may resolve issues related to unsupported options like --shard. Add another task in your pipeline to update Playwright:

- script: npm install playwright@latest
  displayName: 'Update Playwright'

Check for Typos and Syntax Errors

Finally, check for any typos or syntax errors in the command line arguments when executing tests with Azure DevOps pipelines.

In summary, to fix the "unknown option --shard=2/3" error, ensure correct installation of dependencies, verify sharding configuration, update Playwright version if needed, and check for typos or syntax errors.

Thank you!
Was this helpful?
Still have questions?

If you still have questions, please ask a question and I will try to answer it.

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 [email protected].