Skip to content

Commit

Permalink
fix: Flakey tests caused by Debug static
Browse files Browse the repository at this point in the history
  • Loading branch information
eonarheim committed Feb 16, 2024
1 parent a633af4 commit 376b38c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ module.exports = (config) => {
'--disable-gpu',
'--no-sandbox',
'--enable-precise-memory-info',
'--js-flags="--max_old_space_size=8192 --expose-gc"'
'--js-flags="--max_old_space_size=8192"'
]
},
ChromiumHeadless_with_debug: {
Expand Down
12 changes: 7 additions & 5 deletions src/engine/Debug/DebugSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,12 +295,14 @@ export class DebugSystem extends System {
}

postupdate(engine: Scene<unknown>, elapsedMs: number): void {
this._graphicsContext.save();
if (this._camera) {
this._camera.draw(this._graphicsContext);
if (this._engine.isDebug) {
this._graphicsContext.save();
if (this._camera) {
this._camera.draw(this._graphicsContext);
}
Debug.flush(this._graphicsContext);
this._graphicsContext.restore();
}
Debug.flush(this._graphicsContext);
this._graphicsContext.restore();
}

/**
Expand Down
3 changes: 3 additions & 0 deletions src/spec/DebugSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ describe('Debug draw static', () => {
it('exists', () => {
expect(ex.Debug).toBeDefined();
});
beforeEach(() => {
ex.Debug.clear();
});

afterEach(() => {
ex.Debug.clear();
Expand Down
1 change: 1 addition & 0 deletions src/spec/util/TestUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export namespace TestUtils {
displayMode: ex.DisplayMode.Fixed,
...options
};
ex.Debug.clear();
ex.Flags._reset();
ex.Flags.enable('suppress-obsolete-message');
flags.forEach(f => ex.Flags.enable(f));
Expand Down

0 comments on commit 376b38c

Please sign in to comment.