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
Change animtest\test\unit\specs\HelloWorld.spec.js to
import{shallow,createLocalVue}from'@vue/test-utils'importHelloWorldfrom'@/components/HelloWorld'describe('HelloWorld.vue',()=>{letlocalVuebeforeEach(()=>{localVue=createLocalVue()})describe('Menu',()=>{it('Menu visability should toggle when clicked',()=>{constwrapper=shallow(HelloWorld,{ localVue })// Set up/Verify: hiddenwrapper.vm.menuVisibility=falseexpect(wrapper.vm.menuVisibility).toBeFalsy()expect(wrapper.find({ref: 'testMenuContents'}).element.style.display).toEqual('none')// Toggle: shownwrapper.find({ref: 'testMenuToggle'}).trigger('click')expect(wrapper.vm.menuVisibility).toBeTruthy()expect(wrapper.find({ref: 'testMenuContents'}).element.style.display).toEqual('')// Toggle: hiddenwrapper.find({ref: 'testMenuToggle'}).trigger('click')console.log(wrapper.find({ref: 'testMenuContents'}).element.classList)expect(wrapper.vm.menuVisibility).toBeFalsy()expect(wrapper.find({ref: 'testMenuContents'}).element.style.display).toEqual('none')})})})
npm run unit (1 of 1 ran/failed)
What is expected?
pass
What is actually happening?
console.log test\unit\specs\HelloWorld.spec.js:30
DOMTokenList {
'0': 'menu-contents',
'1': 'v-leave',
'2': 'v-leave-active'
}
FAIL test\unit\specs\HelloWorld.spec.js
HelloWorld.vue
Menu
× Menu visability should toggle when clicked (45ms)
● HelloWorld.vue › Menu › Menu visability should toggle when clicked
Expected value to equal:
"none"
Received:
""
32 | .toBeFalsy()
33 | expect(wrapper.find({ ref: 'testMenuContents' }).element.style.display)
> 34 | .toEqual('none')
35 | })
36 | })
37 | })
at Object.<anonymous> (test/unit/specs/HelloWorld.spec.js:34:7)
This is to test that toggling the menu works.
Verify the menu is hidden
First button click - Toggles menu to be shown
Second button click - Toggles menu to be hidden again
It fails on the second button click. It should be reporting that the style="display: none;", but that style has not been applied yet because the Vue <transition> has not finished. This can be seen from the classList still having v-leave and v-leave-active applied.
The text was updated successfully, but these errors were encountered:
Version
1.0.0-beta.11
Reproduction link
https://codesandbox.io/s/k31v0lw3o
Steps to reproduce
npm install -g vue-cli
npm init webpack animtest
(hit enter for every question)cd animtest
npm install --save-dev @vue/test-utils
npm run unit
(1 of 1 tests ran/passed)animtest\src\components\HelloWorld.vue
toanimtest\test\unit\specs\HelloWorld.spec.js
tonpm run unit
(1 of 1 ran/failed)What is expected?
pass
What is actually happening?
This is to test that toggling the menu works.
It fails on the second button click. It should be reporting that the
style="display: none;"
, but that style has not been applied yet because the Vue<transition>
has not finished. This can be seen from the classList still havingv-leave
andv-leave-active
applied.The text was updated successfully, but these errors were encountered: