@@ -4745,20 +4978,26 @@ it("can subscribe to subscriptions and react to cache updates via `subscribeToMo
);
}
- const { user } = renderWithClient(
, { client, wrapper: Profiler });
+ const { user } = renderWithClient(
+
,
+ {
+ client,
+ },
+ renderStream
+ );
// initial render
- await Profiler.takeRender();
+ await renderStream.takeRender();
await act(() => user.click(screen.getByText("Load query")));
{
- const { renderedComponents } = await Profiler.takeRender();
+ const { renderedComponents } = await renderStream.takeRender();
expect(renderedComponents).toStrictEqual([App, SuspenseFallback]);
}
{
- const { renderedComponents, snapshot } = await Profiler.takeRender();
+ const { renderedComponents, snapshot } = await renderStream.takeRender();
expect(renderedComponents).toStrictEqual([ReadQueryHook]);
expect(snapshot.result).toEqual({
@@ -4775,7 +5014,7 @@ it("can subscribe to subscriptions and react to cache updates via `subscribeToMo
return { greeting: data.greetingUpdated };
});
- const { snapshot } = Profiler.getCurrentRender();
+ const { snapshot } = renderStream.getCurrentRender();
snapshot.subscribeToMore!({ document: subscription, updateQuery });
@@ -4788,7 +5027,7 @@ it("can subscribe to subscriptions and react to cache updates via `subscribeToMo
});
{
- const { snapshot, renderedComponents } = await Profiler.takeRender();
+ const { snapshot, renderedComponents } = await renderStream.takeRender();
expect(renderedComponents).toStrictEqual([ReadQueryHook]);
expect(snapshot.result).toEqual({
@@ -4844,7 +5083,7 @@ it("throws when calling `subscribeToMore` before loading the query", async () =>
const client = new ApolloClient({ link, cache: new InMemoryCache() });
- const Profiler = createProfiler({
+ const renderStream = createRenderStream({
initialSnapshot: {
subscribeToMore: null as SubscribeToMoreFunction<
SimpleCaseData,
@@ -4855,13 +5094,13 @@ it("throws when calling `subscribeToMore` before loading the query", async () =>
});
const { SuspenseFallback, ReadQueryHook } =
- createDefaultProfiledComponents(Profiler);
+ createDefaultProfiledComponents(renderStream);
function App() {
useTrackRenders();
const [loadQuery, queryRef, { subscribeToMore }] = useLoadableQuery(query);
- Profiler.mergeSnapshot({ subscribeToMore });
+ renderStream.mergeSnapshot({ subscribeToMore });
return (
@@ -4873,11 +5112,11 @@ it("throws when calling `subscribeToMore` before loading the query", async () =>
);
}
- renderWithClient(
, { client, wrapper: Profiler });
+ renderWithClient(
, { client }, renderStream);
// initial render
- await Profiler.takeRender();
+ await renderStream.takeRender();
- const { snapshot } = Profiler.getCurrentRender();
+ const { snapshot } = renderStream.getCurrentRender();
expect(() => {
snapshot.subscribeToMore!({ document: subscription });
diff --git a/src/react/hooks/__tests__/useMutation.test.tsx b/src/react/hooks/__tests__/useMutation.test.tsx
index da26fd2c87d..2e3d22856fd 100644
--- a/src/react/hooks/__tests__/useMutation.test.tsx
+++ b/src/react/hooks/__tests__/useMutation.test.tsx
@@ -31,7 +31,8 @@ import { useQuery } from "../useQuery";
import { useMutation } from "../useMutation";
import { BatchHttpLink } from "../../../link/batch-http";
import { FetchResult } from "../../../link/core";
-import { profileHook, spyOnConsole } from "../../../testing/internal";
+import { spyOnConsole } from "../../../testing/internal";
+import { renderHookToSnapshotStream } from "@testing-library/react-render-stream";
describe("useMutation Hook", () => {
interface Todo {
@@ -750,26 +751,24 @@ describe("useMutation Hook", () => {
},
];
- const ProfiledHook = profileHook(() =>
- useMutation<
- { createTodo: Todo },
- { priority: string; description: string }
- >(CREATE_TODO_MUTATION)
+ const { takeSnapshot } = renderHookToSnapshotStream(
+ () =>
+ useMutation<
+ { createTodo: Todo },
+ { priority: string; description: string }
+ >(CREATE_TODO_MUTATION),
+ {
+ wrapper: ({ children }) => (
+
{children}
+ ),
+ }
);
- render(
, {
- wrapper: ({ children }) => (
-
{children}
- ),
- });
-
- let createTodo: Awaited
>[0];
- let reset: Awaited<
- ReturnType
- >[1]["reset"];
+ let createTodo: Awaited>[0];
+ let reset: Awaited