Reactjs 弹出的Create react应用程序jest覆盖率报告不准确
我使用CreateReact应用程序创建一个应用程序,然后将其弹出。目前正在做我的测试套件,我想显示我的测试覆盖率,所以我在我的package.json下添加了“collectCoverage”:true。运行测试后,它不会显示测试覆盖率的百分比 有什么我需要做的吗 下面是Links.test.jsxReactjs 弹出的Create react应用程序jest覆盖率报告不准确,reactjs,jestjs,Reactjs,Jestjs,我使用CreateReact应用程序创建一个应用程序,然后将其弹出。目前正在做我的测试套件,我想显示我的测试覆盖率,所以我在我的package.json下添加了“collectCoverage”:true。运行测试后,它不会显示测试覆盖率的百分比 有什么我需要做的吗 下面是Links.test.jsx import React from "react"; import { shallow, mount } from "enzyme"; import Links from "./Links";
import React from "react";
import { shallow, mount } from "enzyme";
import Links from "./Links";
it("should show correct links", () => {
const wrapper = mount(<Links />);
expect(wrapper).toMatchSnapshot();
});
从“React”导入React;
从“酶”中导入{shall,mount};
从“/Links”导入链接;
它(“应该显示正确的链接”,()=>{
const wrapper=mount();
expect(wrapper.toMatchSnapshot();
});
下面是正在测试的链接组件
import React from "react";
const Links = () => {
return (
<div className="container mb-4 mt-4" id="Links">
<div className="h4 mb-3">OUR LINKS</div>
<div className="d-flex justify-content-between flex-wrap mw-90">
<a
href="https://site.ca/sites.aspx"
target="_blank"
className="buttonImage siteImage"
>
<div className="darkenBackground d-flex flex-column justify-content-center">
<div className="text-center h4">My Site</div>
</div>
</a>
<a href="#" target="_blank" className="buttonImage mapsImage">
<div className="darkenBackground d-flex flex-column justify-content-center">
<div className="text-center h4">Maps</div>
</div>
</a>
<a href="#" target="_blank" className="buttonImage loopImage">
<div className="darkenBackground d-flex flex-column justify-content-center">
<div className="text-center h4">Social</div>
</div>
</a>
<a href="#" target="_blank" className="buttonImage polcyImage">
<div className="darkenBackground d-flex flex-column justify-content-center">
<div className="text-center h4">
Acceptable Use <br /> and Security Policies
</div>
</div>
</a>
</div>
</div>
);
};
export default Links;
从“React”导入React;
常量链接=()=>{
返回(
我们的链接
);
};
导出默认链接;
您的测试是什么样子的?它现在只是一个快照,不被认为是测试覆盖率吗?是的,它应该。链接组件怎么样?还有一个很好的测量快照。链接组件非常基本。你知道@TomErikStøwer有什么问题吗?