Testing djs commands/flows
What's the generic consensus for (unit/integration) testing commands? Mock the djs return values? Room for error if I my mock doesn't reproduce the behaviour accurately.
I'm currently testing all of the beneath code for accessing my data (services/models).
6 Replies
- What's your exact discord.js
npm list discord.js
and node node -v
version?
- Not a discord.js issue? Check out #other-js-ts.
- Consider reading #how-to-get-help to improve your question!
- Explain what exactly your issue is.
- Post the full error stack trace, not just the top part!
- Show your code!
- Issue solved? Press the button!To expand, my current mocking is someting like this:
imo just testing the backend logic and not the bot layer is enough
Yeah I’ve taken such approach. Abstracted the reply method, and spy on that
that's not what I said though
say you wanted to test the /pay command, you can make your command execute look like (in a very simplified way)
then testing the banking service would be enough to test almost all of the logic, and pretty much all the parts you'd want to test
right ok, thank you