Good day.
There is a browser game on js, all the code in one file, the file is connected to html. There was a question about how to make unit tests for the game. I looked at mocha and jasmine examples, but the simplest functions that return a specific value are tested there and in tests this return value is compared with the expected one. In my case, the functions in the code do not return anything, one sets the pictures, the other changes the coordinates of the player, the other draws, etc. An example of such a function:
function checkReadyState() { if (game.gameOverAudio.readyState === 4 && game.backgroundAudio.readyState === 4) { window.clearInterval(game.checkAudio); document.getElementById('loading').style.display = "none"; game.start(); }} This function returns nothing, and how can you tell if it passed the test or not? Or for each function add some special return value, which will indicate that the function has completed successfully?
How to test such code? And in what file should it be done, if all the code is in one file? I'm new to testing, so I rely on your advice. Thank you in advance