0

我使用 Playwright 进行集成测试。但是当我通过 jenkinsfile 运行它时,我看到了这个错误unexpected token {。错误发生在npm run test-chrome。有谁知道可能是什么问题?

package.json

{
  "name": "playwright",
  "version": "1.0.0",
  "description": "Automation tests",
  "main": "index.js",
  "scripts": {
    "test": "npx playwright test --headed --workers=1",
    "test-firefox": "npx playwright test --headed --workers=1 --project=firefox",
    "test-chrome": "npx playwright test --headed --workers=1 --project=chromium",
    "test-headless": "npx playwright test",
    "test-chrome": "export URL=https://www.google.com && npx playwright test --workers=1 --project=chromium"
  },
  "author": "home_cei",
  "license": "ISC",
  "devDependencies": {
    "@playwright/test": "^1.19.0",
    "prettier": "^2.4.3",
    "allure-playwright": "^2.0.0-beta.15",
    "mocha": "^9.1.2"
  },
  "dependencies": {
    "chai": "^4.3.4",
    "playwright-core": "^1.19.0"
  }
}

jenkinsfile

pipeline {
agent {
    label 'cicd-build'
  }
  stages {
    stage('Install Playwright') {
      steps {
        sh 'npm install'
      }
    }
    stage('Test') {
      steps {
        sh 'npm run test-chrome'
      }
    }
   }
      post {
        success {
        publishHTML target: [
        reportDir: 'Report',
        reportFiles: 'index.html',
        reportName: 'Test_Results'
        ]
        }
      }
    }
4

2 回答 2

1

“test-chrome”似乎是 package.json 的脚本部分中的重复键。也许这就是导致问题的原因。

于 2022-02-14T20:04:15.887 回答
0

发生此错误是因为我使用了错误node version <12的 . 更改我的版本后,它工作正常。

于 2022-03-03T19:37:56.517 回答