You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am currently trying to test that a command exits with code 1. In the command, the code simply calls this.exit(1) and the test I am trying to assert with .exit(1). However, I am getting the error Error: Expected to exit with code 1 but it ran without exiting. See PR for context.
I have the suspicion that the exit test would always fail, as its run method always throws an error. How can I handle this situation?
Thanks in advance!
The text was updated successfully, but these errors were encountered:
@JarnoRFB Calling this.exit throws an error, which the exit hook's catch method is supposed to pick up. If the run method is executed instead of the catch - that means that you're command didn't throw an error, which is why it's telling you that it ran without exiting.
If you modify the the catch method on the base command class is to throw an error here then your test will begin passing.
@mdonnalley That makes a lot of sense. Thank you for the clarification!
As it is implemented right now, the base class seems to catch any error and just set the exit code to 1 in this case. Is there any way to assert the exit code in the test without requiring the command to throw an error?
I am currently trying to test that a command exits with code 1. In the command, the code simply calls
this.exit(1)
and the test I am trying to assert with.exit(1)
. However, I am getting the errorError: Expected to exit with code 1 but it ran without exiting
. See PR for context.I have the suspicion that the
exit
test would always fail, as its run method always throws an error. How can I handle this situation?Thanks in advance!
The text was updated successfully, but these errors were encountered: