Skip to content

Not able to get working with Vite #1046

@doutatsu

Description

@doutatsu

I am having trouble getting the tests to work with Vite, specifically due to the import object that is provided. One example is loading in global components using Vue Test Utils config:

hitting an issue with globEager when trying to provide plugins to config

Here my plugin:

export default {
  install: (app, _options) => {
    const components = import.meta.globEager('../components/base_components/*.vue');

    Object.entries(components).forEach(([path, definition]) => {
      const componentName = path.split('/').pop().replace(/\.\w+$/, '');
      app.component(componentName, definition.default);
    });
  },
};

I am trying to pass this plugin in my setup script for Jest using Vue Test Utils:

import { config } from '@vue/test-utils';
import globalComponents from '@/plugins/globalComponents';

config.global.plugins = [globalComponents];

But I get an error process.globEager is not a function

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions