geckosio / phaser-on-nodejs

Allows you to run Phaser 3 game (including Phaser's physics engines) on Node.js
MIT License
102 stars 11 forks source link

Bug running in Vitest #17

Closed zewa666 closed 1 year ago

zewa666 commented 1 year ago

I'm not 100% sure this is related to this library but it's perhaps worth giving it a shot. I'm trying to run my Phaser game with Vitest/Vite and have used this library as part of the vitest.setup.ts to stage everything so that the game can spin up in headless mode. This works since Vitest performs it's tests in NodeJS using JSDOM.

The issue I'm experiencing is lots of weird issues when my test watcher retriggers execution. It throws all type of weird Pango/Cairo related issues and ultimately kills the active terminal on Ubuntu. Over at windows, it just crashes the execution and leaves you in blank terminal.

Here's a little repro with the short steps involved to reproduce the bug.

https://github.com/zewa666/phaser-vitest-bug

Perhaps someone here has an idea what could be causing this. I've been searching/trying out things for a couple of hours, including destroying the game, delaying execution etc. but nothing helped so far.

zewa666 commented 1 year ago

setting isolate: false fixed it although its more of a workaround than an actual fix