Skip to content

Commit 7264b09

Browse files
committed
test: test dispose before prune
1 parent cc08a9c commit 7264b09

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

playground/hmr/__tests__/hmr.spec.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -999,11 +999,13 @@ if (!isBuild) {
999999

10001000
test('deleting import from non-self-accepting module can trigger prune event', async () => {
10011001
await page.goto(viteTestUrl)
1002-
await expect.poll(() => page.textContent('.prune')).toMatch('init')
1002+
await expect.poll(() => page.textContent('.prune')).toMatch('prune-init')
10031003
editFile('prune/dep1.js', (code) =>
10041004
code.replace(`import './dep2.js'`, `// import './dep2.js'`),
10051005
)
1006-
await expect.poll(() => page.textContent('.prune')).toMatch('dep2-pruned')
1006+
await expect
1007+
.poll(() => page.textContent('.prune'))
1008+
.toMatch('prune-init|dep2-disposed|dep2-pruned')
10071009
})
10081010

10091011
test('import.meta.hot?.accept', async () => {

playground/hmr/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,4 @@
4545
<img id="logo" />
4646
<img id="logo-no-inline" />
4747
<div class="circular"></div>
48-
<div class="prune">prune/init</div>
48+
<div class="prune">prune-init</div>

playground/hmr/prune/dep2.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
if (import.meta.hot) {
2+
import.meta.hot.dispose(() => {
3+
document.querySelector('.prune').textContent += '|dep2-disposed'
4+
})
25
import.meta.hot.prune(() => {
3-
document.querySelector('.prune').textContent = 'prune/dep2-pruned'
6+
document.querySelector('.prune').textContent += '|dep2-pruned'
47
})
58
}

0 commit comments

Comments
 (0)