From 745d69cab326aedd933b7df6ebf569b1aa46dd90 Mon Sep 17 00:00:00 2001 From: sapphi-red <49056869+sapphi-red@users.noreply.github.com> Date: Mon, 16 Jun 2025 13:55:49 +0900 Subject: [PATCH] test: fix flaky "deleted file should trigger dispose ..." test in hmr-ssr playground --- playground/hmr-ssr/__tests__/hmr-ssr.spec.ts | 27 ++++++++++++-------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/playground/hmr-ssr/__tests__/hmr-ssr.spec.ts b/playground/hmr-ssr/__tests__/hmr-ssr.spec.ts index b3654d6ebdc29a..59ab99c685981b 100644 --- a/playground/hmr-ssr/__tests__/hmr-ssr.spec.ts +++ b/playground/hmr-ssr/__tests__/hmr-ssr.spec.ts @@ -824,22 +824,29 @@ if (!isBuild) { const parentFile = 'file-delete-restore/parent.js' const childFile = 'file-delete-restore/child.js' + const originalChildFileCode = readFile(childFile) - // delete the file - editFile(parentFile, (code) => - code.replace( - "export { value as childValue } from './child'", - "export const childValue = 'not-child'", - ), + await untilConsoleLogAfter( + () => { + // delete the file + editFile(parentFile, (code) => + code.replace( + "export { value as childValue } from './child'", + "export const childValue = 'not-child'", + ), + ) + removeFile(childFile) + }, + [ + 'file-delete-restore/child.js is disposed', + 'file-delete-restore/child.js is pruned', + ], + false, ) - const originalChildFileCode = readFile(childFile) - removeFile(childFile) await expect .poll(() => hmr('.file-delete-restore')) .toMatch('parent:not-child') - expect(clientLogs).to.include('file-delete-restore/child.js is disposed') - expect(clientLogs).to.include('file-delete-restore/child.js is pruned') // restore the file addFile(childFile, originalChildFileCode)