最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Azure Pipeline if failing on step while installing Playwright - Stack Overflow

programmeradmin0浏览0评论

I'm trying to configure Azure pipeline for Playwright tests, but pipeline is always failing on step when installing Playwright with error:

Can someone help me solving this issue? My .yml file looks like this:

# Playwright execution yaml pipeline
trigger:
  - main
  - develop

pool:
  name: 'Ultra Violet Team'

parameters:
- name: target_environment
  displayName: Target API Environment
  type: string
  default: development
  values:
  - development
  - staging
  - production

name: Playwright_Tests_Execution_${{parameters.target_environment}}_$(Date:yyyyMMdd)$(Rev:r)

steps:
  - task: NodeTool@0
    inputs:
      versionSpec: '14.x'
    displayName: 'Install Node.js'

  - script: |
      npm ci
    displayName: 'Installing Playwright'

  #Install Browsers
  - script: |
      npx playwright install --with-deps
    displayName: "Update Playwright deps"

  - script: |
      npm run test:runo365test
    displayName: 'Run Playwright tests'
    env:
      TARGET_ENVIRONMENT: ${{ parameters.target_environment }}

  - script: |
      npm run generateReport
    displayName: 'Generate report'
    condition: always()

  - task: ArchiveFiles@2
    displayName: 'Add test-results to Archive'
    inputs:
      rootFolderOrFile: '$(Pipeline.Workspace)/s/test-report/reports/'
      archiveFile: '$(Agent.TempDirectory)/$(Build.BuildId)_$(System.JobAttempt)$(System.StageAttempt).zip'
      replaceExistingArchive: true
    condition: always()

  - task: PublishBuildArtifacts@1
    displayName: 'Publish Artifacts'
    inputs:
      pathToPublish: '$(Agent.TempDirectory)/$(Build.BuildId)_$(System.JobAttempt)$(System.StageAttempt).zip'
      artifactName: pipeline-artifact
    condition: always()

Also package.json looks like this:

