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 clone the repo and run npm i then npm run test, however it's not display as expected:
07 12 2021 16:16:19.134:INFO [karma]: Karma v2.0.5 server started at http://0.0.0.0:9876/
07 12 2021 16:16:19.136:INFO [launcher]: Launching browser Chrome with unlimited concurrency
07 12 2021 16:16:19.154:INFO [launcher]: Starting browser Chrome
07 12 2021 16:16:19.996:INFO [Chrome 96.0.4664 (Windows 10 0.0.0)]: Connected on socket F4fijiOGcGpfsAE_AAAA with id 99121632
Counter.vue
× increments count when button is clicked
AssertionError: expected '0\n Increment' to include '1'
at Context.eval (webpack-internal:///32:15:86)
Chrome 96.0.4664 (Windows 10 0.0.0): Executed 1 of 1 (1 FAILED) ERROR (0.022 secs / 0.012 secs)
=============================== Coverage summary ===============================
Statements : 100% ( 2/2 )
Branches : 100% ( 0/0 )
Functions : 100% ( 0/0 )
Lines : 100% ( 2/2 )
================================================================================
After some messing around, I found the original code is buggy.
The problematic source code is:
describe("Counter.vue",()=>{it("increments count when button is clicked",()=>{constwrapper=shallowMount(Counter);wrapper.find("button").trigger("click");expect(wrapper.find("div").text()).contains("1");});});
I change it as follow, which works perfectly:
describe("Counter.vue",()=>{it("increments count when button is clicked",()=>{constwrapper=shallowMount(Counter);wrapper.find("button").trigger("click");wrapper.vm.$nextTick().then(()=>{expect(wrapper.find("div").text()).contains("1");});});});
Seems need writing expect in an async way instead.
The text was updated successfully, but these errors were encountered:
I clone the repo and run
npm i
thennpm run test
, however it's not display as expected:After some messing around, I found the original code is buggy.
The problematic source code is:
I change it as follow, which works perfectly:
Seems need writing
expect
in an async way instead.The text was updated successfully, but these errors were encountered: