We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 517c2b8 commit 223f180Copy full SHA for 223f180
packages/runtime-core/__tests__/apiWatch.spec.ts
@@ -77,6 +77,21 @@ describe('api: watch', () => {
77
expect(spy).toBeCalledWith([1], expect.anything(), expect.anything())
78
})
79
80
+ it('should not fire if watched getter result did not change', async () => {
81
+ const spy = jest.fn()
82
+ const n = ref(0)
83
+ watch(() => n.value % 2, spy)
84
+
85
+ n.value++
86
+ await nextTick()
87
+ expect(spy).toBeCalledTimes(1)
88
89
+ n.value += 2
90
91
+ // should not be called again because getter result did not change
92
93
+ })
94
95
it('watching single source: computed ref', async () => {
96
const count = ref(0)
97
const plus = computed(() => count.value + 1)
0 commit comments