Cancel All Protractor Tests On Condition Met

I have a basic Angular 6 app with e2e tests setup by default.

We make CRUD operations on a test database (the backend with the test environment should be running before starting the e2e tests).

The idea is to request a specific endpoint that returns true if the test environment is running. (backend in an express server)

In the very first spec I can make that request but throw new Error() doesn't stop the tests.

I've found some npm packages forcing the tests to exit on the first failure (jasmine fail whale and jasmine fail fast) but I don't want my tests to stop on any other exception than the wrong environment.

I tried making this test in protractor.conf.js in the onPrepare() method. I can throw new Error() there but I cannot make an http request (even basic XmlHTTPRequest is not defined)

What are my solutions to make sure the tests are run only when the right environment is running?



process.exit() seems to be a good enough solution for your use case.