Reputation: 772
I created a Jenkins pipeline that runs dockerize the frontend app, build it and run playwrite test cases.
My problem is that, the running tests stage doesn't move to the next step after running all tests.
Jenkins file:
#!groovy
pipeline {
agent any
stages {
stage('Checkout') {
steps {
echo 'Clean workspace'
cleanWs()
echo 'Checking out the PR'
checkout scm
}
}
stage('Build') {
steps {
echo 'Destroy Old Build'
echo 'Building'
sh 'make upbuild_d'
}
}
stage('Lint') {
steps {
echo 'Checking Lint'
sh 'make lint'
}
}
stage('Test') {
steps {
echo 'Running Tests ...'
sh 'make test-e2e'
}
}
}
// [StagePost] Clean after finishing
post {
always {
echo '## BEGIN ALWAYS BLOCK ##'
echo 'Destroy Build'
sh 'make destroy'
cleanWs()
echo '## END ALWAYS BLOCK ##'
}
}
}
Here is the make test-e2e
in Makefile
test-e2e:
docker exec my-container bash -c 'npm run test:e2e'
And this is the test:e2e
script npx playwright test --project=chromium
How can Jenkins detect that all tests are already run to execute the post steps?
Upvotes: 1
Views: 2907
Reputation: 4871
There are couple of ways you can do this
CI=true
to playwright command.CI=true npx playwright test
reporter: [['html', { open: 'never' }]],
The open
option has 3 possible values
always
, always open the HTML reportnever
, never open the HTML reporton-failure
, show the report only when the tests failedTo learn more about this, check ReporterDescription type, it has multiple options for reporter
export type ReporterDescription =
['dot'] |
['line'] |
['list'] |
['github'] |
['junit'] | ['junit', { outputFile?: string, stripANSIControlSequences?: boolean }] |
['json'] | ['json', { outputFile?: string }] |
['html'] | ['html', { outputFolder?: string, open?: 'always' | 'never' | 'on-failure', attachmentsBaseURL?: string }] |
['null'] |
[string] | [string, any];
Upvotes: 2
Reputation: 772
This issue occurred because of this line in playwright.config.js reporter: 'html'
.
This results in trying to open the test report in a browser that requires a GUI which isn't found inside the container, so the process hangs. It is fixed by updating the reporter config as reporter: [['html', { open: 'never' }]]
Upvotes: 4