Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1e023dd

Browse files
authored
fix: make watcher test stable (#2482)
<!-- Thank you for contributing! --> ### Description close #2438 <!-- Please insert your description here and provide especially info about the "what" this PR is solving -->
1 parent f41d8ae commit 1e023dd

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

packages/rolldown/tests/watch/watch.test.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,12 @@ test.sequential('watch', async () => {
1616
plugins: [
1717
{
1818
watchChange(id, event) {
19-
watchChangeFn()
20-
expect(id).toBe(input)
21-
expect(event).toMatchObject({ event: 'update' })
19+
// The macos emit create event when the file is changed, not sure the reason,
20+
// so here only check the update event
21+
if (event.event === 'update') {
22+
watchChangeFn()
23+
expect(id).toBe(input)
24+
}
2225
},
2326
},
2427
{
@@ -82,9 +85,12 @@ test.sequential('watch event', async () => {
8285
watcher.on('close', closeFn)
8386
const changeFn = vi.fn()
8487
watcher.on('change', (id, event) => {
85-
changeFn()
86-
expect(id).toBe(input)
87-
expect(event.event).toBe('update')
88+
// The macos emit create event when the file is changed, not sure the reason,
89+
// so here only check the update event
90+
if (event.event === 'update') {
91+
changeFn()
92+
expect(id).toBe(input)
93+
}
8894
})
8995

9096
// edit file

0 commit comments

Comments
 (0)