import '@devvit/shared-types/polyfill/fetch.polyfill.js'; import { TelemetryMock } from '@devvit/analytics/server/reddit/test'; import { MediaMock } from '@devvit/media/test'; import { NotificationsMock } from '@devvit/notifications/test'; import { RealtimeMock } from '@devvit/realtime/server/test'; import { RedditPluginMock } from '@devvit/reddit/test'; import { RedisMock } from '@devvit/redis/test'; import { SchedulerMock } from '@devvit/scheduler/test'; import { SettingsMock } from '@devvit/settings/test'; import type { Config } from '@devvit/shared-types/Config.js'; import { Header } from '@devvit/shared-types/Header.js'; import type { AppConfig } from '@devvit/shared-types/schemas/config-file.v1.js'; import type { T2, T5 } from '@devvit/shared-types/tid.js'; import type { TestAPI } from 'vitest'; import { HTTPMock } from '../mocks/http/httpMock.js'; export type DevvitFixtures = { /** * The Devvit configuration object for the current test context. */ config: Config; /** * Request headers simulating a real Devvit execution environment. */ headers: { [key in Header]?: string; }; /** * App settings configured for this test instance. * Can be customized via `createDevvitTest({ settings: ... })`. */ settings: { [key: string]: string | number | boolean | string[] | undefined; }; /** * The username of the simulated user executing the app. * @default 'testuser' */ username: string; /** * The user ID (t2_*) of the simulated user. * @default 't2_testuser' */ userId: T2; /** * The name of the subreddit where the app is running. * @default 'testsub' */ subredditName: string; /** * The subreddit ID (t5_*) where the app is running. * @default 't5_testsub' */ subredditId: T5; /** * Direct access to mock implementations of Devvit capabilities. * Use these to inspect state or configure specific mock behaviors. */ mocks: { media: MediaMock; redis: RedisMock; http: HTTPMock; reddit: RedditPluginMock; realtime: RealtimeMock; settings: SettingsMock; scheduler: SchedulerMock; notifications: NotificationsMock; telemetry: TelemetryMock; }; }; export type DevvitTestConfig = { /** * The username of the simulated user. * @default 'testuser' */ username?: string; /** * The user ID (t2_*) of the simulated user. * @default 't2_testuser' */ userId?: T2; /** * The name of the subreddit where the app is running. * @default 'testsub' */ subredditName?: string; /** * The subreddit ID (t5_*) where the app is running. * @default 't5_testsub' */ subredditId?: T5; /** * Pre-configured app settings to be available via `context.settings`. Use to set * settings for use with the `@devvit/settings` capability to make it easier to test. */ settings?: { [key: string]: string | number | boolean | string[] | undefined; }; /** * Custom AppConfig to use for the test environment. For internal use. */ appConfig?: AppConfig; }; /** * Creates a test runner with customized Devvit environment. * * @example * const test = createDevvitTest({ * username: 'moderator_bob', * settings: { enable_ban_hammer: true } * }); * * test('mod action works', async ({ config, headers }) => { * // ... * }); */ export declare const createDevvitTest: (config?: DevvitTestConfig) => TestAPI; //# sourceMappingURL=devvitTest.d.ts.map