Jenkins pipeline passes the npm run test
stage even if no mongo connection is found and no test run.
This is the simple Jenkinsfile test section:
code{
stage('Checkout')
{
echo 'Getting source code...'
checkout scm
}
stage('Build Test Environment')
{
echo 'Building dependencies...'
sh 'npm i'
}
stage('Runnin Test')
{
echo 'Testing...'
sh 'npm run test'
}
I am running mongo locally on the build server as docker image.
And I get this error:
MongoError: failed to connect to server mongo
But I want my build to fail if no mongo connection is found or the test cases fail.