Add unit testing support with vitest (#18)
* update loose files and add vitest * update test scripts * more support for vitest * more test support * update vscode settings
This commit is contained in:
1 parent
4e911a9be9
commit
53def01b51
14 files changed
+3232
-41
No files matched your search
@@ -0,0 +1,5 @@
|
||||
import Phaser from "phaser";
|
||||
|
||||
export default new Phaser.Game({
|
||||
type: Phaser.HEADLESS,
|
||||
});
|
||||
@@ -0,0 +1,2 @@
|
||||
import "vitest-canvas-mock";
|
||||
import "#app/test/phaser.setup";
|
||||
@@ -0,0 +1,22 @@
|
||||
import { expect, describe, it } from "vitest";
|
||||
import { randomString } from "./utils";
|
||||
|
||||
import Phaser from "phaser";
|
||||
|
||||
describe("utils", () => {
|
||||
describe("randomString", () => {
|
||||
it("should return a string of the specified length", () => {
|
||||
const str = randomString(10);
|
||||
expect(str.length).toBe(10);
|
||||
});
|
||||
|
||||
it("should work with seed", () => {
|
||||
const state = Phaser.Math.RND.state();
|
||||
const str1 = randomString(10, true);
|
||||
Phaser.Math.RND.state(state);
|
||||
const str2 = randomString(10, true);
|
||||
|
||||
expect(str1).toBe(str2);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user