@apollo/client 3.8.3 → 3.8.4
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 +8 -6
- package/apollo-client.cjs +7 -2
- package/apollo-client.cjs.map +1 -1
- package/apollo-client.min.cjs +1 -1
- package/config/jest/setup.js +10 -0
- package/config/jest/setup.js.map +1 -1
- package/core/QueryManager.d.ts +1 -1
- package/core/QueryManager.d.ts.map +1 -1
- package/core/QueryManager.js.map +1 -1
- package/core/core.cjs +1 -1
- package/core/core.cjs.map +1 -1
- package/core/core.cjs.native.js +1 -1
- package/dev/dev.cjs +7 -2
- package/dev/dev.cjs.map +1 -1
- package/dev/dev.cjs.native.js +7 -2
- package/package.json +30 -23
- package/testing/core/withConsoleSpy.d.ts.map +1 -1
- package/testing/core/withConsoleSpy.js.map +1 -1
- package/testing/internal/disposables/index.d.ts +3 -0
- package/testing/internal/disposables/index.d.ts.map +1 -0
- package/testing/internal/disposables/index.js +3 -0
- package/testing/internal/disposables/index.js.map +1 -0
- package/testing/internal/disposables/spyOnConsole.d.ts +10 -0
- package/testing/internal/disposables/spyOnConsole.d.ts.map +1 -0
- package/testing/internal/disposables/spyOnConsole.js +33 -0
- package/testing/internal/disposables/spyOnConsole.js.map +1 -0
- package/testing/internal/disposables/withCleanup.d.ts +3 -0
- package/testing/internal/disposables/withCleanup.d.ts.map +1 -0
- package/testing/internal/disposables/withCleanup.js +11 -0
- package/testing/internal/disposables/withCleanup.js.map +1 -0
- package/testing/internal/index.d.ts +3 -0
- package/testing/internal/index.d.ts.map +1 -0
- package/testing/internal/index.js +3 -0
- package/testing/internal/index.js.map +1 -0
- package/testing/internal/profile/Render.d.ts +140 -0
- package/testing/internal/profile/Render.d.ts.map +1 -0
- package/testing/internal/profile/Render.js +132 -0
- package/testing/internal/profile/Render.js.map +1 -0
- package/testing/internal/profile/index.d.ts +4 -0
- package/testing/internal/profile/index.d.ts.map +1 -0
- package/testing/internal/profile/index.js +2 -0
- package/testing/internal/profile/index.js.map +1 -0
- package/testing/internal/profile/profile.d.ts +55 -0
- package/testing/internal/profile/profile.d.ts.map +1 -0
- package/testing/internal/profile/profile.js +222 -0
- package/testing/internal/profile/profile.js.map +1 -0
- package/testing/internal/profile/traces.d.ts +3 -0
- package/testing/internal/profile/traces.d.ts.map +1 -0
- package/testing/internal/profile/traces.js +26 -0
- package/testing/internal/profile/traces.js.map +1 -0
- package/testing/matchers/ProfiledComponent.d.ts +8 -0
- package/testing/matchers/ProfiledComponent.d.ts.map +1 -0
- package/testing/matchers/ProfiledComponent.js +107 -0
- package/testing/matchers/ProfiledComponent.js.map +1 -0
- package/testing/matchers/index.js +3 -0
- package/testing/matchers/index.js.map +1 -1
- package/utilities/globals/globals.cjs +7 -2
- package/utilities/globals/globals.cjs.map +1 -1
- package/utilities/globals/globals.cjs.native.js +7 -2
- package/utilities/globals/invariantWrappers.d.ts.map +1 -1
- package/utilities/globals/invariantWrappers.js +6 -1
- package/utilities/globals/invariantWrappers.js.map +1 -1
- package/version.js +1 -1
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { screen } from "@testing-library/dom";
|
|
2
|
+
export interface BaseRender {
|
|
3
|
+
id: string;
|
|
4
|
+
phase: "mount" | "update" | "nested-update";
|
|
5
|
+
actualDuration: number;
|
|
6
|
+
baseDuration: number;
|
|
7
|
+
startTime: number;
|
|
8
|
+
commitTime: number;
|
|
9
|
+
count: number;
|
|
10
|
+
}
|
|
11
|
+
type Screen = typeof screen;
|
|
12
|
+
export type SyncScreen = {
|
|
13
|
+
[K in keyof Screen]: K extends `find${string}` ? {
|
|
14
|
+
(...args: Parameters<Screen[K]>): ReturnType<Screen[K]>;
|
|
15
|
+
} : Screen[K];
|
|
16
|
+
};
|
|
17
|
+
export interface Render<Snapshot> extends BaseRender {
|
|
18
|
+
snapshot: Snapshot;
|
|
19
|
+
readonly domSnapshot: HTMLElement;
|
|
20
|
+
withinDOM: () => SyncScreen;
|
|
21
|
+
}
|
|
22
|
+
export declare class RenderInstance<Snapshot> implements Render<Snapshot> {
|
|
23
|
+
snapshot: Snapshot;
|
|
24
|
+
private stringifiedDOM;
|
|
25
|
+
id: string;
|
|
26
|
+
phase: "mount" | "update" | "nested-update";
|
|
27
|
+
actualDuration: number;
|
|
28
|
+
baseDuration: number;
|
|
29
|
+
startTime: number;
|
|
30
|
+
commitTime: number;
|
|
31
|
+
count: number;
|
|
32
|
+
constructor(baseRender: BaseRender, snapshot: Snapshot, stringifiedDOM: string | undefined);
|
|
33
|
+
private _domSnapshot;
|
|
34
|
+
get domSnapshot(): HTMLElement;
|
|
35
|
+
get withinDOM(): () => {
|
|
36
|
+
getByLabelText<T extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").SelectorMatcherOptions | undefined): T;
|
|
37
|
+
getAllByLabelText<T_1 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").SelectorMatcherOptions | undefined): T_1[];
|
|
38
|
+
queryByLabelText<T_2 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").SelectorMatcherOptions | undefined): T_2 | null;
|
|
39
|
+
queryAllByLabelText<T_3 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").SelectorMatcherOptions | undefined): T_3[];
|
|
40
|
+
findByLabelText<T_4 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").SelectorMatcherOptions | undefined, waitForElementOptions?: import("@testing-library/dom").waitForOptions | undefined): Promise<T_4>;
|
|
41
|
+
findAllByLabelText<T_5 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").SelectorMatcherOptions | undefined, waitForElementOptions?: import("@testing-library/dom").waitForOptions | undefined): Promise<T_5[]>;
|
|
42
|
+
getByPlaceholderText<T_6 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined): T_6;
|
|
43
|
+
getAllByPlaceholderText<T_7 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined): T_7[];
|
|
44
|
+
queryByPlaceholderText<T_8 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined): T_8 | null;
|
|
45
|
+
queryAllByPlaceholderText<T_9 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined): T_9[];
|
|
46
|
+
findByPlaceholderText<T_10 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/dom").waitForOptions | undefined): Promise<T_10>;
|
|
47
|
+
findAllByPlaceholderText<T_11 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/dom").waitForOptions | undefined): Promise<T_11[]>;
|
|
48
|
+
getByText<T_12 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").SelectorMatcherOptions | undefined): T_12;
|
|
49
|
+
getAllByText<T_13 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").SelectorMatcherOptions | undefined): T_13[];
|
|
50
|
+
queryByText<T_14 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").SelectorMatcherOptions | undefined): T_14 | null;
|
|
51
|
+
queryAllByText<T_15 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").SelectorMatcherOptions | undefined): T_15[];
|
|
52
|
+
findByText<T_16 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").SelectorMatcherOptions | undefined, waitForElementOptions?: import("@testing-library/dom").waitForOptions | undefined): Promise<T_16>;
|
|
53
|
+
findAllByText<T_17 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").SelectorMatcherOptions | undefined, waitForElementOptions?: import("@testing-library/dom").waitForOptions | undefined): Promise<T_17[]>;
|
|
54
|
+
getByAltText<T_18 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined): T_18;
|
|
55
|
+
getAllByAltText<T_19 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined): T_19[];
|
|
56
|
+
queryByAltText<T_20 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined): T_20 | null;
|
|
57
|
+
queryAllByAltText<T_21 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined): T_21[];
|
|
58
|
+
findByAltText<T_22 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/dom").waitForOptions | undefined): Promise<T_22>;
|
|
59
|
+
findAllByAltText<T_23 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/dom").waitForOptions | undefined): Promise<T_23[]>;
|
|
60
|
+
getByTitle<T_24 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined): T_24;
|
|
61
|
+
getAllByTitle<T_25 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined): T_25[];
|
|
62
|
+
queryByTitle<T_26 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined): T_26 | null;
|
|
63
|
+
queryAllByTitle<T_27 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined): T_27[];
|
|
64
|
+
findByTitle<T_28 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/dom").waitForOptions | undefined): Promise<T_28>;
|
|
65
|
+
findAllByTitle<T_29 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/dom").waitForOptions | undefined): Promise<T_29[]>;
|
|
66
|
+
getByDisplayValue<T_30 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined): T_30;
|
|
67
|
+
getAllByDisplayValue<T_31 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined): T_31[];
|
|
68
|
+
queryByDisplayValue<T_32 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined): T_32 | null;
|
|
69
|
+
queryAllByDisplayValue<T_33 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined): T_33[];
|
|
70
|
+
findByDisplayValue<T_34 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/dom").waitForOptions | undefined): Promise<T_34>;
|
|
71
|
+
findAllByDisplayValue<T_35 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/dom").waitForOptions | undefined): Promise<T_35[]>;
|
|
72
|
+
getByRole<T_36 extends HTMLElement = HTMLElement>(role: import("@testing-library/dom").ByRoleMatcher, options?: import("@testing-library/dom").ByRoleOptions | undefined): T_36;
|
|
73
|
+
getAllByRole<T_37 extends HTMLElement = HTMLElement>(role: import("@testing-library/dom").ByRoleMatcher, options?: import("@testing-library/dom").ByRoleOptions | undefined): T_37[];
|
|
74
|
+
queryByRole<T_38 extends HTMLElement = HTMLElement>(role: import("@testing-library/dom").ByRoleMatcher, options?: import("@testing-library/dom").ByRoleOptions | undefined): T_38 | null;
|
|
75
|
+
queryAllByRole<T_39 extends HTMLElement = HTMLElement>(role: import("@testing-library/dom").ByRoleMatcher, options?: import("@testing-library/dom").ByRoleOptions | undefined): T_39[];
|
|
76
|
+
findByRole<T_40 extends HTMLElement = HTMLElement>(role: import("@testing-library/dom").ByRoleMatcher, options?: import("@testing-library/dom").ByRoleOptions | undefined, waitForElementOptions?: import("@testing-library/dom").waitForOptions | undefined): Promise<T_40>;
|
|
77
|
+
findAllByRole<T_41 extends HTMLElement = HTMLElement>(role: import("@testing-library/dom").ByRoleMatcher, options?: import("@testing-library/dom").ByRoleOptions | undefined, waitForElementOptions?: import("@testing-library/dom").waitForOptions | undefined): Promise<T_41[]>;
|
|
78
|
+
getByTestId<T_42 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined): T_42;
|
|
79
|
+
getAllByTestId<T_43 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined): T_43[];
|
|
80
|
+
queryByTestId<T_44 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined): T_44 | null;
|
|
81
|
+
queryAllByTestId<T_45 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined): T_45[];
|
|
82
|
+
findByTestId<T_46 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/dom").waitForOptions | undefined): Promise<T_46>;
|
|
83
|
+
findAllByTestId<T_47 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/dom").waitForOptions | undefined): Promise<T_47[]>;
|
|
84
|
+
} & {
|
|
85
|
+
getByLabelText: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").SelectorMatcherOptions | undefined) => HTMLElement;
|
|
86
|
+
getAllByLabelText: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").SelectorMatcherOptions | undefined) => HTMLElement[];
|
|
87
|
+
queryByLabelText: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").SelectorMatcherOptions | undefined) => HTMLElement | null;
|
|
88
|
+
queryAllByLabelText: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").SelectorMatcherOptions | undefined) => HTMLElement[];
|
|
89
|
+
findByLabelText: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").SelectorMatcherOptions | undefined, waitForElementOptions?: import("@testing-library/dom").waitForOptions | undefined) => Promise<HTMLElement>;
|
|
90
|
+
findAllByLabelText: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").SelectorMatcherOptions | undefined, waitForElementOptions?: import("@testing-library/dom").waitForOptions | undefined) => Promise<HTMLElement[]>;
|
|
91
|
+
getByPlaceholderText: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined) => HTMLElement;
|
|
92
|
+
getAllByPlaceholderText: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined) => HTMLElement[];
|
|
93
|
+
queryByPlaceholderText: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined) => HTMLElement | null;
|
|
94
|
+
queryAllByPlaceholderText: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined) => HTMLElement[];
|
|
95
|
+
findByPlaceholderText: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/dom").waitForOptions | undefined) => Promise<HTMLElement>;
|
|
96
|
+
findAllByPlaceholderText: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/dom").waitForOptions | undefined) => Promise<HTMLElement[]>;
|
|
97
|
+
getByText: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").SelectorMatcherOptions | undefined) => HTMLElement;
|
|
98
|
+
getAllByText: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").SelectorMatcherOptions | undefined) => HTMLElement[];
|
|
99
|
+
queryByText: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").SelectorMatcherOptions | undefined) => HTMLElement | null;
|
|
100
|
+
queryAllByText: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").SelectorMatcherOptions | undefined) => HTMLElement[];
|
|
101
|
+
findByText: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").SelectorMatcherOptions | undefined, waitForElementOptions?: import("@testing-library/dom").waitForOptions | undefined) => Promise<HTMLElement>;
|
|
102
|
+
findAllByText: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").SelectorMatcherOptions | undefined, waitForElementOptions?: import("@testing-library/dom").waitForOptions | undefined) => Promise<HTMLElement[]>;
|
|
103
|
+
getByAltText: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined) => HTMLElement;
|
|
104
|
+
getAllByAltText: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined) => HTMLElement[];
|
|
105
|
+
queryByAltText: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined) => HTMLElement | null;
|
|
106
|
+
queryAllByAltText: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined) => HTMLElement[];
|
|
107
|
+
findByAltText: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/dom").waitForOptions | undefined) => Promise<HTMLElement>;
|
|
108
|
+
findAllByAltText: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/dom").waitForOptions | undefined) => Promise<HTMLElement[]>;
|
|
109
|
+
getByTitle: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined) => HTMLElement;
|
|
110
|
+
getAllByTitle: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined) => HTMLElement[];
|
|
111
|
+
queryByTitle: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined) => HTMLElement | null;
|
|
112
|
+
queryAllByTitle: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined) => HTMLElement[];
|
|
113
|
+
findByTitle: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/dom").waitForOptions | undefined) => Promise<HTMLElement>;
|
|
114
|
+
findAllByTitle: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/dom").waitForOptions | undefined) => Promise<HTMLElement[]>;
|
|
115
|
+
getByDisplayValue: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined) => HTMLElement;
|
|
116
|
+
getAllByDisplayValue: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined) => HTMLElement[];
|
|
117
|
+
queryByDisplayValue: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined) => HTMLElement | null;
|
|
118
|
+
queryAllByDisplayValue: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined) => HTMLElement[];
|
|
119
|
+
findByDisplayValue: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/dom").waitForOptions | undefined) => Promise<HTMLElement>;
|
|
120
|
+
findAllByDisplayValue: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/dom").waitForOptions | undefined) => Promise<HTMLElement[]>;
|
|
121
|
+
getByRole: (role: import("@testing-library/dom").ByRoleMatcher, options?: import("@testing-library/dom").ByRoleOptions | undefined) => HTMLElement;
|
|
122
|
+
getAllByRole: (role: import("@testing-library/dom").ByRoleMatcher, options?: import("@testing-library/dom").ByRoleOptions | undefined) => HTMLElement[];
|
|
123
|
+
queryByRole: (role: import("@testing-library/dom").ByRoleMatcher, options?: import("@testing-library/dom").ByRoleOptions | undefined) => HTMLElement | null;
|
|
124
|
+
queryAllByRole: (role: import("@testing-library/dom").ByRoleMatcher, options?: import("@testing-library/dom").ByRoleOptions | undefined) => HTMLElement[];
|
|
125
|
+
findByRole: (role: import("@testing-library/dom").ByRoleMatcher, options?: import("@testing-library/dom").ByRoleOptions | undefined, waitForElementOptions?: import("@testing-library/dom").waitForOptions | undefined) => Promise<HTMLElement>;
|
|
126
|
+
findAllByRole: (role: import("@testing-library/dom").ByRoleMatcher, options?: import("@testing-library/dom").ByRoleOptions | undefined, waitForElementOptions?: import("@testing-library/dom").waitForOptions | undefined) => Promise<HTMLElement[]>;
|
|
127
|
+
getByTestId: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined) => HTMLElement;
|
|
128
|
+
getAllByTestId: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined) => HTMLElement[];
|
|
129
|
+
queryByTestId: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined) => HTMLElement | null;
|
|
130
|
+
queryAllByTestId: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined) => HTMLElement[];
|
|
131
|
+
findByTestId: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/dom").waitForOptions | undefined) => Promise<HTMLElement>;
|
|
132
|
+
findAllByTestId: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/dom").waitForOptions | undefined) => Promise<HTMLElement[]>;
|
|
133
|
+
} & {
|
|
134
|
+
debug: (element?: Element | HTMLDocument | (Element | HTMLDocument)[] | undefined, maxLength?: number | undefined, options?: import("pretty-format").PrettyFormatOptions | undefined) => void;
|
|
135
|
+
logTestingPlaygroundURL: (element?: Element | HTMLDocument | undefined) => void;
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
export declare function errorOnDomInteraction(): void;
|
|
139
|
+
export {};
|
|
140
|
+
//# sourceMappingURL=Render.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Render.d.ts","sourceRoot":"","sources":["../../../../src/testing/internal/profile/Render.tsx"],"names":[],"mappings":"AAWA,OAAO,EAAU,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAKtD,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,OAAO,GAAG,QAAQ,GAAG,eAAe,CAAC;IAC5C,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IAInB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,KAAK,MAAM,GAAG,OAAO,MAAM,CAAC;AAE5B,MAAM,MAAM,UAAU,GAAG;KACtB,CAAC,IAAI,MAAM,MAAM,GAAG,CAAC,SAAS,OAAO,MAAM,EAAE,GAC1C;QAEE,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;KACzD,GACD,MAAM,CAAC,CAAC,CAAC;CACd,CAAC;AAGF,MAAM,WAAW,MAAM,CAAC,QAAQ,CAAE,SAAQ,UAAU;IAKlD,QAAQ,EAAE,QAAQ,CAAC;IAKnB,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;IAYlC,SAAS,EAAE,MAAM,UAAU,CAAC;CAC7B;AAGD,qBAAa,cAAc,CAAC,QAAQ,CAAE,YAAW,MAAM,CAAC,QAAQ,CAAC;IAWtD,QAAQ,EAAE,QAAQ;IACzB,OAAO,CAAC,cAAc;IAXxB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,OAAO,GAAG,QAAQ,GAAG,eAAe,CAAC;IAC5C,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;gBAGZ,UAAU,EAAE,UAAU,EACf,QAAQ,EAAE,QAAQ,EACjB,cAAc,EAAE,MAAM,GAAG,SAAS;IAW5C,OAAO,CAAC,YAAY,CAA0B;IAC9C,IAAI,WAAW,gBA8Bd;IAED,IAAI,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAgBZ;CACF;AAED,wBAAgB,qBAAqB,SA6DpC"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { __spreadArray } from "tslib";
|
|
2
|
+
import { within, screen } from "@testing-library/dom";
|
|
3
|
+
import { JSDOM, VirtualConsole } from "jsdom";
|
|
4
|
+
import { applyStackTrace, captureStackTrace } from "./traces.js";
|
|
5
|
+
var RenderInstance = (function () {
|
|
6
|
+
function RenderInstance(baseRender, snapshot, stringifiedDOM) {
|
|
7
|
+
this.snapshot = snapshot;
|
|
8
|
+
this.stringifiedDOM = stringifiedDOM;
|
|
9
|
+
this.id = baseRender.id;
|
|
10
|
+
this.phase = baseRender.phase;
|
|
11
|
+
this.actualDuration = baseRender.actualDuration;
|
|
12
|
+
this.baseDuration = baseRender.baseDuration;
|
|
13
|
+
this.startTime = baseRender.startTime;
|
|
14
|
+
this.commitTime = baseRender.commitTime;
|
|
15
|
+
this.count = baseRender.count;
|
|
16
|
+
}
|
|
17
|
+
Object.defineProperty(RenderInstance.prototype, "domSnapshot", {
|
|
18
|
+
get: function () {
|
|
19
|
+
if (this._domSnapshot)
|
|
20
|
+
return this._domSnapshot;
|
|
21
|
+
if (!this.stringifiedDOM) {
|
|
22
|
+
throw new Error("DOM snapshot is not available - please set the `snapshotDOM` option");
|
|
23
|
+
}
|
|
24
|
+
var virtualConsole = new VirtualConsole();
|
|
25
|
+
var stackTrace = captureStackTrace("RenderInstance.get");
|
|
26
|
+
virtualConsole.on("jsdomError", function (error) {
|
|
27
|
+
throw applyStackTrace(error, stackTrace);
|
|
28
|
+
});
|
|
29
|
+
var snapDOM = new JSDOM(this.stringifiedDOM, {
|
|
30
|
+
runScripts: "dangerously",
|
|
31
|
+
virtualConsole: virtualConsole,
|
|
32
|
+
});
|
|
33
|
+
var document = snapDOM.window.document;
|
|
34
|
+
var body = document.body;
|
|
35
|
+
var script = document.createElement("script");
|
|
36
|
+
script.type = "text/javascript";
|
|
37
|
+
script.text = "\n ".concat(errorOnDomInteraction.toString(), ";\n ").concat(errorOnDomInteraction.name, "();\n ");
|
|
38
|
+
body.appendChild(script);
|
|
39
|
+
body.removeChild(script);
|
|
40
|
+
return (this._domSnapshot = body);
|
|
41
|
+
},
|
|
42
|
+
enumerable: false,
|
|
43
|
+
configurable: true
|
|
44
|
+
});
|
|
45
|
+
Object.defineProperty(RenderInstance.prototype, "withinDOM", {
|
|
46
|
+
get: function () {
|
|
47
|
+
var _this = this;
|
|
48
|
+
var snapScreen = Object.assign(within(this.domSnapshot), {
|
|
49
|
+
debug: function () {
|
|
50
|
+
var _a = [];
|
|
51
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
52
|
+
_a[_i] = arguments[_i];
|
|
53
|
+
}
|
|
54
|
+
var _b = _a[0], dom = _b === void 0 ? _this.domSnapshot : _b, rest = _a.slice(1);
|
|
55
|
+
screen.debug.apply(screen, __spreadArray([dom], rest, false));
|
|
56
|
+
},
|
|
57
|
+
logTestingPlaygroundURL: function () {
|
|
58
|
+
var _a = [];
|
|
59
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
60
|
+
_a[_i] = arguments[_i];
|
|
61
|
+
}
|
|
62
|
+
var _b = _a[0], dom = _b === void 0 ? _this.domSnapshot : _b, rest = _a.slice(1);
|
|
63
|
+
screen.logTestingPlaygroundURL.apply(screen, __spreadArray([dom], rest, false));
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
return function () { return snapScreen; };
|
|
67
|
+
},
|
|
68
|
+
enumerable: false,
|
|
69
|
+
configurable: true
|
|
70
|
+
});
|
|
71
|
+
return RenderInstance;
|
|
72
|
+
}());
|
|
73
|
+
export { RenderInstance };
|
|
74
|
+
export function errorOnDomInteraction() {
|
|
75
|
+
var events = [
|
|
76
|
+
"auxclick",
|
|
77
|
+
"blur",
|
|
78
|
+
"change",
|
|
79
|
+
"click",
|
|
80
|
+
"copy",
|
|
81
|
+
"cut",
|
|
82
|
+
"dblclick",
|
|
83
|
+
"drag",
|
|
84
|
+
"dragend",
|
|
85
|
+
"dragenter",
|
|
86
|
+
"dragleave",
|
|
87
|
+
"dragover",
|
|
88
|
+
"dragstart",
|
|
89
|
+
"drop",
|
|
90
|
+
"focus",
|
|
91
|
+
"focusin",
|
|
92
|
+
"focusout",
|
|
93
|
+
"input",
|
|
94
|
+
"keydown",
|
|
95
|
+
"keypress",
|
|
96
|
+
"keyup",
|
|
97
|
+
"mousedown",
|
|
98
|
+
"mouseenter",
|
|
99
|
+
"mouseleave",
|
|
100
|
+
"mousemove",
|
|
101
|
+
"mouseout",
|
|
102
|
+
"mouseover",
|
|
103
|
+
"mouseup",
|
|
104
|
+
"paste",
|
|
105
|
+
"pointercancel",
|
|
106
|
+
"pointerdown",
|
|
107
|
+
"pointerenter",
|
|
108
|
+
"pointerleave",
|
|
109
|
+
"pointermove",
|
|
110
|
+
"pointerout",
|
|
111
|
+
"pointerover",
|
|
112
|
+
"pointerup",
|
|
113
|
+
"scroll",
|
|
114
|
+
"select",
|
|
115
|
+
"selectionchange",
|
|
116
|
+
"selectstart",
|
|
117
|
+
"submit",
|
|
118
|
+
"toggle",
|
|
119
|
+
"touchcancel",
|
|
120
|
+
"touchend",
|
|
121
|
+
"touchmove",
|
|
122
|
+
"touchstart",
|
|
123
|
+
"wheel",
|
|
124
|
+
];
|
|
125
|
+
function warnOnDomInteraction() {
|
|
126
|
+
throw new Error("\n DOM interaction with a snapshot detected in test.\n Please don't interact with the DOM you get from `withinDOM`,\n but still use `screen' to get elements for simulating user interaction.\n ");
|
|
127
|
+
}
|
|
128
|
+
events.forEach(function (event) {
|
|
129
|
+
document.addEventListener(event, warnOnDomInteraction);
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=Render.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Render.js","sourceRoot":"","sources":["../../../../src/testing/internal/profile/Render.tsx"],"names":[],"mappings":";AAWA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAsDjE;IASE,wBACE,UAAsB,EACf,QAAkB,EACjB,cAAkC;QADnC,aAAQ,GAAR,QAAQ,CAAU;QACjB,mBAAc,GAAd,cAAc,CAAoB;QAE1C,IAAI,CAAC,EAAE,G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V,OAAO;QACP,SAAS;QACT,UAAU;QACV,OAAO;QACP,WAAW;QACX,YAAY;QACZ,YAAY;QACZ,WAAW;QACX,UAAU;QACV,WAAW;QACX,SAAS;QACT,OAAO;QACP,eAAe;QACf,aAAa;QACb,cAAc;QACd,cAAc;QACd,aAAa;QACb,YAAY;QACZ,aAAa;QACb,WAAW;QACX,QAAQ;QACR,QAAQ;QACR,iBAAiB;QACjB,aAAa;QACb,QAAQ;QACR,QAAQ;QACR,aAAa;QACb,UAAU;QACV,WAAW;QACX,YAAY;QACZ,OAAO;KACR,CAAC;IACF,SAAS,oBAAoB;QAC3B,MAAM,IAAI,KAAK,CAAC,8MAIf,CAAC,CAAC;IACL,CAAC;IACD,MAAM,CAAC,OAAO,CAAC,UAAC,KAAK;QACnB,QAAQ,CAAC,gBAAgB,CAAC,KAAK,EAAE,oBAAoB,CAAC,CAAC;IACzD,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["/* istanbul ignore file */\n\n/*\nSomething in this file does not compile correctly while measuring code coverage\nand will lead to a\n Uncaught [ReferenceError: cov_1zb8w312au is not defined]\nif we do not ignore this file in code coverage.\n\nAs we only use this file in our internal tests, we can safely ignore it.\n*/\n\nimport { within, screen } from \"@testing-library/dom\";\nimport { JSDOM, VirtualConsole } from \"jsdom\";\nimport { applyStackTrace, captureStackTrace } from \"./traces.js\";\n\n/** @internal */\nexport interface BaseRender {\n id: string;\n phase: \"mount\" | \"update\" | \"nested-update\";\n actualDuration: number;\n baseDuration: number;\n startTime: number;\n commitTime: number;\n /**\n * The number of renders that have happened so far (including this render).\n */\n count: number;\n}\n\ntype Screen = typeof screen;\n/** @internal */\nexport type SyncScreen = {\n [K in keyof Screen]: K extends `find${string}`\n ? {\n /** @deprecated A snapshot is static, so avoid async queries! */\n (...args: Parameters<Screen[K]>): ReturnType<Screen[K]>;\n }\n : Screen[K];\n};\n\n/** @internal */\nexport interface Render<Snapshot> extends BaseRender {\n /**\n * The snapshot, as returned by the `takeSnapshot` option of `profile`.\n * (If using `profileHook`, this is the return value of the hook.)\n */\n snapshot: Snapshot;\n /**\n * A DOM snapshot of the rendered component, if the `snapshotDOM`\n * option of `profile` was enabled.\n */\n readonly domSnapshot: HTMLElement;\n /**\n * Returns a callback to receive a `screen` instance that is scoped to the\n * DOM snapshot of this `Render` instance.\n * Note: this is used as a callback to prevent linter errors.\n * @example\n * ```diff\n * const { withinDOM } = RenderedComponent.takeRender();\n * -expect(screen.getByText(\"foo\")).toBeInTheDocument();\n * +expect(withinDOM().getByText(\"foo\")).toBeInTheDocument();\n * ```\n */\n withinDOM: () => SyncScreen;\n}\n\n/** @internal */\nexport class RenderInstance<Snapshot> implements Render<Snapshot> {\n id: string;\n phase: \"mount\" | \"update\" | \"nested-update\";\n actualDuration: number;\n baseDuration: number;\n startTime: number;\n commitTime: number;\n count: number;\n\n constructor(\n baseRender: BaseRender,\n public snapshot: Snapshot,\n private stringifiedDOM: string | undefined\n ) {\n this.id = baseRender.id;\n this.phase = baseRender.phase;\n this.actualDuration = baseRender.actualDuration;\n this.baseDuration = baseRender.baseDuration;\n this.startTime = baseRender.startTime;\n this.commitTime = baseRender.commitTime;\n this.count = baseRender.count;\n }\n\n private _domSnapshot: HTMLElement | undefined;\n get domSnapshot() {\n if (this._domSnapshot) return this._domSnapshot;\n if (!this.stringifiedDOM) {\n throw new Error(\n \"DOM snapshot is not available - please set the `snapshotDOM` option\"\n );\n }\n\n const virtualConsole = new VirtualConsole();\n const stackTrace = captureStackTrace(\"RenderInstance.get\");\n virtualConsole.on(\"jsdomError\", (error) => {\n throw applyStackTrace(error, stackTrace);\n });\n\n const snapDOM = new JSDOM(this.stringifiedDOM, {\n runScripts: \"dangerously\",\n virtualConsole,\n });\n const document = snapDOM.window.document;\n const body = document.body;\n const script = document.createElement(\"script\");\n script.type = \"text/javascript\";\n script.text = `\n ${errorOnDomInteraction.toString()};\n ${errorOnDomInteraction.name}();\n `;\n body.appendChild(script);\n body.removeChild(script);\n\n return (this._domSnapshot = body);\n }\n\n get withinDOM() {\n const snapScreen = Object.assign(within(this.domSnapshot), {\n debug: (\n ...[dom = this.domSnapshot, ...rest]: Parameters<typeof screen.debug>\n ) => {\n screen.debug(dom, ...rest);\n },\n logTestingPlaygroundURL: (\n ...[dom = this.domSnapshot, ...rest]: Parameters<\n typeof screen.logTestingPlaygroundURL\n >\n ) => {\n screen.logTestingPlaygroundURL(dom, ...rest);\n },\n });\n return () => snapScreen;\n }\n}\n/** @internal */\nexport function errorOnDomInteraction() {\n const events: Array<keyof DocumentEventMap> = [\n \"auxclick\",\n \"blur\",\n \"change\",\n \"click\",\n \"copy\",\n \"cut\",\n \"dblclick\",\n \"drag\",\n \"dragend\",\n \"dragenter\",\n \"dragleave\",\n \"dragover\",\n \"dragstart\",\n \"drop\",\n \"focus\",\n \"focusin\",\n \"focusout\",\n \"input\",\n \"keydown\",\n \"keypress\",\n \"keyup\",\n \"mousedown\",\n \"mouseenter\",\n \"mouseleave\",\n \"mousemove\",\n \"mouseout\",\n \"mouseover\",\n \"mouseup\",\n \"paste\",\n \"pointercancel\",\n \"pointerdown\",\n \"pointerenter\",\n \"pointerleave\",\n \"pointermove\",\n \"pointerout\",\n \"pointerover\",\n \"pointerup\",\n \"scroll\",\n \"select\",\n \"selectionchange\",\n \"selectstart\",\n \"submit\",\n \"toggle\",\n \"touchcancel\",\n \"touchend\",\n \"touchmove\",\n \"touchstart\",\n \"wheel\",\n ];\n function warnOnDomInteraction() {\n throw new Error(`\n DOM interaction with a snapshot detected in test.\n Please don't interact with the DOM you get from \\`withinDOM\\`,\n but still use \\`screen\\' to get elements for simulating user interaction.\n `);\n }\n events.forEach((event) => {\n document.addEventListener(event, warnOnDomInteraction);\n });\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/testing/internal/profile/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,iBAAiB,EACjB,iBAAiB,EACjB,YAAY,GACb,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AAE/E,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/testing/internal/profile/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC","sourcesContent":["export type {\n NextRenderOptions,\n ProfiledComponent,\n ProfiledHook,\n} from \"./profile.js\";\nexport { profile, profileHook, WaitForRenderTimeoutError } from \"./profile.js\";\n\nexport type { SyncScreen } from \"./Render.js\";\n"]}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { Render, BaseRender } from "./Render.js";
|
|
3
|
+
type ValidSnapshot = void | (object & {
|
|
4
|
+
call?: never;
|
|
5
|
+
});
|
|
6
|
+
declare const _stackTrace: unique symbol;
|
|
7
|
+
export interface NextRenderOptions {
|
|
8
|
+
timeout?: number;
|
|
9
|
+
[_stackTrace]?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface ProfiledComponent<Props, Snapshot> extends React.FC<Props>, ProfiledComponentFields<Props, Snapshot>, ProfiledComponenOnlyFields<Props, Snapshot> {
|
|
12
|
+
}
|
|
13
|
+
interface UpdateSnapshot<Snapshot> {
|
|
14
|
+
(newSnapshot: Snapshot): void;
|
|
15
|
+
(updateSnapshot: (lastSnapshot: Readonly<Snapshot>) => Snapshot): void;
|
|
16
|
+
}
|
|
17
|
+
interface ProfiledComponenOnlyFields<Props, Snapshot> {
|
|
18
|
+
updateSnapshot: UpdateSnapshot<Snapshot>;
|
|
19
|
+
}
|
|
20
|
+
interface ProfiledComponentFields<Props, Snapshot> {
|
|
21
|
+
renders: Array<Render<Snapshot> | {
|
|
22
|
+
phase: "snapshotError";
|
|
23
|
+
count: number;
|
|
24
|
+
error: unknown;
|
|
25
|
+
}>;
|
|
26
|
+
peekRender(options?: NextRenderOptions): Promise<Render<Snapshot>>;
|
|
27
|
+
takeRender(options?: NextRenderOptions): Promise<Render<Snapshot>>;
|
|
28
|
+
currentRenderCount(): number;
|
|
29
|
+
getCurrentRender(): Render<Snapshot>;
|
|
30
|
+
takeUntilRenderCount(count: number, optionsPerRender?: NextRenderOptions): Promise<void>;
|
|
31
|
+
waitForNextRender(options?: NextRenderOptions): Promise<Render<Snapshot>>;
|
|
32
|
+
}
|
|
33
|
+
export declare function profile<Snapshot extends ValidSnapshot = void, Props = Record<string, never>>({ Component, onRender, snapshotDOM, initialSnapshot, }: {
|
|
34
|
+
Component: React.ComponentType<Props>;
|
|
35
|
+
onRender?: (info: BaseRender & {
|
|
36
|
+
snapshot: Snapshot;
|
|
37
|
+
updateSnapshot: UpdateSnapshot<Snapshot>;
|
|
38
|
+
}) => void;
|
|
39
|
+
snapshotDOM?: boolean;
|
|
40
|
+
initialSnapshot?: Snapshot;
|
|
41
|
+
}): ProfiledComponent<Props, Snapshot>;
|
|
42
|
+
export declare class WaitForRenderTimeoutError extends Error {
|
|
43
|
+
constructor();
|
|
44
|
+
}
|
|
45
|
+
type StringReplaceRenderWithSnapshot<T extends string> = T extends `${infer Pre}Render${infer Post}` ? `${Pre}Snapshot${Post}` : T;
|
|
46
|
+
type ResultReplaceRenderWithSnapshot<T> = T extends (...args: infer Args) => Render<infer Snapshot> ? (...args: Args) => Snapshot : T extends (...args: infer Args) => Promise<Render<infer Snapshot>> ? (...args: Args) => Promise<Snapshot> : T;
|
|
47
|
+
type ProfiledHookFields<Props, ReturnValue> = ProfiledComponentFields<Props, ReturnValue> extends infer PC ? {
|
|
48
|
+
[K in keyof PC as StringReplaceRenderWithSnapshot<K & string>]: ResultReplaceRenderWithSnapshot<PC[K]>;
|
|
49
|
+
} : never;
|
|
50
|
+
export interface ProfiledHook<Props, ReturnValue> extends React.FC<Props>, ProfiledHookFields<Props, ReturnValue> {
|
|
51
|
+
ProfiledComponent: ProfiledComponent<Props, ReturnValue>;
|
|
52
|
+
}
|
|
53
|
+
export declare function profileHook<ReturnValue extends ValidSnapshot, Props>(renderCallback: (props: Props) => ReturnValue): ProfiledHook<Props, ReturnValue>;
|
|
54
|
+
export {};
|
|
55
|
+
//# sourceMappingURL=profile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profile.d.ts","sourceRoot":"","sources":["../../../../src/testing/internal/profile/profile.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAO/B,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAItD,KAAK,aAAa,GAAG,IAAI,GAAG,CAAC,MAAM,GAAG;IAAuB,IAAI,CAAC,EAAE,KAAK,CAAA;CAAE,CAAC,CAAC;AAG7E,QAAA,MAAM,WAAW,eAAW,CAAC;AAE7B,MAAM,WAAW,iBAAiB;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,CAAC,WAAW,CAAC,CAAC,EAAE,MAAM,CAAC;CACxB;AAGD,MAAM,WAAW,iBAAiB,CAAC,KAAK,EAAE,QAAQ,CAChD,SAAQ,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,EACrB,uBAAuB,CAAC,KAAK,EAAE,QAAQ,CAAC,EACxC,0BAA0B,CAAC,KAAK,EAAE,QAAQ,CAAC;CAAG;AAElD,UAAU,cAAc,CAAC,QAAQ;IAC/B,CAAC,WAAW,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC9B,CAAC,cAAc,EAAE,CAAC,YAAY,EAAE,QAAQ,CAAC,QAAQ,CAAC,KAAK,QAAQ,GAAG,IAAI,CAAC;CACxE;AAED,UAAU,0BAA0B,CAAC,KAAK,EAAE,QAAQ;IAClD,cAAc,EAAE,cAAc,CAAC,QAAQ,CAAC,CAAC;CAC1C;AACD,UAAU,uBAAuB,CAAC,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ter, __extends, __generator } from "tslib";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { TextEncoder, TextDecoder } from "util";
|
|
5
|
+
(_a = global.TextEncoder) !== null && _a !== void 0 ? _a : (global.TextEncoder = TextEncoder);
|
|
6
|
+
(_b = global.TextDecoder) !== null && _b !== void 0 ? _b : (global.TextDecoder = TextDecoder);
|
|
7
|
+
import { RenderInstance } from "./Render.js";
|
|
8
|
+
import { applyStackTrace, captureStackTrace } from "./traces.js";
|
|
9
|
+
var _stackTrace = Symbol();
|
|
10
|
+
export function profile(_a) {
|
|
11
|
+
var Component = _a.Component, onRender = _a.onRender, _b = _a.snapshotDOM, snapshotDOM = _b === void 0 ? false : _b, initialSnapshot = _a.initialSnapshot;
|
|
12
|
+
var currentRender;
|
|
13
|
+
var nextRender;
|
|
14
|
+
var resolveNextRender;
|
|
15
|
+
var rejectNextRender;
|
|
16
|
+
var snapshotRef = { current: initialSnapshot };
|
|
17
|
+
var updateSnapshot = function (snap) {
|
|
18
|
+
if (typeof snap === "function") {
|
|
19
|
+
if (!initialSnapshot) {
|
|
20
|
+
throw new Error("Cannot use a function to update the snapshot if no initial snapshot was provided.");
|
|
21
|
+
}
|
|
22
|
+
snapshotRef.current = snap(typeof snapshotRef.current === "object"
|
|
23
|
+
? __assign({}, snapshotRef.current) : snapshotRef.current);
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
snapshotRef.current = snap;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
var profilerOnRender = function (id, phase, actualDuration, baseDuration, startTime, commitTime) {
|
|
30
|
+
var baseRender = {
|
|
31
|
+
id: id,
|
|
32
|
+
phase: phase,
|
|
33
|
+
actualDuration: actualDuration,
|
|
34
|
+
baseDuration: baseDuration,
|
|
35
|
+
startTime: startTime,
|
|
36
|
+
commitTime: commitTime,
|
|
37
|
+
count: Profiled.renders.length + 1,
|
|
38
|
+
};
|
|
39
|
+
try {
|
|
40
|
+
onRender === null || onRender === void 0 ? void 0 : onRender(__assign(__assign({}, baseRender), { updateSnapshot: updateSnapshot, snapshot: snapshotRef.current }));
|
|
41
|
+
var snapshot = snapshotRef.current;
|
|
42
|
+
var domSnapshot = snapshotDOM
|
|
43
|
+
? window.document.body.innerHTML
|
|
44
|
+
: undefined;
|
|
45
|
+
var render = new RenderInstance(baseRender, snapshot, domSnapshot);
|
|
46
|
+
currentRender = render;
|
|
47
|
+
Profiled.renders.push(render);
|
|
48
|
+
resolveNextRender === null || resolveNextRender === void 0 ? void 0 : resolveNextRender(render);
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
Profiled.renders.push({
|
|
52
|
+
phase: "snapshotError",
|
|
53
|
+
count: Profiled.renders.length,
|
|
54
|
+
error: error,
|
|
55
|
+
});
|
|
56
|
+
rejectNextRender === null || rejectNextRender === void 0 ? void 0 : rejectNextRender(error);
|
|
57
|
+
}
|
|
58
|
+
finally {
|
|
59
|
+
nextRender = resolveNextRender = rejectNextRender = undefined;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
var iteratorPosition = 0;
|
|
63
|
+
var Profiled = Object.assign(function (props) { return (React.createElement(React.Profiler, { id: "test", onRender: profilerOnRender },
|
|
64
|
+
React.createElement(Component, __assign({}, props)))); }, {
|
|
65
|
+
updateSnapshot: updateSnapshot,
|
|
66
|
+
}, {
|
|
67
|
+
renders: new Array(),
|
|
68
|
+
currentRenderCount: function () {
|
|
69
|
+
return Profiled.renders.length;
|
|
70
|
+
},
|
|
71
|
+
peekRender: function (options) {
|
|
72
|
+
if (options === void 0) { options = {}; }
|
|
73
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
74
|
+
var render_1, render;
|
|
75
|
+
var _a;
|
|
76
|
+
return __generator(this, function (_b) {
|
|
77
|
+
if (iteratorPosition < Profiled.renders.length) {
|
|
78
|
+
render_1 = Profiled.renders[iteratorPosition];
|
|
79
|
+
if (render_1.phase === "snapshotError") {
|
|
80
|
+
throw render_1.error;
|
|
81
|
+
}
|
|
82
|
+
return [2, render_1];
|
|
83
|
+
}
|
|
84
|
+
render = Profiled.waitForNextRender(__assign((_a = {}, _a[_stackTrace] = captureStackTrace(Profiled.peekRender), _a), options));
|
|
85
|
+
return [2, render];
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
},
|
|
89
|
+
takeRender: function (options) {
|
|
90
|
+
if (options === void 0) { options = {}; }
|
|
91
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
92
|
+
var error, e_1;
|
|
93
|
+
var _a;
|
|
94
|
+
return __generator(this, function (_b) {
|
|
95
|
+
switch (_b.label) {
|
|
96
|
+
case 0:
|
|
97
|
+
error = undefined;
|
|
98
|
+
_b.label = 1;
|
|
99
|
+
case 1:
|
|
100
|
+
_b.trys.push([1, 3, 4, 5]);
|
|
101
|
+
return [4, Profiled.peekRender(__assign((_a = {}, _a[_stackTrace] = captureStackTrace(Profiled.takeRender), _a), options))];
|
|
102
|
+
case 2: return [2, _b.sent()];
|
|
103
|
+
case 3:
|
|
104
|
+
e_1 = _b.sent();
|
|
105
|
+
error = e_1;
|
|
106
|
+
throw e_1;
|
|
107
|
+
case 4:
|
|
108
|
+
if (!(error && error instanceof WaitForRenderTimeoutError)) {
|
|
109
|
+
iteratorPosition++;
|
|
110
|
+
}
|
|
111
|
+
return [7];
|
|
112
|
+
case 5: return [2];
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
},
|
|
117
|
+
getCurrentRender: function () {
|
|
118
|
+
if (!currentRender) {
|
|
119
|
+
throw new Error("Has not been rendered yet!");
|
|
120
|
+
}
|
|
121
|
+
return currentRender;
|
|
122
|
+
},
|
|
123
|
+
takeUntilRenderCount: function (count, optionsPerRender) {
|
|
124
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
125
|
+
return __generator(this, function (_a) {
|
|
126
|
+
switch (_a.label) {
|
|
127
|
+
case 0:
|
|
128
|
+
if (!(Profiled.renders.length < count)) return [3, 2];
|
|
129
|
+
return [4, Profiled.takeRender(optionsPerRender)];
|
|
130
|
+
case 1:
|
|
131
|
+
_a.sent();
|
|
132
|
+
return [3, 0];
|
|
133
|
+
case 2: return [2];
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
},
|
|
138
|
+
waitForNextRender: function (_a) {
|
|
139
|
+
var _b = _a === void 0 ? {} : _a, _c = _b.timeout, timeout = _c === void 0 ? 1000 : _c, _d = _stackTrace, _e = _b[_d], stackTrace = _e === void 0 ? captureStackTrace(Profiled.waitForNextRender) : _e;
|
|
140
|
+
if (!nextRender) {
|
|
141
|
+
nextRender = Promise.race([
|
|
142
|
+
new Promise(function (resolve, reject) {
|
|
143
|
+
resolveNextRender = resolve;
|
|
144
|
+
rejectNextRender = reject;
|
|
145
|
+
}),
|
|
146
|
+
new Promise(function (_, reject) {
|
|
147
|
+
return setTimeout(function () {
|
|
148
|
+
return reject(applyStackTrace(new WaitForRenderTimeoutError(), stackTrace));
|
|
149
|
+
}, timeout);
|
|
150
|
+
}),
|
|
151
|
+
]);
|
|
152
|
+
}
|
|
153
|
+
return nextRender;
|
|
154
|
+
},
|
|
155
|
+
});
|
|
156
|
+
return Profiled;
|
|
157
|
+
}
|
|
158
|
+
var WaitForRenderTimeoutError = (function (_super) {
|
|
159
|
+
__extends(WaitForRenderTimeoutError, _super);
|
|
160
|
+
function WaitForRenderTimeoutError() {
|
|
161
|
+
var _newTarget = this.constructor;
|
|
162
|
+
var _this = _super.call(this, "Exceeded timeout waiting for next render.") || this;
|
|
163
|
+
Object.setPrototypeOf(_this, _newTarget.prototype);
|
|
164
|
+
return _this;
|
|
165
|
+
}
|
|
166
|
+
return WaitForRenderTimeoutError;
|
|
167
|
+
}(Error));
|
|
168
|
+
export { WaitForRenderTimeoutError };
|
|
169
|
+
export function profileHook(renderCallback) {
|
|
170
|
+
var returnValue;
|
|
171
|
+
var Component = function (props) {
|
|
172
|
+
ProfiledComponent.updateSnapshot(renderCallback(props));
|
|
173
|
+
return null;
|
|
174
|
+
};
|
|
175
|
+
var ProfiledComponent = profile({
|
|
176
|
+
Component: Component,
|
|
177
|
+
onRender: function () { return returnValue; },
|
|
178
|
+
});
|
|
179
|
+
return Object.assign(function ProfiledHook(props) {
|
|
180
|
+
return React.createElement(ProfiledComponent, __assign({}, props));
|
|
181
|
+
}, {
|
|
182
|
+
ProfiledComponent: ProfiledComponent,
|
|
183
|
+
}, {
|
|
184
|
+
renders: ProfiledComponent.renders,
|
|
185
|
+
currentSnapshotCount: ProfiledComponent.currentRenderCount,
|
|
186
|
+
peekSnapshot: function (options) {
|
|
187
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
188
|
+
return __generator(this, function (_a) {
|
|
189
|
+
switch (_a.label) {
|
|
190
|
+
case 0: return [4, ProfiledComponent.peekRender(options)];
|
|
191
|
+
case 1: return [2, (_a.sent()).snapshot];
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
});
|
|
195
|
+
},
|
|
196
|
+
takeSnapshot: function (options) {
|
|
197
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
198
|
+
return __generator(this, function (_a) {
|
|
199
|
+
switch (_a.label) {
|
|
200
|
+
case 0: return [4, ProfiledComponent.takeRender(options)];
|
|
201
|
+
case 1: return [2, (_a.sent()).snapshot];
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
});
|
|
205
|
+
},
|
|
206
|
+
getCurrentSnapshot: function () {
|
|
207
|
+
return ProfiledComponent.getCurrentRender().snapshot;
|
|
208
|
+
},
|
|
209
|
+
takeUntilSnapshotCount: ProfiledComponent.takeUntilRenderCount,
|
|
210
|
+
waitForNextSnapshot: function (options) {
|
|
211
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
212
|
+
return __generator(this, function (_a) {
|
|
213
|
+
switch (_a.label) {
|
|
214
|
+
case 0: return [4, ProfiledComponent.waitForNextRender(options)];
|
|
215
|
+
case 1: return [2, (_a.sent()).snapshot];
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
});
|
|
219
|
+
},
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
//# sourceMappingURL=profile.js.map
|