import { CLITelemetryStore } from "@sanity/cli-core/types"; import { Mock } from "vitest"; import { SpinnerInstance } from "@sanity/cli-core/ux"; /** * Creates a mock HTTP server for testing. * * @returns A mock HTTP server object with emit and once methods * @internal */ export declare function createMockHttpServer(): { emit(event: string, ...args: unknown[]): void; once(event: string, listener: (...args: unknown[]) => void): void; }; /** * Creates a mock spinner function to avoid writing output to stdout. * @param overrides - Pass any mocks or stubs for test expectations * @internal * @deprecated Use mocks/cli-core/ux/spinner instead */ export declare function createMockSpinner( overrides?: Partial, ): Mock<(options: string) => SpinnerInstance>; /** * Creates a mock Vite watcher for testing. * * @returns A mock watcher object with add, emit, and on methods * @internal */ export declare function createMockWatcher(): MockWatcher; /** * Creates a test token for the Sanity CLI * * @public * * @param token - The token to create * @returns void */ export declare function createTestToken(token: string): void; /** * Default fixtures bundled with the package and their options. * * @public */ export declare const DEFAULT_FIXTURES: Record; /** * @deprecated Use {@link FixtureName} instead. This type alias will be removed in a future release. * @public */ export declare type ExampleName = FixtureName; /** * Valid fixture name type. * @public */ export declare type FixtureName = | "basic-app" | "basic-functions" | "basic-studio" | "federated-studio" | "graphql-studio" | "multi-workspace-studio" | "nextjs-app" | "prebuilt-app" | "prebuilt-studio" | "worst-case-studio"; /** * Options for each fixture. * @public */ export declare interface FixtureOptions { includeDist?: boolean; } /** * @public * @param options - Options for mocking the telemetry store. * @returns The mocked telemetry store. */ export declare const mockTelemetry: ( options?: MockTelemetryOptions, ) => CLITelemetryStore; /** * @public */ export declare interface MockTelemetryOptions { trace?: () => void; updateUserProperties?: () => void; } /** * @internal */ export declare interface MockWatcher { add: Mock; emit: (event: string, ...args: unknown[]) => void; on: (event: string, listener: (...args: unknown[]) => void) => void; } /** * Serializer for snapshot tests to normalize line endings and Windows ^ to Unix `\` * @public */ export declare const snapshotSerializer: { serialize: (val: string) => string; test: (val: unknown) => val is string; }; /** * Recursively copy a directory, skipping specified folders. * * @param srcDir - Source directory to copy from * @param destDir - Destination directory to copy to * @param skip - Array of directory/file names to skip (e.g., ['node_modules', 'dist']) * @internal */ export declare function testCopyDirectory( srcDir: string, destDir: string, skip?: string[], ): Promise; /** * @deprecated Use {@link testFixture} instead. This function will be removed in a future release. * * Clones an example (now called fixture) directory into a temporary directory with an isolated copy. * * @param exampleName - The name of the example/fixture to clone (e.g., 'basic-app', 'basic-studio') * @param options - Configuration options * @returns The absolute path to the temporary directory containing the example/fixture * * @public */ export declare function testExample( exampleName: FixtureName | (string & {}), options?: TestFixtureOptions, ): Promise; /** * @deprecated Use {@link TestFixtureOptions} instead. This type alias will be removed in a future release. * @public */ export declare type TestExampleOptions = TestFixtureOptions; /** * Clones a fixture directory into a temporary directory with an isolated copy. * * The function creates a unique temporary copy of the specified fixture with: * - A random unique ID to avoid conflicts between parallel tests * - Symlinked node_modules for performance (from the global setup version) * - Modified package.json name to prevent conflicts * * The fixture is first looked up in the temp directory (if global setup ran), * otherwise it falls back to the bundled fixtures in the package. * * @param fixtureName - The name of the fixture to clone (e.g., 'basic-app', 'basic-studio') * @param options - Configuration options * @returns The absolute path to the temporary directory containing the fixture * * @public * * @example * ```typescript * import {testFixture} from '@sanity/cli-test' * import {describe, test} from 'vitest' * * describe('my test suite', () => { * test('should work with basic-studio', async () => { * const cwd = await testFixture('basic-studio') * // ... run your tests in this directory * }) * }) * ``` */ export declare function testFixture( fixtureName: FixtureName | (string & {}), options?: TestFixtureOptions, ): Promise; /** * @public */ export declare interface TestFixtureOptions { /** * Custom temp directory. Defaults to process.cwd()/tmp (or the OS temp directory when * `useSystemTmp` is true). */ tempDir?: string; /** * Use the OS temp directory instead of cwd/tmp. Avoids monorepo workspace detection by * package managers and git when tests run inside a monorepo. Ignored when `tempDir` is set. */ useSystemTmp?: boolean; } export {};