国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Vue-Test-Utils ? Vitest? ??? Vue-Router ?????
P粉190883225
P粉190883225 2023-08-25 09:26:52
0
1
843
<p>Vue-Router? Vitest? ???? ??? ????? ?? ????. </p> <p>?? ?? ?? ??? ?????? ??? ??? ???? ?????? ?????. Vue-Test-Utils? ?? ??? ???? ?? ?? ??? ?????. ??? Jest? ???? ????? ??????. </p> <p>?? vue-router? ???? ??? ?????? vue-router? ???? ?? ? ??? ?????. </p> <p> ????? ?? ????? ?? ??? ??? ?? ?? ?? ??? ???????. </p> <h3>Home.vue</h3> <pre class="brush:php;toolbar:false;"><???? ?? lang="ts"> "vue"?? {onMounted}? ?????;; "vue-router"?? {useRoute}? ?????;; const ?? = useRoute() onMounted(() => { console.log(route.query) }) </????> <???> <div>?</div> </???></pre> <h3>首頁(yè).spec.ts</h3> <pre class="brush:php;toolbar:false;">"vitest"?? {expect, it, vi}? ?????;; "@vue/test-utils"?? {mount}? ?????;; "../src/comComponents/Home.vue"?? ?? ?????. it('? ???', async () => { const ?? = ???(?) ??(??.??()).toBeTruthy() })</pre> <h3>vite.config.ts</h3> <pre class="brush:php;toolbar:false;">/// <?? ??="vitest" /> 'vite'?? { ?? ?? } ???? '@vitejs/plugin-vue'?? vue ???? // https://vitejs.dev/config/ ?? ?? ?? ????({ ????: [vue()], ??: { ??: 'jsdom', ??: ['./test/**/*.spec.ts'], ??: ['node_modules', 'dist'], ?? : ?? } })</pre> <h3>?? ????錯(cuò)誤消息如下:..</h3> <h3>?? ???? ??</h3> <p>我嘗試image下?這樣模擬 vue-router</p> <pre class="brush:php;toolbar:false;">vi.mock('vue-router', () => ({ useRoute: vi.fn(), }))</pre> <p>或者只是</p> <pre class="brush:php;toolbar:false;">vi.mock('vue-router')</pre> <h4>這是我的最終 Home.spec.ts 文件</h4> <pre class="brush:php;toolbar:false;">"vitest"?? {expect, it, vi}? ?????;; "@vue/test-utils"?? {mount}? ?????. "../src/comComponents/Home.vue"?? ?? ?????. vi.mock('vue-???') it('? ???', async () => { const ?? = ???(?, { ???: { ??: ["???-??", "???-?"] } }) ??(??.??()).toBeTruthy() })</pre></p>
P粉190883225
P粉190883225

?? ??(1)
P粉294954447

??, Home.vue 中看到 router-linkrouter-view:

?? ???? ????. ????

??? Home.spec.ts? ??? ??? ???.

????

? ?? ??/??:

  • ??? ???? ??? ???? ??
  • ?? ?? ????? ?? ??? ????? ?? ?? ??
  • ???? ? ?????? ?? .spyOn().mockImplementation...()? ?????
  • AAA [??, ??, ??] ?? GWT [???, ??, ??]? ?? ???/???? ??? ???? ???? ?????. ? ? ?? ???? ?? ??? ???? ???, ??? ?? ??? ???? ? ??? ???
  • .toHaveBeenCalled...()? ???? ?????? ???? ????? ?????
  • mount() 函數(shù)中的存根應(yīng)與模板中使用的組件相關(guān)(因此,如果您不使用 ???? ???? ? ???)

??? ??? ????. ??!