unplugin / unplugin-vue-components

📲 On-demand components auto importing for Vue
https://www.npmjs.com/package/unplugin-vue-components
MIT License
3.75k stars 349 forks source link

How to work with vue-jest? #431

Open ErikCH opened 2 years ago

ErikCH commented 2 years ago

I have a vue 3 project that uses vue-jest. When I run the tests, I get an error that all the components are missing that are being auto-imported by unplugin.

I found a work around adding in a global parameter with all the components. (components is being imported from another object)

describe('Authenticator', () => {
  it('Authenticator Exists', () => {
    const wrapper = render(Authenticator, {
      global: {
        components,
      },
    });

    expect(wrapper).toBeTruthy();
  });

You can see this working here.

Is there an easier way of getting this working? Right now I cannot move to vitest.

JJBocanegra commented 2 years ago

But this will need you to keep the list of components updated in that file, making it more difficult to maintain.

AndrewBogdanovTSS commented 1 year ago

That's why he said it's not ideal solution