Does it make sense to write a unit test that a discord bot’s command times out after 10 minutes?

  Kiến thức lập trình

I’m creating a discord bot in discord.js and writing unit tests with Jest.

It’s an AI art bot that has a command called /generate that generates an image using a 3rd party API. This 3rd party api times out after 10 minutes — because sometimes the image just doesn’t get generated on their end.

I have code that polls the generation status every 5 seconds, and after 10 minutes it times out.

Does it make sense to test that my command /generate times out after 10 minutes? If yes, how would I mock the 3rd party API? And do I have to wait for the entire 10 minutes when testing, or how do I actually test it?

LEAVE A COMMENT