首页 > 解决方案 > 弹出创建反应应用程序笑话覆盖率报告不准确

问题描述

我使用 create-react-app 创建了一个应用程序,然后我将其弹出。目前正在做我的测试套件,我想展示我的测试覆盖率,所以我在我的 package.json 下添加了“collectCoverage”:true。运行测试后,它没有显示我的测试覆盖率

在此处输入图像描述

有什么我需要做的吗?

这是 Links.test.jsx

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();
});

下面是正在测试的 Links 组件

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;

标签: reactjsjestjs

解决方案


推荐阅读