我在使用
我在github上发布了我问题的完整代码,但这里是测试代码的快照:
react-testing-library
测试React.Suspense
时遇到了一个奇怪的错误。这个错误只是说“不支持”,但没有给出任何关于问题的实质性见解。我按照肯特·道德在Youtube上的示例进行操作。我在github上发布了我问题的完整代码,但这里是测试代码的快照:
import React from "react";
import { render, waitForElement, cleanup } from "react-testing-library";
import MyOtherPackageThing from "my-package/lib/my-thing";
import LazyThing from "../src/index";
afterEach(cleanup);
test("it works", async () => {
const { getByText, debug } = render(<MyOtherPackageThing />);
await waitForElement(() => getByText("my thing"));
expect(getByText("my thing"));
});
describe("these fail with 'Not Supported'", () => {
test("it lazy loads a local component", async () => {
const LazyLocalThing = React.lazy(() => import("../src/LocalThing"));
const { getByText, debug } = render(
<React.Suspense fallback="Loading...">
<LazyLocalThing />
</React.Suspense>
);
debug();
await waitForElement(() => getByText("my local thing"));
debug();
expect(getByText("my local thing"));
});
test("it says not supported, like wtf", async () => {
const { getByText, debug } = render(<LazyThing />);
debug();
await waitForElement(() => getByText("my thing"));
debug();
expect(getByText("my thing"));
});
});
my-consumer-pkg
中尝试运行yarn jest
时,出现了一些错误,我可以看到一些很长的日志。也许你应该在那个测试包中开一个issue,因为在这里找到帮助会很困难,这是一个高度专业化的问题。 - zisherun.sh
中,所以您设置它时不应该遇到任何问题。 - Benrun.sh
文件。 - zishe