【问题标题】:undefined: Error: Global config has not been defined yet - Playwright component test未定义:错误:尚未定义全局配置 - Playwright 组件测试
【发布时间】:2022-11-11 09:30:28
【问题描述】:

我正在尝试在网格上实现 Playwrights 组件测试。这是组件测试:

import { test, expect } from "@playwright/experimental-ct-react";
import InvoicesTable from "../../../../src/shared/inventory/InvoicesPage/InvoicesTable/InvoicesTable";
import mockComponentInvoices from "../../../../src/shared/inventory/mocks/componentMockInvoices";

test.describe("Invoice Table Renders Component Tests: ", () => {

    test("component renders", async ({ mount }) => {
        const component = await mount(
        <InvoicesTable invoices={ mockComponentInvoices }/>);

        await expect(component).toContainText('email');
    });
});

这是错误:

未定义:错误:尚未定义全局配置。 在 GlobalConfig.get (http://localhost:3100/assets/index.b07305db.js:105442:13)

这是一个 React 应用程序。

我正在运行一个组件测试,但我创建的新组件在执行时显示该错误消息。

任何帮助,将不胜感激。

【问题讨论】:

    标签: javascript reactjs playwright


    【解决方案1】:

    我相信这个问题是由导入 mockComponentInvoices 引起的

    这是 Playwright 组件测试的known limitation:

    你只能从你的测试文件中导入你的组件

    不幸的是,我仍然没有弄清楚他们对如何解决这个问题的含义。

    【讨论】:

      猜你喜欢
      • 2013-07-03
      • 1970-01-01
      • 2014-10-27
      • 2018-05-03
      • 1970-01-01
      • 2019-11-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多