"name": "uv-playwright-tests",
  "version": "1.0.0",
  "main": "index.js",
  "scripts": {
    "build": "tsc --noEmit",
    "esLint": "eslint .",
    "esLint-fix": "eslint . --fix",
    "e2e:headless": "npx playwright test",
    "e2e:headed": "npx playwright test --headed",
    "e2e:chrome-headed": "npx playwright test --project=Chromium --headed",
    "e2e:chrome-headless": "npx playwright test --project=Chromium",
    "test:runo365test": "npx playwright test",
    "generateReport": "npx playwright show-report",
    "e2e:generate-html-report": "npx playwright show-report",
    "e2e:generate-allure-report": "allure generate ./allure-results -o ./allure-report --clean"
  },
  "devDependencies": {
    "@eslint/js": "^9.15.0",
    "@faker-js/faker": "^9.2.0",
    "eslint-plugin-playwright": "^2.1.0",
    "allure-commandline": "^2.32.0",
    "allure-playwright": "^3.0.6",
    "dotenv": "^16.4.5",
    "fs-extra": "^11.2.0",
    "globals": "^15.12.0",
    "prettier": "^3.3.3",
    "typescript": "^5.6.3",
    "typescript-eslint": "^8.15.0",
    "ts-node": "^10.9.2"
  },

  "dependencies": {
  "authenticator": "^1.1.5",
  "@types/authenticator": "^1.1.4",
  "ts-node": "^10.9.2",
  "@types/node": "^22.9.1",
  "playwright": "^1.49.0",
  "@playwright/test": "^1.49.0",
  "eslint": "^9.15.0",
  "eslint-config-prettier": "^9.1.0",
  "eslint-plugin-import": "^2.31.0",
  "eslint-plugin-playwright": "^2.1.0",
  "eslint-plugin-prettier": "^5.2.1",
  "@typescript-eslint/eslint-plugin": "^8.15.0",
  "@typescript-eslint/parser": "^8.15.0"

I assume that issue is in package.json and package-lock.json, but I cannot solve it

I'm trying to configure Azure pipeline for Playwright tests, but pipeline is always failing on step when installing Playwright with error:

Can someone help me solving this issue? My .yml file looks like this:

# Playwright execution yaml pipeline
trigger:
  - main
  - develop

pool:
  name: 'Ultra Violet Team'

parameters:
- name: target_environment
  displayName: Target API Environment
  type: string
  default: development
  values:
  - development
  - staging
  - production

name: Playwright_Tests_Execution_${{parameters.target_environment}}_$(Date:yyyyMMdd)$(Rev:r)

steps:
  - task: NodeTool@0
    inputs:
      versionSpec: '14.x'
    displayName: 'Install Node.js'

  - script: |
      npm ci
    displayName: 'Installing Playwright'

  #Install Browsers
  - script: |
      npx playwright install --with-deps
    displayName: "Update Playwright deps"

  - script: |
      npm run test:runo365test
    displayName: 'Run Playwright tests'
    env:
      TARGET_ENVIRONMENT: ${{ parameters.target_environment }}

  - script: |
      npm run generateReport
    displayName: 'Generate report'
    condition: always()

  - task: ArchiveFiles@2
    displayName: 'Add test-results to Archive'
    inputs:
      rootFolderOrFile: '$(Pipeline.Workspace)/s/test-report/reports/'
      archiveFile: '$(Agent.TempDirectory)/$(Build.BuildId)_$(System.JobAttempt)$(System.StageAttempt).zip'
      replaceExistingArchive: true
    condition: always()

  - task: PublishBuildArtifacts@1
    displayName: 'Publish Artifacts'
    inputs:
      pathToPublish: '$(Agent.TempDirectory)/$(Build.BuildId)_$(System.JobAttempt)$(System.StageAttempt).zip'
      artifactName: pipeline-artifact
    condition: always()

Also package.json looks like this:

"name": "uv-playwright-tests",
  "version": "1.0.0",
  "main": "index.js",
  "scripts": {
    "build": "tsc --noEmit",
    "esLint": "eslint .",
    "esLint-fix": "eslint . --fix",
    "e2e:headless": "npx playwright test",
    "e2e:headed": "npx playwright test --headed",
    "e2e:chrome-headed": "npx playwright test --project=Chromium --headed",
    "e2e:chrome-headless": "npx playwright test --project=Chromium",
    "test:runo365test": "npx playwright test",
    "generateReport": "npx playwright show-report",
    "e2e:generate-html-report": "npx playwright show-report",
    "e2e:generate-allure-report": "allure generate ./allure-results -o ./allure-report --clean"
  },
  "devDependencies": {
    "@eslint/js": "^9.15.0",
    "@faker-js/faker": "^9.2.0",
    "eslint-plugin-playwright": "^2.1.0",
    "allure-commandline": "^2.32.0",
    "allure-playwright": "^3.0.6",
    "dotenv": "^16.4.5",
    "fs-extra": "^11.2.0",
    "globals": "^15.12.0",
    "prettier": "^3.3.3",
    "typescript": "^5.6.3",
    "typescript-eslint": "^8.15.0",
    "ts-node": "^10.9.2"
  },

  "dependencies": {
  "authenticator": "^1.1.5",
  "@types/authenticator": "^1.1.4",
  "ts-node": "^10.9.2",
  "@types/node": "^22.9.1",
  "playwright": "^1.49.0",
  "@playwright/test": "^1.49.0",
  "eslint": "^9.15.0",
  "eslint-config-prettier": "^9.1.0",
  "eslint-plugin-import": "^2.31.0",
  "eslint-plugin-playwright": "^2.1.0",
  "eslint-plugin-prettier": "^5.2.1",
  "@typescript-eslint/eslint-plugin": "^8.15.0",
  "@typescript-eslint/parser": "^8.15.0"

I assume that issue is in package.json and package-lock.json, but I cannot solve it

Share Improve this question edited Nov 20, 2024 at 18:16 Josip Herceg asked Nov 20, 2024 at 13:13 Josip HercegJosip Herceg 313 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

According to the npm-ci document, if dependencies in the package-lock.json do not match those in package.json, npm ci will exit with an error.

You can run the following command in your local to get an up to date package-lock.json file and update it to your repo.

npm install
ls | grep package-lock

Test result with new package-lock.json file:

Or you can use the npm install command instead of the npm ci command in your pipeline. By default, npm install will install all modules listed as dependencies in package.json.

  - script: |
      npm install 
    displayName: 'run npm install'

Test result:

发布评论

评论列表(0)

  1. 暂无评论