我使用 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'
]
}
}
}