

GitHub - bvaughn/jest-react-profiler: Jest helpers for working with the React Pr...
source link: https://github.com/bvaughn/jest-react-profiler
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

README.md
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(Example).toHaveCommittedTimes(1); // Or use a Jest snapshot to track the value: expect(Example).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.
Recommend
-
50
Try it out by signing in with your Google, Github, or Twitter accounts at personal-logger.now.sh. Local Installation This application was built with
-
54
README.md Codability
-
40
README.md react-window React components for efficiently rendering large lists and tabular data
-
60
README.md react-flame-graph React components for efficiently rendering large lists and tabular data
-
50
在使用 React Navigation 的项目中,想要集成 redux 就必须要引入 react-navigation-redux-helpers
-
56
README.md Utility functions shared by react-highlight-words and
-
43
README.md This is an experimental rewrite of the React DevTools extension (see github.com/...
-
15
Setting up Jest unit tests in a React + Typescript project Nov 9, 2020 • Jason Walton Here’s what I do when I want to set up a Jest on a React project. First, we need to install some dependencies:
-
18
利用 Jest 为 React 组件编写单元测试loveky前端小学生 https://loveky.github.io本文首发...
-
7
Many of us use profiler...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK