No tests found, exiting with code 1 in Jenkins Pipeline - jenkins

No tests found, exiting with code 1 in Jenkins Pipeline, I'm using jest-puppeteer, local all tests are running fine but whenever I run tests in Jenkin's pipeline its giving error "No tests found, exiting with code 1". I have configure test-sequencer.js and added path in jest.config.js but still no luck.enter image description here
enter image description here

Related

Suppress script in the Jenkins post build task

I am using Jenkins Post build task plugin to execute a bash script. The script is running fine, but the entire raw script is printed on the Jenkins console. Check section 3 in the image.
How can I avoid the script from getting printed on the Jenkins console?

junitxml jenkins plugin not showing output of passed tests (PyTest)

I am running pytest tests in a Jenkins scheduled job and generating a junitxml report as the following
pytest --junitxml=report.xml
Then I am using a post build action of publish junit test result and I can see the results but I don't see output of the passed tests (Even if I check the checkbox of "Retain long standard output/error"
Anyone succeeded in showing the output of passed tests when using pytest + junitxml publisher in Jenkins ?
It's due to Pytest that doesn't add end of line in the .xml.

Execute shell giving error in Jenkins Freestyle job

Whenever I am trying to do execute shell command in freestyle job in Jenkins, however when I try to do same thing while from pipeline, it is running successful.
Following is the error which I am getting in freestyle job:
It seems that the drive is full and there is no space left to execute this shell command. See this log:
So what you should do is to make sure that there is enough space on the drive where you run the script/command is available. Maybe you could switch to another partition or delete temporary or unused files.

Jenkins fails Jest tests that otherwise works (corporate proxy)

I am sitting behind corporate proxy.
So basically test is just page.goto("https://") I created Freestyle project and made it execute code in command line:
cd C:/Testing
npm test -- Jenkins
If I run these commands on machine where Jenkins is running, everything works and test passes. However, if I run it using Jenkins, this error appears:
Building in workspace C:\Program Files (x86)\Jenkins\workspace\Main Project
[Main Project] $ cmd /c call C:\Windows\TEMP\jenkins7770552654778169643.bat
C:\Program Files (x86)\Jenkins\workspace\Main Project>cd C:/Testing
C:\Testing>npm test -- Jenkins
> testing#1.0.0 test C:\Testing
> jest "Jenkins"
FAIL .\Jenkins.test.js (5.023s)
Describe
× Test (513ms)
� Describe › Test
net::ERR_TUNNEL_CONNECTION_FAILED at https://google.com/
at navigate (node_modules/puppeteer/lib/Page.js:539:37)
Test Suites: 1 failed, 1 total
Tests: 1 failed, 1 total
Snapshots: 0 total
Time: 6.587s
Ran all test suites matching /Jenkins/i.
npm ERR! Test failed. See above for more details.
Build step 'Execute Windows batch command' marked build as failure
Finished: FAILURE
I checked Jenkins HTTP Proxy Configuration and it was set up correctly (host, port and credentials are all correct), but if I enter https://google.com/ in Test URL and press "Validate Proxy", this error appears:
Failed to connect to https://google.com/ (code 407).
Is there something that can refuse Jenkins requests to websites? Windows Defender firewall is disabled.

Files not appearing in Jenkins workspace

I have an npm script that basically executes some unit tests with Jest and then generates a test-results.xml file in a dist/ folder. This is executed within a deploy.sh script that basically has a npm run test line in it that kicks off the test task.
When Jenkins runs my code, however, I can see that the tests are passing in the Jenkins console, but for some reason Jenkins can't see the test-results.xml file in the workspace. Hence, I get this error:
ERROR: Step ‘Publish JUnit test result report’ failed: No test report files were found. Configuration error?
It's weird because I SSH'd into my server and can clearly see that my test script generated a test-results.xml file under dist/ folder, but for some reason the entire dist/ folder and everything in it is conspicuously absent from my Jenkins workspace.
This question was resolved in question comments, but for future reference and other in similar situations:
Make sure that you are looking at the same place as Jenkins is. Jenkins always resolves the pattern provided in the Public JUnit test result report relative the workspace root.
For freestyle jobs or node steps in pipeline jobs, the location of the workspace root is printed on the console output, look for:
Building in workspace <jenkins_root>\workspace\<job_name>
or
Building remotely on Agent42 in workspace <path_to_workspaces>/workspace/<job_name>

Resources