我已经在打字稿中使用我的 React-app 进行了测试,使用 ts-jest 如下所示。
import * as React from "react";
import * as renderer from "react-test-renderer";
import { ChartTitle } from "Components/chart_title";
describe("Component: ChartTitle", () => {
it("will be rendered with no error", () => {
const chartTitle = "My Chart 1";
renderer.create(<ChartTitle title={chartTitle} />);
});
});
Run Code Online (Sandbox Code Playgroud)
它在我的本地环境中通过了,但在 CircleCI 中失败了。
FAIL __tests__/components/chart_title.tsx
? Test suite failed to run
TypeScript diagnostics (customize using `[jest-config].globals.ts-jest.diagnostics` option):
__tests__/components/chart_title.tsx:4:28 - error TS2307: Cannot find module 'Components/chart_title'.
4 import { ChartTitle } from "Components/chart_title"; …Run Code Online (Sandbox Code Playgroud)