You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wrote this test, which runs when removing the watcher, but fails when it's present.
import{computed,Ref,ref}from'@vue/reactivity'import{watch}from'@vue-reactivity/watch'import{fn}from'jest-mock'import{any}from'jest-mock-extended'it('should watch inside an array ref when an item is removed',()=>{constrowsData: {p1: Ref<number>,p2: Ref<number>,p3: Ref<number>}[]=[]for(leti=0;i<5;i++){constp1=ref(1)constp2=ref(2)constp3=ref(3)rowsData.push({ p1, p2, p3 })}constrows=ref(rowsData)constc=computed(()=>{letsum=0for(constrowofrows.value){sum+=row.p1sum+=row.p2sum+=row.p3}returnsum})constwatchFunction=fn()watch(c,watchFunction)// When removing this line, the test is OK.expect(c.value).toBe(30)rows.value.splice(1,1)expect(c.value).toBe(24)expect(watchFunction).toBeCalledWith(24,30,any())// When removing this line, the test is OK.})
Cannot read properties of undefined (reading 'p1')
TypeError: Cannot read properties of undefined (reading 'p1')
at ReactiveEffect.fn (/home/toilal/projects/carbon-saver/platform.carbon-saver/packages/computation-core.carbon-saver/__tests__/reactivity.spec.ts:20:18)
at ReactiveEffect.run (/home/toilal/projects/carbon-saver/platform.carbon-saver/node_modules/@vue/reactivity/dist/reactivity.cjs.js:189:25)
at ComputedRefImpl.get value [as value] (/home/toilal/projects/carbon-saver/platform.carbon-saver/node_modules/@vue/reactivity/dist/reactivity.cjs.js:1136:39)
at ReactiveEffect.getter [as fn] (/home/toilal/projects/carbon-saver/platform.carbon-saver/node_modules/@vue-reactivity/watch/dist/index.js:83:27)
at ReactiveEffect.run (/home/toilal/projects/carbon-saver/platform.carbon-saver/node_modules/@vue/reactivity/dist/reactivity.cjs.js:189:25)
at job (/home/toilal/projects/carbon-saver/platform.carbon-saver/node_modules/@vue-reactivity/watch/dist/index.js:129:31)
at ReactiveEffect.scheduler (/home/toilal/projects/carbon-saver/platform.carbon-saver/node_modules/@vue-reactivity/watch/dist/index.js:150:7)
at triggerEffect (/home/toilal/projects/carbon-saver/platform.carbon-saver/node_modules/@vue/reactivity/dist/reactivity.cjs.js:393:20)
at triggerEffects (/home/toilal/projects/carbon-saver/platform.carbon-saver/node_modules/@vue/reactivity/dist/reactivity.cjs.js:383:13)
at triggerRefValue (/home/toilal/projects/carbon-saver/platform.carbon-saver/node_modules/@vue/reactivity/dist/reactivity.cjs.js:995:13)
The text was updated successfully, but these errors were encountered:
I wrote this test, which runs when removing the watcher, but fails when it's present.
The text was updated successfully, but these errors were encountered: