[Bug] vite port (for development) (#3003)

* make vite-port configurable

and make it default 8000

* add retries for `does not trigger by non damage moves` test
This commit is contained in:
flx-sta 2024-07-12 18:20:22 -07:00 committed by GitHub
parent 8e44ddfde2
commit 589801214b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 23 additions and 10 deletions

View File

@ -4,3 +4,4 @@ VITE_SERVER_URL=http://localhost:8001
VITE_DISCORD_CLIENT_ID=1234567890
VITE_GOOGLE_CLIENT_ID=1234567890
VITE_I18N_DEBUG=1
VITE_PORT=8000

View File

@ -52,7 +52,10 @@ describe("Abilities - Quick Draw", () => {
expect(pokemon.battleData.abilitiesApplied).contain(Abilities.QUICK_DRAW);
}, 20000);
test("does not triggered by non damage moves", async () => {
test("does not triggered by non damage moves", {
timeout: 20000,
retry: 5
}, async () => {
await game.startBattle([Species.SLOWBRO]);
const pokemon = game.scene.getPlayerPokemon();
@ -67,7 +70,8 @@ describe("Abilities - Quick Draw", () => {
expect(pokemon.isFainted()).toBe(true);
expect(enemy.isFainted()).toBe(false);
expect(pokemon.battleData.abilitiesApplied).not.contain(Abilities.QUICK_DRAW);
}, 20000);
}
);
test("does not increase priority", async () => {
vi.spyOn(Overrides, "OPP_MOVESET_OVERRIDE", "get").mockReturnValue(Array(4).fill(Moves.EXTREME_SPEED));

1
src/vite.env.d.ts vendored
View File

@ -1,6 +1,7 @@
/// <reference types="vite/client" />
interface ImportMetaEnv {
readonly VITE_PORT?: string;
readonly VITE_BYPASS_LOGIN?: string;
readonly VITE_BYPASS_TUTORIAL?: string;
readonly VITE_API_BASE_URL?: string;

View File

@ -1,4 +1,4 @@
import { defineConfig } from 'vite';
import { defineConfig, loadEnv } from 'vite';
import tsconfigPaths from 'vite-tsconfig-paths';
export const defaultConfig = {
@ -20,10 +20,17 @@ export const defaultConfig = {
};
export default defineConfig(({mode}) => ({
...defaultConfig,
esbuild: {
pure: mode === 'production' ? [ 'console.log' ] : [],
keepNames: true,
},
}));
export default defineConfig(({mode}) => {
const envPort = Number(loadEnv(mode, process.cwd()).VITE_PORT);
return ({
...defaultConfig,
esbuild: {
pure: mode === 'production' ? ['console.log'] : [],
keepNames: true,
},
server: {
port: !isNaN(envPort) ? envPort : 8000,
}
});
});