Unknown custom element: - did you register the component correctly? error on with <nuxt /> component in default.vue Jest Unknown custom element: - did you register the component correctly? error on with <nuxt /> component in default.vue Jest vue.js vue.js

Unknown custom element: - did you register the component correctly? error on with <nuxt /> component in default.vue Jest


I figured out how to get past that error. I had to just stub it out of the wrapper. You don't have to import Nuxt, just string 'nuxt' will replace it as a stubbed element in the wrapper:

describe('DefaultLayout', () => {  let wrapper;  afterEach(() => {    wrapper.destroy();  });  /** mount **/  test('is a Vue instance', () => {    wrapper = mount(DefaultLayout, {      localVue,      stubs: ['nuxt'],    });    expect(wrapper.isVueInstance()).toBeTruthy();  }); /** shallowMount **/ test('is a Vue instance', () => {    wrapper = shallowMount(DefaultLayout, {       localVue,       stubs: ['nuxt', 'top-nav', 'footer'],    });    expect(wrapper.isVueInstance()).toBeTruthy();    // expect(wrapper.html()).toBe('<div>'); => this is to debug see below for output  });});//DEBUG"<div><top-nav-stub class=\"\"></top-nav-stub> <main><nuxt-stub></nuxt-stub> . </main> <footer-stub></footer-stub></div>"