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?
Answer
process.exit()
seems to be a good enough solution for your use case.
Related Questions
- → Maximum call stack exceeded when instantiating class inside of a module
- → Browserify api: how to pass advanced option to script
- → Node.js Passing object from server.js to external modules?
- → gulp-rename makes copies, but does not replace
- → requiring RX.js in node.js
- → Remove an ObjectId from an array of objectId
- → Can not connect to Redis
- → React: How to publish page on server using React-starter-kit
- → Express - better pattern for passing data between middleware functions
- → Can't get plotly + node.js to stream data coming through POST requests
- → IsGenerator implementation
- → Async/Await not waiting
- → (Socket.io on nodejs) Updating div with mysql data stops without showing error