I'm testing my vuejs component and a very strange issue occurred.
Here is my test
import { mount } from 'avoriaz';
let wrapper = mount(MyComponent, { globals: {$route},});
it('the click changes the value of shown', () => {
// This passes
expect(wrapper.vm.shown).to.equal(false);
// the click on this element will turn shown value into true
wrapper.first('#my_link').trigger('click');
// the value of shown is indeed true now
console.log(wrapper.vm.shown); // LOG LOG: true
expect(wrapper.vm.shown).to.equal(true); // expected undefined to equal true
});
What's happening and why shown
is undefined
when passed as argument to expect
method and is boolean when displayed through console.log
?