Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return VueWrapper instance If element is binding Vue Plugin instance #1351

Closed
fcappi opened this issue Nov 13, 2019 · 2 comments
Closed

Return VueWrapper instance If element is binding Vue Plugin instance #1351

fcappi opened this issue Nov 13, 2019 · 2 comments

Comments

@fcappi
Copy link

fcappi commented Nov 13, 2019

What problem does this feature solve?

Currently, using VueComponent Selector works with plugin components (e.g. BootstrapVue), but the return from find() method is wrapped by Wrapper instead of VueWrapper.
We need the VueWrapper so we can access the Vue instance

What does the proposed API look like?

vCustomButton.ts

export default Vue.extend({
  template: `
  <div>
    <b-button>Button</b-button>
  </div>
  `
}); 

vCustomButton.spec.ts

import vCustomButton from 'vCustomButton'
import { BButton } from 'bootstrap-vue'


describe('vCustomButton', () => {
  let wrapper: Wrapper<any>;
  
  beforeEach(() => {
    wrapper = shallowMount(vCustomButton);
  })

  describe('Validation', () => {
    it('Test return from find()', () => {
      const bbuton = wrapper.find(BButton);

      // returns VueWrapper instead of Wrapper
      expect(bbuton).toBeInstanceOf(VueWrapper)
    })
  });
});
@dobromir-hristov
Copy link
Contributor

bbutton.vm should be what you are looking for, no?

@lmiller1990
Copy link
Member

This is intended behavior - the button component in VueBootstrap is a functional component. Those don't have Vue instances. See here: https://github.com/bootstrap-vue/bootstrap-vue/blob/d30c8b07840069a7891a7e0489910090698b38bc/src/components/button/button.js#L148

Another reason why we should drop find(Comp) - it's misleading and confusing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants