Skip to content

Commit

Permalink
rename createProfiler to createRenderStream
Browse files Browse the repository at this point in the history
  • Loading branch information
phryneas committed Oct 9, 2024
1 parent a32bedc commit 2bf91c1
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export type {
RenderStreamWithRenderFn,
} from "./profile/profile.js";
export {
createProfiler,
createRenderStream,
useTrackRenders,
WaitForRenderTimeoutError,
} from "./profile/profile.js";
Expand Down
7 changes: 2 additions & 5 deletions src/profile/Render.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -28,7 +27,7 @@ export interface BaseRender {
}

type Screen = typeof screen;
/** @internal */

export type SyncScreen = {
[K in keyof Screen]: K extends `find${string}`
? {
Expand All @@ -38,7 +37,6 @@ export type SyncScreen = {
: Screen[K];
};

/** @internal */
export interface Render<Snapshot> extends BaseRender {
/**
* The snapshot, as returned by the `takeSnapshot` option of `profile`.
Expand Down Expand Up @@ -66,7 +64,6 @@ export interface Render<Snapshot> extends BaseRender {
renderedComponents: Array<string | React.ComponentType>;
}

/** @internal */
export class RenderInstance<Snapshot> implements Render<Snapshot> {
id: string;
phase: "mount" | "update" | "nested-update";
Expand Down Expand Up @@ -138,7 +135,7 @@ export class RenderInstance<Snapshot> implements Render<Snapshot> {
return () => snapScreen;
}
}
/** @internal */

export function errorOnDomInteraction() {
const events: Array<keyof DocumentEventMap> = [
"auxclick",
Expand Down
6 changes: 2 additions & 4 deletions src/profile/profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -104,8 +104,7 @@ export type ProfilerOptions<Snapshot extends ValidSnapshot> = {
skipNonTrackingRenders?: boolean;
};

/** @internal */
export function createProfiler<Snapshot extends ValidSnapshot = void>({
export function createRenderStream<Snapshot extends ValidSnapshot = void>({
onRender,
snapshotDOM = false,
initialSnapshot,
Expand Down Expand Up @@ -349,7 +348,6 @@ export function createProfiler<Snapshot extends ValidSnapshot = void>({
return Profiler;
}

/** @internal */
export class WaitForRenderTimeoutError extends Error {
constructor() {
super("Exceeded timeout waiting for next render.");
Expand Down
6 changes: 2 additions & 4 deletions src/renderHookToSnapshotStream.ts
Original file line number Diff line number Diff line change
@@ -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<Snapshot extends ValidSnapshot>
extends Assertable {
/**
Expand Down Expand Up @@ -62,7 +60,7 @@ export function renderHookToSnapshotStream<
renderCallback: (props: Props) => ReturnValue,
{ initialProps, ...options }: RenderHookOptions<Props> = {}
): HookSnapshotStream<Props, ReturnValue> {
const { render, ...stream } = createProfiler<ReturnValue>();
const { render, ...stream } = createRenderStream<ReturnValue>();

const ProfiledHook: React.FC<Props> = (props) => {
stream.replaceSnapshot(renderCallback(props));
Expand Down
4 changes: 2 additions & 2 deletions src/renderToRenderStream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
type RenderResult as BaseResult,
} from "@testing-library/react";
import {
createProfiler,
createRenderStream,
ProfiledComponentFields,
ProfiledComponentOnlyFields,
ProfilerOptions,
Expand Down Expand Up @@ -33,7 +33,7 @@ export function renderToRenderStream<Snapshot extends ValidSnapshot = void>(
...options
}: RenderOptions<Snapshot> = {}
): RenderResult<Snapshot> {
const { render, ...stream } = createProfiler<Snapshot>({
const { render, ...stream } = createRenderStream<Snapshot>({
onRender,
snapshotDOM,
initialSnapshot,
Expand Down

0 comments on commit 2bf91c1

Please sign in to comment.