Skip to content

Commit ed066f9

Browse files
authored
test: fix flaky "deleted file should trigger dispose ..." test in hmr-ssr playground (vitejs#20213)
1 parent 6994d17 commit ed066f9

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

playground/hmr-ssr/__tests__/hmr-ssr.spec.ts

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -824,22 +824,29 @@ if (!isBuild) {
824824

825825
const parentFile = 'file-delete-restore/parent.js'
826826
const childFile = 'file-delete-restore/child.js'
827+
const originalChildFileCode = readFile(childFile)
827828

828-
// delete the file
829-
editFile(parentFile, (code) =>
830-
code.replace(
831-
"export { value as childValue } from './child'",
832-
"export const childValue = 'not-child'",
833-
),
829+
await untilConsoleLogAfter(
830+
() => {
831+
// delete the file
832+
editFile(parentFile, (code) =>
833+
code.replace(
834+
"export { value as childValue } from './child'",
835+
"export const childValue = 'not-child'",
836+
),
837+
)
838+
removeFile(childFile)
839+
},
840+
[
841+
'file-delete-restore/child.js is disposed',
842+
'file-delete-restore/child.js is pruned',
843+
],
844+
false,
834845
)
835-
const originalChildFileCode = readFile(childFile)
836-
removeFile(childFile)
837846

838847
await expect
839848
.poll(() => hmr('.file-delete-restore'))
840849
.toMatch('parent:not-child')
841-
expect(clientLogs).to.include('file-delete-restore/child.js is disposed')
842-
expect(clientLogs).to.include('file-delete-restore/child.js is pruned')
843850

844851
// restore the file
845852
addFile(childFile, originalChildFileCode)

0 commit comments

Comments
 (0)