Skip to content

Commit 18b05e4

Browse files
author
shangweiwei365
committed
test: apiWatch vuejs#12967
1 parent 51eabb0 commit 18b05e4

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
"build:types": "rimraf temp && tsc --declaration --emitDeclarationOnly --outDir temp && api-extractor run && api-extractor run -c packages/compiler-sfc/api-extractor.json",
4646
"test": "npm run ts-check && npm run test:types && npm run test:unit && npm run test:e2e && npm run test:ssr && npm run test:sfc",
4747
"test:unit": "vitest run test/unit",
48+
"test:watch": "vitest run test/unit/features/v3/apiWatch.spec.ts",
4849
"test:ssr": "npm run build:ssr && vitest run server-renderer",
4950
"test:sfc": "vitest run compiler-sfc",
5051
"test:e2e": "npm run build -- full-prod,server-renderer-basic && vitest run test/e2e",

test/unit/features/v3/apiWatch.spec.ts

+11
Original file line numberDiff line numberDiff line change
@@ -1200,4 +1200,15 @@ describe('api: watch', () => {
12001200
expect(parentSpy).toHaveBeenCalledTimes(1)
12011201
expect(childSpy).toHaveBeenCalledTimes(1)
12021202
})
1203+
1204+
// #12967
1205+
test('trigger when adding new property with Vue.set', async () => {
1206+
const spy = vi.fn()
1207+
const r = reactive({ exist: 5 })
1208+
watch(r, spy, { deep: true })
1209+
set(r, 'add', 1)
1210+
1211+
await nextTick()
1212+
expect(spy).toHaveBeenCalledTimes(1)
1213+
})
12031214
})

0 commit comments

Comments
 (0)