[Vuejs]-Vue Test utils, Testing scoped slot logic within parent context

0👍

The solution in my instance was to stub every other component bar the VTable component with the scoped slots.

const wrapper = mount(
          index,
          {
            localVue,
            mocks,
            store: new Vuex.Store(store),
            stubs: {
              FooComponent: { template: '<div class="FooComponent"></div>' },
              BarComponent: true,
              ...
            }
          })

This approach carries the caveat that tests could become brittle if the component that wasn’t stubbed is less generic (that in itself might be an indicator that the component in question requires refactoring)

Leave a comment