mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-03 23:12:20 +02:00
more support for vitest
This commit is contained in:
parent
10a3d97076
commit
4fe69a29e9
2
.gitignore
vendored
2
.gitignore
vendored
@ -33,4 +33,4 @@ public/images/character/*/
|
|||||||
src/data/battle-anim-raw-data*.ts
|
src/data/battle-anim-raw-data*.ts
|
||||||
src/data/battle-anim-data.ts
|
src/data/battle-anim-data.ts
|
||||||
|
|
||||||
src/**/*.js
|
coverage
|
1226
package-lock.json
generated
1226
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
15
package.json
15
package.json
@ -8,19 +8,23 @@
|
|||||||
"build": "vite build",
|
"build": "vite build",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
"test": "vitest run",
|
"test": "vitest run",
|
||||||
"test:watch": "vitest watch"
|
"test:cov": "vitest run --coverage",
|
||||||
|
"test:watch": "vitest watch --coverage"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@vitest/coverage-istanbul": "^1.4.0",
|
||||||
"axios": "^1.6.2",
|
"axios": "^1.6.2",
|
||||||
"axios-cache-interceptor": "^1.3.2",
|
"axios-cache-interceptor": "^1.3.2",
|
||||||
"eslint": "^8.25.0",
|
"eslint": "^8.25.0",
|
||||||
"happy-dom": "^14.3.9",
|
"jsdom": "^24.0.0",
|
||||||
"json-beautify": "^1.1.1",
|
"json-beautify": "^1.1.1",
|
||||||
|
"phaser3spectorjs": "^0.0.8",
|
||||||
"pokenode-ts": "^1.20.0",
|
"pokenode-ts": "^1.20.0",
|
||||||
"typescript": "^5.0.3",
|
"typescript": "^5.0.3",
|
||||||
"vite": "^4.5.0",
|
"vite": "^4.5.0",
|
||||||
"vite-plugin-fs": "^0.4.4",
|
"vite-plugin-fs": "^0.4.4",
|
||||||
"vitest": "^1.4.0"
|
"vitest": "^1.4.0",
|
||||||
|
"vitest-canvas-mock": "^0.3.3"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@material/material-color-utilities": "^0.2.7",
|
"@material/material-color-utilities": "^0.2.7",
|
||||||
@ -35,5 +39,10 @@
|
|||||||
"imports": {
|
"imports": {
|
||||||
"#app": "./src/main.js",
|
"#app": "./src/main.js",
|
||||||
"#app/*": "./src/*"
|
"#app/*": "./src/*"
|
||||||
|
},
|
||||||
|
"jest": {
|
||||||
|
"setupFiles": [
|
||||||
|
"jest-canvas-mock"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
5
src/test/game.ts
Normal file
5
src/test/game.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import Phaser from "phaser";
|
||||||
|
|
||||||
|
export default new Phaser.Game({
|
||||||
|
type: Phaser.HEADLESS,
|
||||||
|
});
|
2
src/test/vitest.setup.ts
Normal file
2
src/test/vitest.setup.ts
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
import "vitest-canvas-mock";
|
||||||
|
import "#app/test/game";
|
@ -1,11 +1,22 @@
|
|||||||
import { expect, describe, it } from "vitest";
|
import { expect, describe, it } from "vitest";
|
||||||
import { randomString } from "./utils";
|
import { randomString } from "./utils";
|
||||||
|
|
||||||
|
import Phaser from "phaser";
|
||||||
|
|
||||||
describe("utils", () => {
|
describe("utils", () => {
|
||||||
describe("randomString", () => {
|
describe("randomString", () => {
|
||||||
it("should return a string of the specified length", () => {
|
it("should return a string of the specified length", () => {
|
||||||
const str = randomString(10);
|
const str = randomString(10);
|
||||||
expect(str.length).toBe(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);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -4,7 +4,26 @@ import { defineConfig } from 'vite';
|
|||||||
export default defineConfig(({ mode }) => {
|
export default defineConfig(({ mode }) => {
|
||||||
return {
|
return {
|
||||||
test: {
|
test: {
|
||||||
environment: 'happy-dom',
|
setupFiles: ['./src/test/vitest.setup.ts'],
|
||||||
|
environment: 'jsdom',
|
||||||
|
deps: {
|
||||||
|
optimizer: {
|
||||||
|
web: {
|
||||||
|
include: ['vitest-canvas-mock'],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
threads: false,
|
||||||
|
environmentOptions: {
|
||||||
|
jsdom: {
|
||||||
|
resources: 'usable',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
coverage: {
|
||||||
|
provider: 'istanbul',
|
||||||
|
reportsDirectory: 'coverage',
|
||||||
|
reporters: ['text-summary', 'html'],
|
||||||
|
},
|
||||||
},
|
},
|
||||||
plugins: [/*fs()*/],
|
plugins: [/*fs()*/],
|
||||||
server: { host: '0.0.0.0', port: 8000 },
|
server: { host: '0.0.0.0', port: 8000 },
|
||||||
|
Loading…
Reference in New Issue
Block a user