【发布时间】:2020-10-22 08:12:10
【问题描述】:
我有一个组件
app.tsx
import React, { useState } from "react";
const TestCom = () => {
return(
<>
<div className="head">hey there</div>
<select name="xyz" id="uni">
<option value="abc">abc</option>
</select>
</>
)
}
export default TestCom
我正在用玩笑和酶来测试它
app.test.tsx
import TestCom from "./foo";
import { shallow } from 'enzyme';
import React from "react";
test("basic test", () => {
const app= shallow(<TestCom />)
expect(app.find('div.head')).to.have.lengthOf(1);
});
每当我使用 .to 时,它的抛出错误
Property 'to' does not exist on type 'JestMatchersShape<Matchers<void, ShallowWrapper<HTMLAttributes,
any, Component<{}, {}, any>>>, Matchers<Promise<void>, ShallowWrapper<HTMLAttributes, any,
Component<...>>>>'.ts(2339)
我已尝试进行故障排除,但无法找到解决方法
【问题讨论】:
标签: reactjs typescript jestjs enzyme