Roddy of the Frozen Peas
Roddy of the Frozen Peas

Reputation: 15180

Protractor exits with retcode 1 if tests are skipped/pended

My build pipeline relies on the Protractor process terminating with a non-successful retcode when there are errors. All my tests pass, but I just added a test that is pended (using Jasmine's pending('reason').) This is causing Protractor to exit with a retcode of 1 and causing pipeline issues.

I've already patched the Jasmine spec reporter to correctly identify pended tests as non-failures. How can I do something similar to keep Protractor from existing with a failure code? It still thinks there are test failures, so either it determines the run state before it hits my custom reporter, or it's using some other mechanism.

This is what my Logs show:

[2021-01-29T06:06:46.352Z] **************************************************
[2021-01-29T06:06:46.352Z] *                    Pending                     *
[2021-01-29T06:06:46.352Z] **************************************************
[2021-01-29T06:06:46.352Z] 
[2021-01-29T06:06:46.352Z] 1) Sample pended test
[2021-01-29T06:06:46.352Z]   Pended as an example
[2021-01-29T06:06:46.352Z] 
[2021-01-29T06:06:46.352Z] Executed 19 of 22 specs INCOMPLETE (1 PENDING) (2 SKIPPED) in 3 mins 49 secs.
[2021-01-29T06:06:46.352Z] [06:06:46] I/launcher - 0 instance(s) of WebDriver still running
[2021-01-29T06:06:46.352Z] [06:06:46] I/launcher - chrome #01 failed 1 test(s)
[2021-01-29T06:06:46.352Z] [06:06:46] I/launcher - overall: 1 failed spec(s)
[2021-01-29T06:06:46.352Z] [06:06:46] E/launcher - Process exited with error code 1

It seems as though Protractor itself is still considering the test as a failure, based on the 'overall: 1 failed spec(s)' message. How can I get Protractor to not consider pended tests as failed, and return exit code 0?

Upvotes: 0

Views: 36

Answers (1)

Sergey Pleshakov
Sergey Pleshakov

Reputation: 8948

So looks like when you do pending('reason') the code automatically passes to 1 which is non successful.

The problem is, if protractor encounters the real error its value will also be 1, so you can't really catch it easily and be sure this is coming from pending tests

But, since you're using Jasmine 3.6.3, you may use another advantage it gives you. Instead of using pending you can use xit. This will disable your it block. More info https://jasmine.github.io/api/2.7/global.html#xit

Upvotes: 0

Related Questions