如何将脉轮的样式添加到柏树组件测试中

发布于 2025-02-08 03:58:07 字数 47 浏览 2 评论 0原文

据我了解,我可以将CSS文件导入柏树。但是,脉轮没有一个,我该怎么做?提前致谢。

From what I understand, I can import a css file into cypress. However, chakra-ui doesn't have one so how do i do it? Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

菊凝晚露 2025-02-15 03:58:07

cypress/unding/component.ts文件应该看起来像这样:

import "./commands";
import { mount } from "cypress/react18";
import { ChakraProvider } from "@chakra-ui/react";
import { theme } from "../../src/theme/theme";
import { createElement } from "react";

declare global {
  namespace Cypress {
    interface Chainable {
      mount: typeof mount;
    }
  }
}

Cypress.Commands.add("mount", (component, options) => {
  const wrappedComponent = createElement(ChakraProvider, { theme }, component);

  return mount(wrappedComponent, options);
});

完整示例: https://github.com/kenikori/reeact-chakra-cypress

The cypress/support/component.ts file should look something like this:

import "./commands";
import { mount } from "cypress/react18";
import { ChakraProvider } from "@chakra-ui/react";
import { theme } from "../../src/theme/theme";
import { createElement } from "react";

declare global {
  namespace Cypress {
    interface Chainable {
      mount: typeof mount;
    }
  }
}

Cypress.Commands.add("mount", (component, options) => {
  const wrappedComponent = createElement(ChakraProvider, { theme }, component);

  return mount(wrappedComponent, options);
});

Full example: https://github.com/kenikori/react-chakra-cypress

仄言 2025-02-15 03:58:07

这样更新您的组件。

Cypress.Commands.add('mount', (jsx, options) =>
  mount(React.createElement(ThemeProvider, { theme }, jsx), options)
);

Update your component.ts like this:

Cypress.Commands.add('mount', (jsx, options) =>
  mount(React.createElement(ThemeProvider, { theme }, jsx), options)
);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文