-
Notifications
You must be signed in to change notification settings - Fork 180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(phaserx): allow running phaser in headless mode for unit testing in jest #112
Conversation
davidkol
commented
Jul 27, 2022
- allow jest unit testing on phaser layer
- skip waiting for phaser textures when running in headless mode
- check if renderer exists before using it
packages/phaserx/src/defineScene.ts
Outdated
renderer?.pipelines?.add(HueTintAndOutlineFXPipeline.KEY, new HueTintAndOutlineFXPipeline(this.game)); | ||
renderer?.pipelines?.add(MultiHueTintPipeline.KEY, new MultiHueTintPipeline(this.game)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need the first question mark? (Is renderer undefined in Headless mode or only pipelines?)
renderer?.pipelines?.add(HueTintAndOutlineFXPipeline.KEY, new HueTintAndOutlineFXPipeline(this.game)); | |
renderer?.pipelines?.add(MultiHueTintPipeline.KEY, new MultiHueTintPipeline(this.game)); | |
renderer.pipelines?.add(HueTintAndOutlineFXPipeline.KEY, new HueTintAndOutlineFXPipeline(this.game)); | |
renderer.pipelines?.add(MultiHueTintPipeline.KEY, new MultiHueTintPipeline(this.game)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like we dont, renderer is defined, great catch!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
scratch that, it didnt save when i ran the tests with that change, renderer is NOT defined and does in fact need to be checked
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could also mock this function instead of checking for renderer
@@ -87,7 +87,7 @@ export function createChunkedTilemap<TileKeys extends number, LayerKeys extends | |||
); | |||
|
|||
if (layer.hasHueTintShader) { | |||
layers[key].pipeline = (scene.game.renderer as Phaser.Renderer.WebGL.WebGLRenderer).pipelines.get( | |||
layers[key].pipeline = (scene.game.renderer as Phaser.Renderer.WebGL.WebGLRenderer)?.pipelines?.get( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same question here, is renderer undefined in Headless mode or just pipelines?
layers[key].pipeline = (scene.game.renderer as Phaser.Renderer.WebGL.WebGLRenderer)?.pipelines?.get( | |
layers[key].pipeline = (scene.game.renderer as Phaser.Renderer.WebGL.WebGLRenderer).pipelines?.get( |
… in jest (latticexyz#112) * feat(phaserx): allow running phaser in headless mode for unit testing * fix(phaserx): clean up renderer undefined checks and headless equality check * refactor(phaserx): clean up renderer pipeline checks