Skip to content

Commit

Permalink
test: add failed test for #498
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Jan 26, 2021
1 parent 5090cae commit f0605a8
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions test/v3/runtime-core/apiWatch.spec.ts
Expand Up @@ -531,4 +531,30 @@ describe('api: watch', () => {

expect(data2.value).toMatchObject([1])
})

// #498
it('watchEffect should not lead to infinite loop when accessing', async () => {
let dummy = 0

const state = reactive({
data: [],
watchVar: 123,
})

watchEffect(() => {
// accessing
state.watchVar
// setting
state.data = []
dummy += 1
})

expect(dummy).toBe(1)

state.data = []

await nextTick()

expect(dummy).toBe(2)
})
})

0 comments on commit f0605a8

Please sign in to comment.