Skip to content

Latest commit

 

History

History
178 lines (151 loc) · 4.58 KB

api-report.md

File metadata and controls

178 lines (151 loc) · 4.58 KB

API Report File for "@backstage/test-utils"

Do not edit this file. It is a report generated by API Extractor.

import { AnalyticsApi } from '@backstage/core-plugin-api';
import { AnalyticsEvent } from '@backstage/core-plugin-api';
import { ApiHolder } from '@backstage/core-plugin-api';
import { ApiRef } from '@backstage/core-plugin-api';
import { ComponentType } from 'react';
import { ErrorApi } from '@backstage/core-plugin-api';
import { ErrorApiError } from '@backstage/core-plugin-api';
import { ErrorApiErrorContext } from '@backstage/core-plugin-api';
import { ExternalRouteRef } from '@backstage/core-plugin-api';
import { Observable } from '@backstage/types';
import { ReactElement } from 'react';
import { ReactNode } from 'react';
import { RenderResult } from '@testing-library/react';
import { RouteRef } from '@backstage/core-plugin-api';
import { StorageApi } from '@backstage/core-plugin-api';
import { StorageValueChange } from '@backstage/core-plugin-api';

// @public
export type AsyncLogCollector = () => Promise<void>;

// @public
export type CollectedLogs<T extends LogFuncs> = {
  [key in T]: string[];
};

// @public
export type ErrorWithContext = {
  error: ErrorApiError;
  context?: ErrorApiErrorContext;
};

// @public
export type LogCollector = AsyncLogCollector | SyncLogCollector;

// @public
export type LogFuncs = 'log' | 'warn' | 'error';

// @public
export class MockAnalyticsApi implements AnalyticsApi {
  // (undocumented)
  captureEvent(event: AnalyticsEvent): void;
  // (undocumented)
  getEvents(): AnalyticsEvent[];
}

// @public
export function mockBreakpoint(options: { matches: boolean }): void;

// @public
export class MockErrorApi implements ErrorApi {
  constructor(options?: MockErrorApiOptions);
  // (undocumented)
  error$(): Observable<{
    error: ErrorApiError;
    context?: ErrorApiErrorContext;
  }>;
  // (undocumented)
  getErrors(): ErrorWithContext[];
  // (undocumented)
  post(error: ErrorApiError, context?: ErrorApiErrorContext): void;
  // (undocumented)
  waitForError(pattern: RegExp, timeoutMs?: number): Promise<ErrorWithContext>;
}

// @public
export type MockErrorApiOptions = {
  collect?: boolean;
};

// @public
export class MockStorageApi implements StorageApi {
  // (undocumented)
  static create(data?: MockStorageBucket): MockStorageApi;
  // (undocumented)
  forBucket(name: string): StorageApi;
  // (undocumented)
  get<T>(key: string): T | undefined;
  // (undocumented)
  observe$<T>(key: string): Observable<StorageValueChange<T>>;
  // (undocumented)
  remove(key: string): Promise<void>;
  // (undocumented)
  set<T>(key: string, data: T): Promise<void>;
}

// @public
export type MockStorageBucket = {
  [key: string]: any;
};

// @public @deprecated (undocumented)
export const msw: {
  setupDefaultHandlers: (worker: {
    listen: (t: any) => void;
    close: () => void;
    resetHandlers: () => void;
  }) => void;
};

// @public
export function renderInTestApp(
  Component: ComponentType | ReactNode,
  options?: TestAppOptions,
): Promise<RenderResult>;

// @public
export function renderWithEffects(nodes: ReactElement): Promise<RenderResult>;

// @public
export function setupRequestMockHandlers(worker: {
  listen: (t: any) => void;
  close: () => void;
  resetHandlers: () => void;
}): void;

// @public
export type SyncLogCollector = () => void;

// @public
export const TestApiProvider: <T extends any[]>(
  props: TestApiProviderProps<T>,
) => JSX.Element;

// @public
export type TestApiProviderProps<TApiPairs extends any[]> = {
  apis: readonly [...TestApiProviderPropsApiPairs<TApiPairs>];
  children: ReactNode;
};

// @public
export class TestApiRegistry implements ApiHolder {
  static from<TApiPairs extends any[]>(
    ...apis: readonly [...TestApiProviderPropsApiPairs<TApiPairs>]
  ): TestApiRegistry;
  get<T>(api: ApiRef<T>): T | undefined;
}

// @public
export type TestAppOptions = {
  routeEntries?: string[];
  mountedRoutes?: {
    [path: string]: RouteRef | ExternalRouteRef;
  };
};

// @public
export function withLogCollector(
  callback: AsyncLogCollector,
): Promise<CollectedLogs<LogFuncs>>;

// @public
export function withLogCollector(
  callback: SyncLogCollector,
): CollectedLogs<LogFuncs>;

// @public
export function withLogCollector<T extends LogFuncs>(
  logsToCollect: T[],
  callback: AsyncLogCollector,
): Promise<CollectedLogs<T>>;

// @public
export function withLogCollector<T extends LogFuncs>(
  logsToCollect: T[],
  callback: SyncLogCollector,
): CollectedLogs<T>;

// @public
export function wrapInTestApp(
  Component: ComponentType | ReactNode,
  options?: TestAppOptions,
): ReactElement;