Search code examples
azureazure-devopsdevopsplaywright

Running Playwright tests in Azure DevOps Pipeline


I am using Playwright for acceptance-driven tests. I am using the steps listed in the "installation" section to set it up locally and run the playwright tests. I would like to now run the tests in the Azure DevOps pipeline. How can I convert these steps into appropriate tasks in the pipeline?


Solution

  • I was able to install and run using the following steps -

          - task: DotNetCoreCLI@2
            displayName: 'Build the E2E Test Application'
            inputs:
              command: build
              projects: $(workingDirectory)/MyProject.sln
    
          - task: CmdLine@2
            displayName: 'Install Browsers for Playwright'
            inputs:
              script: pwsh $(workingDirectory)/bin/Debug/net6.0/playwright.ps1 install
    
          - task: DotNetCoreCLI@2
            displayName: 'Run E2E Test'
            inputs:
              command: test
              projects: $(workingDirectory)/MyProject.sln
              arguments: '--filter "Category=MyFilteredTest"'
            env:
              MyEnvVar: $(myEnvVar)