我在桌面上执行剧作家脚本没有问题。但是我在 Jenkins 中执行时遇到错误。
知道如何解决此错误吗?
+ npx playwright test
<------My ENV---->prod
Error: Playwright Test did not expect test.describe() to be called here.
Most common reasons include:
- You are calling test.describe() in a configuration file.
- You are calling test.describe() in a file that is imported by the configuration file.
- You have two different versions of @playwright/test. This usually happens
when one of the dependencies in your package.json depends on @playwright/test.
at cgt_crossroad_validation\tests\CrossRoad_AIR.spec.js:11
9 | let loginClass
10 |
> 11 | test.describe('Validation Catering invoice processing', () => {
| ^
12 |
13 | test.beforeEach(async ({browser }, testInfo) => {
14 | page = await browser.newPage();
at TestTypeImpl._currentSuite (E:\.jenkins\workspace\CrossRoad_Validation\cgt_crossroad_validation\node_modules\playwright\lib\common\testType.js:71:13)
at TestTypeImpl._describe (E:\.jenkins\workspace\CrossRoad_Validation\cgt_crossroad_validation\node_modules\playwright\lib\common\testType.js:104:24)
at Function.describe (E:\.jenkins\workspace\CrossRoad_Validation\cgt_crossroad_validation\node_modules\playwright\lib\transform\transform.js:256:12)
at Object.<anonymous> (E:\.jenkins\workspace\CrossRoad_Validation\cgt_crossroad_validation\tests\CrossRoad_AIR.spec.js:11
:6)
我的詹金斯文件
stages {
stage("checkout") {
steps {
checkoutRepo(branch, project, cgtx_repo)
}
}
// stage('Install Playwright') {
// steps {
// sh 'npm install -g playwright'
// }
// }
stage('Install dependencies') {
steps {
dir('cgt_crossroad_validation') {
// Execute npm install within the changed directory
sh 'npm install'
}
}
}
stage('Run Playwright Tests') {
steps {
sh 'npx playwright test'
}
}
}
在jenkins文件中,无论我是否执行npm install,我都会得到相同的结果。
检查两件事:
您在正确的目录中吗?您是否在应该运行的文件夹中运行命令?
您是否为所有文件路径提供了正确的大小写?可能就像您全部用小写输入或在后期更改了大小写。