test: localize mock.module setup to fresh imports

This commit is contained in:
YeonGyu-Kim
2026-04-04 19:49:25 +09:00
parent 8b8559f39d
commit a4db240d47
9 changed files with 204 additions and 158 deletions
+12 -12
View File
@@ -18,18 +18,6 @@ const mockAutoMigrate = mock((): MigrationResult => ({
const mockShowToast = mock((_arg: any) => Promise.resolve())
const mockLog = mock(() => {})
mock.module("../../shared/legacy-plugin-warning", () => ({
checkForLegacyPluginEntry: mockCheckForLegacyPluginEntry,
}))
mock.module("../../shared/logger", () => ({
log: mockLog,
}))
mock.module("./auto-migrate-runner", () => ({
autoMigrateLegacyPluginEntry: mockAutoMigrate,
}))
afterAll(() => {
mock.restore()
})
@@ -53,6 +41,18 @@ function createEvent(type: string, parentID?: string) {
}
async function importFreshModule() {
mock.module("../../shared/legacy-plugin-warning", () => ({
checkForLegacyPluginEntry: mockCheckForLegacyPluginEntry,
}))
mock.module("../../shared/logger", () => ({
log: mockLog,
}))
mock.module("./auto-migrate-runner", () => ({
autoMigrateLegacyPluginEntry: mockAutoMigrate,
}))
const module = await import(`./hook?t=${Date.now()}-${Math.random()}`)
mock.restore()
return module