[Test] Fix several flaky tests

This commit is contained in:
Michael Li 2024-10-11 01:46:40 -04:00
parent 3f63c147a3
commit 63aa792d43
4 changed files with 18 additions and 11 deletions

View File

@ -33,7 +33,7 @@ describe("Moves - Safeguard", () => {
.enemyLevel(5)
.starterSpecies(Species.DRATINI)
.moveset([ Moves.NUZZLE, Moves.SPORE, Moves.YAWN, Moves.SPLASH ])
.ability(Abilities.BALL_FETCH);
.ability(Abilities.UNNERVE); // Stop wild Pokemon from potentially eating Lum Berry
});
it("protects from damaging moves with additional effects", async () => {

View File

@ -18,6 +18,7 @@ import { Moves } from "#enums/moves";
import { ShinyRateBoosterModifier } from "#app/modifier/modifier";
import { SelectModifierPhase } from "#app/phases/select-modifier-phase";
import i18next from "i18next";
import { Abilities } from "#enums/abilities";
const namespace = "mysteryEncounters/anOfferYouCantRefuse";
/** Gyarados for Indimidate */
@ -37,10 +38,11 @@ describe("An Offer You Can't Refuse - Mystery Encounter", () => {
beforeEach(async () => {
game = new GameManager(phaserGame);
scene = game.scene;
game.override.mysteryEncounterChance(100);
game.override.startingWave(defaultWave);
game.override.startingBiome(defaultBiome);
game.override.disableTrainerWaves();
game.override.mysteryEncounterChance(100)
.startingWave(defaultWave)
.startingBiome(defaultBiome)
.disableTrainerWaves()
.ability(Abilities.INTIMIDATE); // Extortion ability
const biomeMap = new Map<Biome, MysteryEncounterType[]>([
[ Biome.VOLCANO, [ MysteryEncounterType.MYSTERIOUS_CHALLENGERS ]],
@ -195,6 +197,7 @@ describe("An Offer You Can't Refuse - Mystery Encounter", () => {
});
it("should award EXP to a pokemon with a move in EXTORTION_MOVES", async () => {
game.override.ability(Abilities.SYNCHRONIZE); // Not an extortion ability, so we can test extortion move
await game.runToMysteryEncounter(MysteryEncounterType.AN_OFFER_YOU_CANT_REFUSE, [ Species.ABRA ]);
const party = scene.getParty();
const abra = party.find((pkm) => pkm.species.speciesId === Species.ABRA)!;

View File

@ -176,10 +176,12 @@ describe("Berries Abound - Mystery Encounter", () => {
const encounterTextSpy = vi.spyOn(EncounterDialogueUtils, "showEncounterText");
await game.runToMysteryEncounter(MysteryEncounterType.BERRIES_ABOUND, defaultParty);
scene.getParty().forEach(pkm => {
vi.spyOn(pkm, "getStat").mockReturnValue(1); // for ease return for every stat
});
const config = game.scene.currentBattle.mysteryEncounter!.enemyPartyConfigs[0];
const speciesToSpawn = config.pokemonConfigs?.[0].species.speciesId;
// Setting enemy's level arbitrarily high to outspeed
config.pokemonConfigs![0].dataSource!.level = 1000;
await runMysteryEncounterToEnd(game, 2, undefined, true);
@ -198,10 +200,12 @@ describe("Berries Abound - Mystery Encounter", () => {
const encounterTextSpy = vi.spyOn(EncounterDialogueUtils, "showEncounterText");
await game.runToMysteryEncounter(MysteryEncounterType.BERRIES_ABOUND, defaultParty);
scene.getParty().forEach(pkm => {
vi.spyOn(pkm, "getStat").mockReturnValue(1); // for ease return for every stat
});
const config = game.scene.currentBattle.mysteryEncounter!.enemyPartyConfigs[0];
const speciesToSpawn = config.pokemonConfigs?.[0].species.speciesId;
// Setting enemy's level arbitrarily high to outspeed
config.pokemonConfigs![0].dataSource!.level = 1000;
await runMysteryEncounterToEnd(game, 2, undefined, true);

View File

@ -147,8 +147,8 @@ describe("The Pokemon Salesman - Mystery Encounter", () => {
expect(scene.getParty().length).toBe(initialPartySize + 1);
const newlyPurchasedPokemon = scene.getParty().find(p => p.name === pokemonName);
expect(newlyPurchasedPokemon).toBeDefined();
const newlyPurchasedPokemon = scene.getParty()[scene.getParty().length - 1];
expect(newlyPurchasedPokemon.name).toBe(pokemonName);
expect(newlyPurchasedPokemon!.moveset.length > 0).toBeTruthy();
});