I try to integrate my Nightwatch.js tests in a Jenkins Job. I want the Jenkins build to fail if the tests will fail and I want the build to pass if all tests will pass. But I recognized that Nightwatch always returns the exit code 1
, doesn't matter if the tests will pass or fail. But I expect that the exit code 0
will be return if all tests will pass.
Does anyone have a solution for that issue? I use nightwatch@0.9.19
in combination with nightwatch-cucumber@9.0.0
.
This is my Nightwatch call:
./node_modules/.bin/nightwatch --env chrome
And if all tests were passed:
./node_modules/.bin/nightwatch --env chrome
echo $?
#Output: 1, but I expect 0
If I start the tests with the Nightwatch in last line and the test will pass, then the NPM command will fail because of the wrong exit code 1
in that case:
> #!/usr/bin/env sh
> ./node_modules/.bin/nightwatch --env $1 $2
>
Starting selenium server... started - PID: 86384
...
✔ Element <input#login-form-username> was visible after 41 milliseconds.
✔ Element <input#login-form-password> was visible after 36 milliseconds.
✔ Element <input#login> was visible after 34 milliseconds.
.
✔ Element <a#header-details-user-fullname> was visible after 6438 milliseconds.
✔ Element <a#log_out> was present after 22 milliseconds.
..
1 scenario (1 passed)
4 steps (4 passed)
0m16.298s
true
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! e2e-web-tests@1.0.0 test: `scripty "chrome" "--tag=lcm-128"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the e2e-web-tests@1.0.0 test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/GRme/.npm/_logs/2018-03-22T11_08_36_903Z-debug.log