From a68ca052641f9f33b6d1f630d035b90fc0ed7fe4 Mon Sep 17 00:00:00 2001 From: Joerg <24250824+svdHero@users.noreply.github.com> Date: Thu, 8 Sep 2022 08:22:42 +0200 Subject: [PATCH] docs(ci): add detailed code snippets for Azure Pipelines (#17125) --- docs/src/ci.md | 71 +++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 64 insertions(+), 7 deletions(-) diff --git a/docs/src/ci.md b/docs/src/ci.md index 6eb9561251..1e899675c9 100644 --- a/docs/src/ci.md +++ b/docs/src/ci.md @@ -293,15 +293,72 @@ Pipelines support [running containerized jobs](https://docs.microsoft.com/en-us/azure/devops/pipelines/process/container-phases?view=azure-devops). Alternatively, you can use [Command line tools](./cli.md#install-system-dependencies) to install all necessary dependencies. +For running the Playwright tests use this pipeline task: ```yml -pool: - vmImage: 'ubuntu-20.04' - -container: mcr.microsoft.com/playwright:v1.26.0-focal - -steps: -... +jobs: + - deployment: Run_E2E_Tests + pool: + vmImage: ubuntu-20.04 + container: mcr.microsoft.com/playwright:v1.26.0-focal + environment: testing + strategy: + runOnce: + deploy: + steps: + - checkout: self + - task: Bash@3 + displayName: 'Run Playwright tests' + inputs: + workingDirectory: 'my-e2e-tests' + targetType: 'inline' + failOnStderr: true + env: + CI: true + script: | + npm ci + npx playwright test ``` +This will make the pipeline run fail if any of the playwright tests fails. +If you also want to integrate the test results with Azure DevOps, use `failOnStderr:false` and the built-in `PublishTestResults` task like so: +```yml +jobs: + - deployment: Run_E2E_Tests + pool: + vmImage: ubuntu-20.04 + container: mcr.microsoft.com/playwright:v1.26.0-focal + environment: testing + strategy: + runOnce: + deploy: + steps: + - checkout: self + - task: Bash@3 + displayName: 'Run Playwright tests' + inputs: + workingDirectory: 'my-e2e-tests' + targetType: 'inline' + failOnStderr: false + env: + CI: true + script: | + npm ci + npx playwright test + exit 0 + - task: PublishTestResults@2 + displayName: 'Publish test results' + inputs: + searchFolder: 'my-e2e-tests/test-results' + testResultsFormat: 'JUnit' + testResultsFiles: 'e2e-junit-results.xml' + mergeTestResults: true + failTaskOnFailedTests: true + testRunTitle: 'My End-To-End Tests' +``` +Note: The JUnit reporter needs to be configured accordingly via +```ts +["junit", { outputFile: "test-results/e2e-junit-results.xml" }] +``` +in `playwright.config.ts`. ### CircleCI