Skip to content

Commit

Permalink
fix watch mode in Vitest 3
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinpalkovic committed Jan 15, 2025
1 parent a539692 commit 3071566
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions code/addons/test/src/node/vitest-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,22 +164,17 @@ export class VitestManager {
}

private updateLastChanged(filepath: string) {
if (isVitest3OrLater) {
const serverMods = this.vite?.moduleGraph.getModulesByFile(filepath);
serverMods?.forEach((mod) => this.vite?.moduleGraph.invalidateModule(mod));
} else {
const projects = this.vitest!.getModuleProjects(filepath);
projects.forEach(({ server, browser }) => {
if (server) {
const serverMods = server.moduleGraph.getModulesByFile(filepath);
serverMods?.forEach((mod) => server.moduleGraph.invalidateModule(mod));
}
if (browser) {
const browserMods = browser.vite.moduleGraph.getModulesByFile(filepath);
browserMods?.forEach((mod) => browser.vite.moduleGraph.invalidateModule(mod));
}
});
}
const projects = this.vitest!.getModuleProjects(filepath);
projects.forEach(({ server, browser }) => {
if (server) {
const serverMods = server.moduleGraph.getModulesByFile(filepath);
serverMods?.forEach((mod) => server.moduleGraph.invalidateModule(mod));
}
if (browser) {
const browserMods = browser.vite.moduleGraph.getModulesByFile(filepath);
browserMods?.forEach((mod) => browser.vite.moduleGraph.invalidateModule(mod));
}
});
}

private async fetchStories(indexUrl: string, requestStoryIds?: string[]) {
Expand Down

0 comments on commit 3071566

Please sign in to comment.