Testing Cloud Code

Okay, I feel a bit stupid, so I’ll add this here for anyone else that has a brain fart like I had :smiley:

Your cloud code is executed within the context of the parse server instance during the request/response life cycle, so it makes sense that it has access to things like the master key…

What I was doing in the example above was importing those dao objects into the test file directly - i.e. outside of the parse instance…

So, if I make network requests to interact with my cloud code (as in the real world), the dao objects are automatically loaded in the correct context and work as they should.

I wish I’d spent a bit more time looking into test setups before I jump into it (I did, but because I inherited something that “worked”, I didn’t spend the time that I should have).

I’ve come across a few nice examples which I will use to update what I currently have.

For those that find this post, take a look at these two examples - hopefully you’ll save yourself some pain :smiley:

https://github.com/Pocket-Prep/parse-server-typescript

I hope this helps someone else.