Automating Tests For A Phaser Game

Hello community,

I was wondering if there is anyway to create automated tests for a game made in Phaser 3. For example testing collisions, expected results and output, see if a certain scene is working properly, etc. I know there are NPM packages like mocha, jest, chai, etc. that do this with REST APIs and Javascript code, but do they also work for running tests on Phaser? Thank you in advance!

Att.
4tydev

:wave:

I’ve done some of this with mocha’s in-browser test runner but it can get pretty complicated. For precise work you need to stop the game loop and step manually.

1 Like

I use jest to test my utility methods.

For example I have a method tile2pixel, where I convert a tile position to pixel position. So in the test I check if { x: 8, y: 12 } results in { x: 409, y: 616 }.

I run all tests automatically on every git commit, so I make sure I don’t crash any code on a new commit.

1 Like

Thank you! I will test using jest and see how it goes! Thanks for the advice!