【发布时间】:2020-06-22 09:06:55
【问题描述】:
我正在使用带有 Typescript 的 NextJS。我正在尝试使用 Jest+Enzyme 测试我的应用程序。我收到以下错误消息:
** 测试套件无法运行
TypeScript diagnostics (customize using `[jest-config].globals.ts-jest.diagnostics` option):
__tests__/Quest.spec.tsx:15:27 - error TS2605:
JSX 元素类型 'Quest' 不是 JSX 的构造函数 元素。 “Quest”类型缺少“ElementClass”类型的以下属性:context、setState、forceUpdate、props、refs
**
我已经添加了我的测试文件的代码和我编写测试的代码:
Quest.spec.tsx(测试文件)
import * as React from 'react';
import {mount} from 'enzyme';
import Quest from '../Quest';
describe('Quest page', () => {
it('should render without throwing an error', function () {
const wrapper = mount(<Quest/>);
})
})
【问题讨论】:
标签: typescript types jestjs enzyme next.js