问题描述
我试图用酶和笑话测试我的反应项目,当用 yarn test
运行我的项目时一切正常,但是当我尝试用脚本 yarn test --coverage
运行覆盖率报告并且所有测试都用酶已失效。
import '@testing-library/jest-dom/extend-expect';
import {configure} from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import 'jest-enzyme';
configure({adapter: new Adapter()});
这是我的测试。
it("should render Form",() => {
console.log(wrapper.debug());
expect(wrapper.exists(FormSignup)).toBe(true);
});
当我使用 yarn test
运行并且尝试记录 wrapper.debug()
Console.log src/pages/patient-auth/patient-auth.test.js:99
<div class="sc-iwaifL fibzQF"><div class="sc-cxNIbT dbZAGD">
<h3>Authorización de paciente</h3></div><div class="sc-lmgQde gQjQQD">
<form autoComplete="off" class="sc-fKgIGh fFDhjo">
<div class="sc-bCwgka cYnlCt"><div><h4>Nombre: test test test</h4>
<h4>Correo : test@test.com</h4></div></div><div class="sc-bCwgka cYnlCt">
<div class="sc-gtssRu cHOYTA"><input type="date" name="expiration_date" min="1980-01-01" max="2021-01-19" class="sc-dlnjPT lbPlE"/>
<label class="sc-hKFyIo htgnEd shrink">Fecha de expiración</label></div><div class="sc-kEqYlL jRpfDg"> <div class="sc-jSFkmK hwcRol"><span> Autorización</span></div><div class="sc-gKAblj fxkdfC"><input type="checkbox" name="auth" id="auth" class="sc-jrsJCI iFWYuj"/><label for="auth" class="sc-iCoHVE gpnzXF"><span data-yes="Si" data-no="No" class="sc-fujyUd bbprCb"></span><label class="sc-pNWxx fvvsLs"></label></label></div></div> </div><button type="submit" class="sc-bdnylx jqdcFs">"Actualizar Paciente"</button><div style="max-width:100%"><p style="font-size:10px">{"expiration_date":"","auth":null}</p>
</div>
</form>
</div>
<div class="sc-iJCRLp iZsMhV"></div></div>
测试是对的
当我使用 yarn test --coverage
运行并且尝试记录 wrapper.debug()
console.log src/pages/patient-auth/patient-auth.test.js:99
null
expect(received).toBe(expected) // Object.is equality
Expected: true
Received: false
103 |
104 | it("should render Form",() => {
> 105 | expect(wrapper.exists(FormSignup)).toBe(true);
| ^
106 | });
非常感谢
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)