fix(windows): address native CI review findings

This commit is contained in:
Tianyi Cui
2026-08-09 13:57:50 +08:00
parent eb9e7c19eb
commit 3b5ee1dce1
10 changed files with 41 additions and 21 deletions

View File

@@ -6,7 +6,7 @@ import { Context } from 'cordis'
import Hmr from '@cordisjs/plugin-hmr'
import Loader from '@cordisjs/plugin-loader'
import Timer from '@cordisjs/plugin-timer'
import { describe, expect, it } from 'vitest'
import { describe, expect, it, vi } from 'vitest'
async function bootHmr(dir: string, root: string[] = []): Promise<Context> {
const ctx = new Context()
@@ -33,7 +33,8 @@ describe('HMR exact config paths', () => {
symlinkSync(target, alias, process.platform === 'win32' ? 'junction' : 'dir')
writeFileSync(filename, 'export const generation = 0\n')
const ctx = await bootHmr(alias, ['.'])
const expected = pathToFileURL(filename).href
const expected = pathToFileURL(join(realpathSync(target), 'module.ts')).href
const cacheHas = vi.spyOn(ctx.loader.internal!.loadCache, 'has').mockReturnValue(false)
const observed: string[] = []
ctx.on('hmr/change', (url) => { observed.push(url) })
try {
@@ -43,6 +44,7 @@ describe('HMR exact config paths', () => {
writeFileSync(filename, `export const generation = ${generation}\n`)
await new Promise(resolve => setTimeout(resolve, 20))
}
expect(cacheHas).toHaveBeenCalledWith(expected)
} finally {
await ctx.fiber.dispose()
rmSync(alias, { force: true })