|
1 | 1 | import type { MatcherFunction } from "expect";
|
2 | 2 | import { WaitForRenderTimeoutError } from "@testing-library/react-render-stream";
|
3 | 3 | import type {
|
| 4 | + Assertable, |
4 | 5 | NextRenderOptions,
|
5 |
| - Profiler, |
6 |
| - ProfiledComponent, |
7 |
| - ProfiledHook, |
| 6 | + RenderStream, |
8 | 7 | } from "@testing-library/react-render-stream";
|
| 8 | +// explicitly imported the symbol from the internal file |
| 9 | +// this will bundle the `Symbol.for` call twice, but we keep it private |
| 10 | +import { assertableSymbol } from "../assertable.js"; |
9 | 11 |
|
10 | 12 | export const toRerender: MatcherFunction<[options?: NextRenderOptions]> =
|
11 | 13 | async function (actual, options) {
|
12 |
| - const _profiler = actual as |
13 |
| - | Profiler<any> |
14 |
| - | ProfiledComponent<any, any> |
15 |
| - | ProfiledHook<any, any>; |
16 |
| - const profiler = "Profiler" in _profiler ? _profiler.Profiler : _profiler; |
| 14 | + const _profiler = actual as RenderStream<any> | Assertable; |
| 15 | + const profiler = |
| 16 | + assertableSymbol in _profiler ? _profiler[assertableSymbol] : _profiler; |
17 | 17 | const hint = this.utils.matcherHint("toRerender", "ProfiledComponent", "");
|
18 | 18 | let pass = true;
|
19 | 19 | try {
|
@@ -44,11 +44,9 @@ const failed = {};
|
44 | 44 | export const toRenderExactlyTimes: MatcherFunction<
|
45 | 45 | [times: number, options?: NextRenderOptions]
|
46 | 46 | > = async function (actual, times, optionsPerRender) {
|
47 |
| - const _profiler = actual as |
48 |
| - | Profiler<any> |
49 |
| - | ProfiledComponent<any, any> |
50 |
| - | ProfiledHook<any, any>; |
51 |
| - const profiler = "Profiler" in _profiler ? _profiler.Profiler : _profiler; |
| 47 | + const _profiler = actual as RenderStream<any> | Assertable; |
| 48 | + const profiler = |
| 49 | + assertableSymbol in _profiler ? _profiler[assertableSymbol] : _profiler; |
52 | 50 | const options = { timeout: 100, ...optionsPerRender };
|
53 | 51 | const hint = this.utils.matcherHint("toRenderExactlyTimes");
|
54 | 52 | let pass = true;
|
|
0 commit comments