react-render-detective 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/chunk-H5RG2EPP.cjs +75 -0
- package/dist/chunk-H5RG2EPP.cjs.map +1 -0
- package/dist/chunk-LILK23YH.js +71 -0
- package/dist/chunk-LILK23YH.js.map +1 -0
- package/dist/index.cjs +314 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +160 -2
- package/dist/index.d.ts +160 -2
- package/dist/index.js +303 -2
- package/dist/index.js.map +1 -1
- package/dist/testing.cjs +20 -0
- package/dist/testing.cjs.map +1 -0
- package/dist/testing.d.cts +62 -0
- package/dist/testing.d.ts +62 -0
- package/dist/testing.js +3 -0
- package/dist/testing.js.map +1 -0
- package/package.json +6 -1
package/dist/testing.cjs
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkH5RG2EPP_cjs = require('./chunk-H5RG2EPP.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "assertNoRenderRegressions", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () { return chunkH5RG2EPP_cjs.assertNoRenderRegressions; }
|
|
10
|
+
});
|
|
11
|
+
Object.defineProperty(exports, "compareProfiles", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () { return chunkH5RG2EPP_cjs.compareProfiles; }
|
|
14
|
+
});
|
|
15
|
+
Object.defineProperty(exports, "profileFromEvents", {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () { return chunkH5RG2EPP_cjs.profileFromEvents; }
|
|
18
|
+
});
|
|
19
|
+
//# sourceMappingURL=testing.cjs.map
|
|
20
|
+
//# sourceMappingURL=testing.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"testing.cjs"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { b as RenderEvent } from './types-gl13xwmN.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Render-regression testing.
|
|
5
|
+
*
|
|
6
|
+
* Fixing a render problem once is easy; keeping it fixed is the hard part. This
|
|
7
|
+
* turns render behaviour into something a pull request can fail on: record a
|
|
8
|
+
* profile for a scripted interaction, commit it, and compare on every run.
|
|
9
|
+
*
|
|
10
|
+
* Deliberately assertion-library agnostic — it returns data and a message, and
|
|
11
|
+
* your test framework decides what to do with it.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
interface ComponentProfile {
|
|
15
|
+
renders: number;
|
|
16
|
+
remounts: number;
|
|
17
|
+
avoidableRenders: number;
|
|
18
|
+
}
|
|
19
|
+
interface RenderProfile {
|
|
20
|
+
/** Free-form label, e.g. "search: type one character". */
|
|
21
|
+
scenario: string;
|
|
22
|
+
components: Record<string, ComponentProfile>;
|
|
23
|
+
}
|
|
24
|
+
interface RegressionOptions {
|
|
25
|
+
/**
|
|
26
|
+
* Allowed growth before a component counts as regressed, as a fraction.
|
|
27
|
+
* `0.2` tolerates a 20% increase. Defaults to 0 — exact.
|
|
28
|
+
*/
|
|
29
|
+
tolerance?: number;
|
|
30
|
+
/** Ignore components below this render count in the baseline. */
|
|
31
|
+
ignoreBelow?: number;
|
|
32
|
+
/** Component names to skip entirely. */
|
|
33
|
+
ignore?: string[];
|
|
34
|
+
/** Fail when a component is rendering *fewer* times too. Off by default. */
|
|
35
|
+
failOnImprovement?: boolean;
|
|
36
|
+
}
|
|
37
|
+
interface Regression {
|
|
38
|
+
component: string;
|
|
39
|
+
metric: "renders" | "remounts" | "avoidableRenders";
|
|
40
|
+
baseline: number;
|
|
41
|
+
current: number;
|
|
42
|
+
delta: number;
|
|
43
|
+
}
|
|
44
|
+
interface RegressionResult {
|
|
45
|
+
ok: boolean;
|
|
46
|
+
scenario: string;
|
|
47
|
+
regressions: Regression[];
|
|
48
|
+
improvements: Regression[];
|
|
49
|
+
/** Components present now but absent from the baseline. */
|
|
50
|
+
added: string[];
|
|
51
|
+
message: string;
|
|
52
|
+
}
|
|
53
|
+
/** Builds a profile from recorded events. Pass `getEvents()`. */
|
|
54
|
+
declare function profileFromEvents(scenario: string, events: RenderEvent[], remounts?: Record<string, number>): RenderProfile;
|
|
55
|
+
declare function compareProfiles(baseline: RenderProfile, current: RenderProfile, options?: RegressionOptions): RegressionResult;
|
|
56
|
+
/**
|
|
57
|
+
* Throws when the current profile is worse than the baseline. The one-liner for
|
|
58
|
+
* a test file; use `compareProfiles` when you want the data.
|
|
59
|
+
*/
|
|
60
|
+
declare function assertNoRenderRegressions(baseline: RenderProfile, current: RenderProfile, options?: RegressionOptions): void;
|
|
61
|
+
|
|
62
|
+
export { type ComponentProfile, type Regression, type RegressionOptions, type RegressionResult, type RenderProfile, assertNoRenderRegressions, compareProfiles, profileFromEvents };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { b as RenderEvent } from './types-gl13xwmN.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Render-regression testing.
|
|
5
|
+
*
|
|
6
|
+
* Fixing a render problem once is easy; keeping it fixed is the hard part. This
|
|
7
|
+
* turns render behaviour into something a pull request can fail on: record a
|
|
8
|
+
* profile for a scripted interaction, commit it, and compare on every run.
|
|
9
|
+
*
|
|
10
|
+
* Deliberately assertion-library agnostic — it returns data and a message, and
|
|
11
|
+
* your test framework decides what to do with it.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
interface ComponentProfile {
|
|
15
|
+
renders: number;
|
|
16
|
+
remounts: number;
|
|
17
|
+
avoidableRenders: number;
|
|
18
|
+
}
|
|
19
|
+
interface RenderProfile {
|
|
20
|
+
/** Free-form label, e.g. "search: type one character". */
|
|
21
|
+
scenario: string;
|
|
22
|
+
components: Record<string, ComponentProfile>;
|
|
23
|
+
}
|
|
24
|
+
interface RegressionOptions {
|
|
25
|
+
/**
|
|
26
|
+
* Allowed growth before a component counts as regressed, as a fraction.
|
|
27
|
+
* `0.2` tolerates a 20% increase. Defaults to 0 — exact.
|
|
28
|
+
*/
|
|
29
|
+
tolerance?: number;
|
|
30
|
+
/** Ignore components below this render count in the baseline. */
|
|
31
|
+
ignoreBelow?: number;
|
|
32
|
+
/** Component names to skip entirely. */
|
|
33
|
+
ignore?: string[];
|
|
34
|
+
/** Fail when a component is rendering *fewer* times too. Off by default. */
|
|
35
|
+
failOnImprovement?: boolean;
|
|
36
|
+
}
|
|
37
|
+
interface Regression {
|
|
38
|
+
component: string;
|
|
39
|
+
metric: "renders" | "remounts" | "avoidableRenders";
|
|
40
|
+
baseline: number;
|
|
41
|
+
current: number;
|
|
42
|
+
delta: number;
|
|
43
|
+
}
|
|
44
|
+
interface RegressionResult {
|
|
45
|
+
ok: boolean;
|
|
46
|
+
scenario: string;
|
|
47
|
+
regressions: Regression[];
|
|
48
|
+
improvements: Regression[];
|
|
49
|
+
/** Components present now but absent from the baseline. */
|
|
50
|
+
added: string[];
|
|
51
|
+
message: string;
|
|
52
|
+
}
|
|
53
|
+
/** Builds a profile from recorded events. Pass `getEvents()`. */
|
|
54
|
+
declare function profileFromEvents(scenario: string, events: RenderEvent[], remounts?: Record<string, number>): RenderProfile;
|
|
55
|
+
declare function compareProfiles(baseline: RenderProfile, current: RenderProfile, options?: RegressionOptions): RegressionResult;
|
|
56
|
+
/**
|
|
57
|
+
* Throws when the current profile is worse than the baseline. The one-liner for
|
|
58
|
+
* a test file; use `compareProfiles` when you want the data.
|
|
59
|
+
*/
|
|
60
|
+
declare function assertNoRenderRegressions(baseline: RenderProfile, current: RenderProfile, options?: RegressionOptions): void;
|
|
61
|
+
|
|
62
|
+
export { type ComponentProfile, type Regression, type RegressionOptions, type RegressionResult, type RenderProfile, assertNoRenderRegressions, compareProfiles, profileFromEvents };
|
package/dist/testing.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"testing.js"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-render-detective",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Know WHY your React components render \u2014 not just that they did.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -61,6 +61,11 @@
|
|
|
61
61
|
"import": "./dist/vite.js",
|
|
62
62
|
"require": "./dist/vite.cjs"
|
|
63
63
|
},
|
|
64
|
+
"./testing": {
|
|
65
|
+
"types": "./dist/testing.d.ts",
|
|
66
|
+
"import": "./dist/testing.js",
|
|
67
|
+
"require": "./dist/testing.cjs"
|
|
68
|
+
},
|
|
64
69
|
"./package.json": "./package.json"
|
|
65
70
|
},
|
|
66
71
|
"scripts": {
|