[Vuejs]-Why Bootstrap-Vue tables (b-table) are mounted as "b-table-stub" in unit testing in @vue/test-utils , not just b-table?

0👍

You used shallowMount() to mount your component "Foo".

Per vue-test-utils v2 docs shallowMount stubs child components so that you can focus on testing component Foo’s logic without the need to mount child components and their children. This makes testing Foo’s specific logic easier. Moreover, it makes the test more efficient since we are essentially building the DOM in memory and we can avoid unnecessarily rendering too much in memory by doing this.

If you need to test b-table, use mount(Foo) instead. Further, if you want to test b-table only and ignore other components you can stub other child components like so:

mount(Foo, {
  ...
  stubs: {
    childA: true,
    childB: true
  },
  ...
})

Leave a comment