Rayrun

How do I configure Playwright tests to run in an Azure DevOps pipeline?

Answer

To run @playwright/test in Azure DevOps, follow these steps:

1. Install Playwright Test task

First, install the Playwright Test task from the Azure DevOps Marketplace.

2. Add the task to your pipeline

Add the Playwright Test task to your pipeline by editing your azure-pipelines.yml file.

3. Configure the task

Configure the task by specifying the path to your test files and selecting the browsers you want to test. You can also choose whether to show browsers during testing and set other options such as headless mode.

- task: PlaywrightTest@0
  inputs:
    testFilesPath: '**/*.spec.ts'
    browsers: 'chromium,firefox,webkit'
    headless: true

4. Install dependencies

If you need to install any dependencies before running your tests, such as Node.js or NPM packages, add these steps before running the Playwright Test task.

- task: NodeTool@0
  inputs:
    versionSpec: '14.x'
- script: npm ci

5. Run the pipeline

Once configured, run your pipeline in Azure DevOps. It will automatically execute your Playwright tests according to their configurations. Any errors or failures will be reported back through Azure DevOps.

Here's an example of a complete azure-pipelines.yml file:

trigger:
  branches:
    include:
      - main

pool:
  vmImage: 'ubuntu-latest'

steps:
- task: NodeTool@0
  inputs:
    versionSpec: '14.x'

- script: npm ci

- task: PlaywrightTest@0
  inputs:
    testFilesPath: '**/*.spec.ts'
    browsers: 'chromium,firefox,webkit'
    headless: true

Now you're all set to run your @playwright/test tests in Azure DevOps!

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