I have no problem executing the playwright scripts on my desktop. However I encounter an error when executing in Jenkins.
Any idea how to resolve this error?
+ 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)
My Jenkins file
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'
}
}
}
In the jenkins file whether I execute npm install or not I get the same result.
Check two things:
Are you inside the right directory ? Are you running the commands inside a folder where you are supposed to run?
Are you giving all file paths with the correct casing? May be like you typed all in lower case or changed casing at later stage.