jest-react-profiler

Jest helpers for working with the React Profiler API.

  • 所有者: bvaughn/jest-react-profiler
  • 平台:
  • 许可证:
  • 分类:
  • 主题:
  • 喜欢:
    0
      比较:

Github星跟踪图

jest-react-profiler

Jest helpers for working with the React Profiler API.

Installation

yarn add jest-react-profiler -D

Example usage

// Requiring this package will automatically register its custom matchers.
const { withProfiler } = require("jest-react-profiler");

function Greeting({ name }) {
  return <div>Hello, {name}</div>;
}

// Decorate a React component with a test Profiler:
const GreetingWithProfiler = withProfiler(Greeting);

// Next render it like normal:
render(
  <GreetingWithProfiler name="Brian" />,
  document.createElement("div")
);

// Now you can specify an expected number of commits:
expect(GreetingWithProfiler).toHaveCommittedTimes(1);

// Or use a Jest snapshot to track the value:
expect(GreetingWithProfiler).toMatchNumCommits();

API

toHaveCommittedTimes(number)

Verifies that the test profiler component committed a specific number of times since the last time the matcher was called.

This matcher resets the commit count between calls to simplify large test cases.

toMatchNumCommits()

Uses Jest snapshots to verify that a test profiler component committed the same number of times as when it was last run.

This matcher verifies that at least once commit has occurred in order to avoid false positives when used with a renderer that does not have profiling enabled.

This matcher resets the commit count between calls to simplify large test cases.

主要指标

概览
名称与所有者bvaughn/jest-react-profiler
主编程语言JavaScript
编程语言JavaScript (语言数: 1)
平台
许可证
所有者活动
创建于2018-12-17 18:34:39
推送于2018-12-20 17:50:31
最后一次提交2018-12-20 09:50:25
发布数0
用户参与
星数277
关注者数3
派生数4
提交数11
已启用问题?
问题数3
打开的问题数1
拉请求数2
打开的拉请求数0
关闭的拉请求数0
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?