From 2bf91c1409d810dc1502d8d7a848b442a6220bc3 Mon Sep 17 00:00:00 2001 From: Lenz Weber-Tronic Date: Wed, 9 Oct 2024 17:21:00 +0200 Subject: [PATCH] rename `createProfiler` to `createRenderStream` --- src/index.ts | 2 +- src/profile/Render.tsx | 7 ++----- src/profile/profile.tsx | 6 ++---- src/renderHookToSnapshotStream.ts | 6 ++---- src/renderToRenderStream.ts | 4 ++-- 5 files changed, 9 insertions(+), 16 deletions(-) diff --git a/src/index.ts b/src/index.ts index 073fb9aef..a1242eaaa 100644 --- a/src/index.ts +++ b/src/index.ts @@ -4,7 +4,7 @@ export type { RenderStreamWithRenderFn, } from "./profile/profile.js"; export { - createProfiler, + createRenderStream, useTrackRenders, WaitForRenderTimeoutError, } from "./profile/profile.js"; diff --git a/src/profile/Render.tsx b/src/profile/Render.tsx index f5d16476a..b3d1d566b 100644 --- a/src/profile/Render.tsx +++ b/src/profile/Render.tsx @@ -13,7 +13,6 @@ import { within, screen } from "@testing-library/dom"; import { JSDOM, VirtualConsole } from "jsdom"; import { applyStackTrace, captureStackTrace } from "./traces.js"; -/** @internal */ export interface BaseRender { id: string; phase: "mount" | "update" | "nested-update"; @@ -28,7 +27,7 @@ export interface BaseRender { } type Screen = typeof screen; -/** @internal */ + export type SyncScreen = { [K in keyof Screen]: K extends `find${string}` ? { @@ -38,7 +37,6 @@ export type SyncScreen = { : Screen[K]; }; -/** @internal */ export interface Render extends BaseRender { /** * The snapshot, as returned by the `takeSnapshot` option of `profile`. @@ -66,7 +64,6 @@ export interface Render extends BaseRender { renderedComponents: Array; } -/** @internal */ export class RenderInstance implements Render { id: string; phase: "mount" | "update" | "nested-update"; @@ -138,7 +135,7 @@ export class RenderInstance implements Render { return () => snapScreen; } } -/** @internal */ + export function errorOnDomInteraction() { const events: Array = [ "auxclick", diff --git a/src/profile/profile.tsx b/src/profile/profile.tsx index 0899b3d98..73e3572a5 100644 --- a/src/profile/profile.tsx +++ b/src/profile/profile.tsx @@ -15,7 +15,7 @@ export type ValidSnapshot = /** only used for passing around data internally */ const _stackTrace = Symbol(); -/** @internal */ + export interface NextRenderOptions { timeout?: number; [_stackTrace]?: string; @@ -104,8 +104,7 @@ export type ProfilerOptions = { skipNonTrackingRenders?: boolean; }; -/** @internal */ -export function createProfiler({ +export function createRenderStream({ onRender, snapshotDOM = false, initialSnapshot, @@ -349,7 +348,6 @@ export function createProfiler({ return Profiler; } -/** @internal */ export class WaitForRenderTimeoutError extends Error { constructor() { super("Exceeded timeout waiting for next render."); diff --git a/src/renderHookToSnapshotStream.ts b/src/renderHookToSnapshotStream.ts index 49465ca0d..b3295ea06 100644 --- a/src/renderHookToSnapshotStream.ts +++ b/src/renderHookToSnapshotStream.ts @@ -1,15 +1,13 @@ import { RenderHookOptions } from "@testing-library/react"; import { - createProfiler, + createRenderStream, NextRenderOptions, - ProfiledComponentFields, ValidSnapshot, } from "./profile/profile.js"; import { Render } from "./profile/Render.js"; import { createElement } from "react"; import { Assertable, assertableSymbol, markAssertable } from "./assertable.js"; -/** @internal */ export interface ProfiledHook extends Assertable { /** @@ -62,7 +60,7 @@ export function renderHookToSnapshotStream< renderCallback: (props: Props) => ReturnValue, { initialProps, ...options }: RenderHookOptions = {} ): HookSnapshotStream { - const { render, ...stream } = createProfiler(); + const { render, ...stream } = createRenderStream(); const ProfiledHook: React.FC = (props) => { stream.replaceSnapshot(renderCallback(props)); diff --git a/src/renderToRenderStream.ts b/src/renderToRenderStream.ts index e1fcc86a8..c9dd9e112 100644 --- a/src/renderToRenderStream.ts +++ b/src/renderToRenderStream.ts @@ -3,7 +3,7 @@ import { type RenderResult as BaseResult, } from "@testing-library/react"; import { - createProfiler, + createRenderStream, ProfiledComponentFields, ProfiledComponentOnlyFields, ProfilerOptions, @@ -33,7 +33,7 @@ export function renderToRenderStream( ...options }: RenderOptions = {} ): RenderResult { - const { render, ...stream } = createProfiler({ + const { render, ...stream } = createRenderStream({ onRender, snapshotDOM, initialSnapshot,