Ошибка при запуске тестового vue с конфигурацией MSAL

У меня есть приложение vue с конфигурацией MSAL Azure. Мое приложение работает хорошо и без каких-либо проблем. Но когда я создаю свой первый тест, он возвращает эту ошибку:

      src/msalConfiguration.ts:8:1 - error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher.

    8 await msalInstance.initialize();

Моя конфигурация msalConfiguration такая:

      import { PublicClientApplication } from "@azure/msal-browser";
import AzureService from "./services/azure.service";

const azureService = new AzureService();
const msalInstance = new PublicClientApplication(
  azureService.getMsalConfig().value
);
await msalInstance.initialize();

export default msalInstance;

И я изменил tsconfig.js, и у меня есть это: «target»: «es2017», «module»: «esnext»,

Вот и у меня то же самое, что говорит ошибка. Я схожу с ума, потому что не могу продолжать тесты и понятия не имею, как их решить.

Мой тест такой:

      import { mount } from "@vue/test-utils";
import DashboardView from "@/views/dashboard/DashboardView.vue";
import InfoCard from "@/components/cards/InfoCard.vue";
import { routes } from "@/constants/routes";
import { Row, Col, Card, Divider } from "ant-design-vue";
import { createI18n } from "vue-i18n";
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
import { createRouter, createWebHashHistory } from "vue-router";
import msalInstance from "@/msalConfiguration";

const fakeTranslations = {
  en: {
    models: "Models",
    experiments: "Experiments",
    dashboard_page: {
      more_info: "More info",
      execution_mode: "Execution mode",
      model_serving: "Model serving",
    },
  },
};

window.matchMedia = jest.fn().mockImplementation((query) => {
  return {
    matches: true,
    media: query,
    onchange: null,
    addListener: jest.fn(),
    removeListener: jest.fn(),
  };
});

const router = createRouter({
  history: createWebHashHistory(),
  routes,
});

describe("DashboardView.vue", () => {
  it("renders the component", async () => {
    const i18n = createI18n({
      locale: "en",
      messages: fakeTranslations,
    });
    const wrapper = mount(DashboardView, {
      global: {
        plugins: [i18n, router],
        components: {
          "a-row": Row,
          "a-divider": Divider,
          "a-col": Col,
          "a-card": Card,
          "info-card": InfoCard,
          "font-awesome-icon": FontAwesomeIcon,
          "router-link": {
            render: () => {},
          },
          msalInstance: msalInstance,
        },
      },
    });

    expect(wrapper.exists()).toBe(true);
  });
});

Я пробовал разные альтернативы, например, создать макет msal, импортировать msal в компоненты оболочки... но не могу найти решение...

0 ответов

Другие вопросы по тегам