Stock Price Checker multiple request in one test

So, after an excruciatingly difficult few days trying to sort out and understand how to manage async code and playing around with the multiple notions of promises, chaining them and mistakenly scoping most of my processing into callbacks I believe I seem to have finally managed doing something at least functional.

The only thing that really bothers me with it is that I couldn’t figure out how to make the last test (Like two stocks) work aside from splitting it into 6 requests. I am creating random stock tickers for these tests which I am keeping track of so I can establish that, although both tests show the same amount of rel_likes, the two individual stock’s likes counts are increased doing the requests on both at once.

My problem is that for this to work I have to submit 6 different requests as follow:

  • View stock no.1
  • View stock no.2
  • View Both
  • View & Like Both
  • View stock no.1 again
  • View stock no.2 again.

I would like to have this whole process and the required assertions fitting into one test only but when I try to make all the requests and validation calling only once Done() at the end of it all I find myself having the following problems :

  • All the tests ‘‘pass’’ according to the framework’s sort of final assertion (the all get a green check)
  • If an assertion fails somewhere in the line, after the test is done and indicated as passed, the whole app crashes on the assertion that did,t get though.

So what I have done is a workaround but I now have 10 tests instead of 5 and all this said and done, this should still all be done within one…

So my question I guess would be… Is there a way to make 6 different requests within one test, save the responses and assert them at the end?

Would that be the way to go or am I missing something?

Otherwise, be free to comment on my solution if you see something you believe would be helpful to my understanding as I am trying to up my game and this challenge was really something on many levels.

Code on Repl

Thanks again to the kind strangers taking time to help!

Challenge: Stock Price Checker

Link to the challenge: