0

Currently failed tests send and exit code of 1 and successful ones send an exit code of 0. Can I have casper send an exit code of 2 on certain cases ?

Update in question:

Is it possible for casper to set a status code of (say) 2 and keep continuing with the remaining tests ?

1 Answer 1

0

In a non-test environment, you can use casper.exit(2); to exit with a specific code.


In a test environment this is a little harder, because the execution is done in casper.test.begin functions.
For example, you can use the last test case in a file to set the exit code:

casper.test.begin("test desc 1", function(test){ ... }); ... casper.test.begin("test desc last", function(test){ casper.exit(2); }); 

It might be better to use the exit event handler, though.

var code = 0; casper.on("exit", function(code){ if (code > 0) { phantom.exit(2); // immediately exits } }); casper.test.begin("test desc 1", function(test){ ... if (!this.visible("something")) { code = 3; } ... }); ... 
Sign up to request clarification or add additional context in comments.

3 Comments

Both suggestions are untested.
Those suggestions cannot be used to one specific test case, but only file wise. I will see if I can come up with something else. ... try-catch might work.
Did you get anywhere with that ? I am still stuck there

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.