我尝试将我的Nightwatch.js测试整合到Jenkins工作中。如果测试失败,我希望Jenkins构建失败,如果所有测试都通过,我希望构建通过。但是我认识到Nightwatch总是返回exit code 1
,无论测试是通过还是失败都无关紧要。但我希望如果所有测试都通过,exit code 0
将会返回。
有没有人能解决这个问题?我将nightwatch@0.9.19
与nightwatch-cucumber@9.0.0
结合使用。
这是我的守夜人电话:
./node_modules/.bin/nightwatch --env chrome
如果所有测试都通过了:
./node_modules/.bin/nightwatch --env chrome
echo $?
#Output: 1, but I expect 0
如果我在最后一行用Nightwatch开始测试并且测试将通过,那么NPM命令将失败,因为在这种情况下错误exit code 1
:
> #!/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