# All files / src testUtils.tsx

68.18% Statements 30/44
100% Branches 5/5
57.14% Functions 4/7
68.18% Lines 30/44

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    451x
    1x
    1x
    1x
    1x
    1x
    1x
    8x
    8x
    8x
    8x
    8x
    8x
    8x
    8x
    8x
    8x
    8x
    8x
    1x
    1x

    1x
    1x
    8x
    8x
    8x
    8x
    8x
    8x
    8x
     import { render } from '@testing-library/react';
    import * as React from 'react';
    import { QueryClient, QueryClientProvider } from '@tanstack/react-query';

    export const testServer = 'http://localhost:55001/plone';

    const createTestQueryClient = () =>
      new QueryClient({
        defaultOptions: {
          queries: {
            retry: false,
          },
        },
        logger: {
          log: console.log,
          warn: console.warn,
          error: () => {},
        },
      });

    export function renderWithClient(ui: React.ReactElement) {
      const testQueryClient = createTestQueryClient();
      const { rerender, ...result } = render(
        <QueryClientProvider client={testQueryClient}>{ui}</QueryClientProvider>,
      );
      return {
        ...result,
        rerender: (rerenderUi: React.ReactElement) =>
          rerender(
            <QueryClientProvider client={testQueryClient}>
              {rerenderUi}
            </QueryClientProvider>,
          ),
      };
    }

    export function createWrapper() {
      const testQueryClient = createTestQueryClient();
      return ({ children }: { children: React.ReactNode }) => (
        <QueryClientProvider client={testQueryClient}>
          {children}
        </QueryClientProvider>
      );
    }