A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/vuejs/vue-next/issues/3068 below:

Watch listens to computed and should not be triggered by ref in computed · Issue #3068 · vuejs/core · GitHub

Version

3.0.5

Reproduction link

https://jsfiddle.net/twgh75x4/4/

Steps to reproduce

test case

  it('watching multiple sources: computed', async () => {
    let count = 0
    const _ref = ref('1')
    const _computed = computed(() => !!_ref.value)
    
    watch([_computed], () => {
      count.value++
    })
    watch(_computed, () => {
      count.value++  
    })
    
    // When the _ref value changes
    // in factthe _computed value remains the same
    // watch should not be triggered
    _ref.value = '2' 
    // count.value is 1, Is not the expected 0
    await nextTick()

    _ref.value = '3'
    // count.value is 2, Is not the expected 0
    await nextTick()
    expect(count).toBe(0)
  })
What is expected?

experct(count).toBe(0)

What is actually happening?

experct(count).toBe(2)


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4