/** * Usage examples for common Vitest patterns */ /** * Example: Basic test with mocking */ export declare const basicTestExample = "\nimport { describe, it, expect, vi } from 'vitest';\nimport { UserService } from './user-service';\n\ndescribe('UserService', () => {\n it('should fetch user', async () => {\n const mockFetch = vi.fn().mockResolvedValue({\n json: async () => ({ id: 1, name: 'John' })\n });\n \n global.fetch = mockFetch;\n \n const service = new UserService();\n const user = await service.getUser(1);\n \n expect(user.name).toBe('John');\n expect(mockFetch).toHaveBeenCalledWith('/api/users/1');\n });\n});\n"; /** * Example: Using test-core builders */ export declare const builderExample = "\nimport { describe, it, expect } from 'vitest';\nimport { createBuilder, createFactory } from '@kitiumai/vitest-helpers';\n\ninterface User {\n id: number;\n name: string;\n email: string;\n}\n\ndescribe('User tests', () => {\n it('should create user with builder', () => {\n const user = createBuilder({ id: 1 })\n .set('name', 'John')\n .set('email', 'john@example.com')\n .build();\n \n expect(user.name).toBe('John');\n });\n \n it('should create multiple users with factory', () => {\n const userFactory = createFactory((seq) => ({\n id: seq,\n name: `User ${seq}`,\n email: `user${seq}@example.com`\n }));\n \n const users = userFactory.createMany(5);\n expect(users).toHaveLength(5);\n expect(users[0].id).toBe(1);\n });\n});\n"; /** * Example: HTTP mocking */ export declare const httpMockExample = "\nimport { describe, it, expect, beforeEach, afterEach } from 'vitest';\nimport { createHttpMockManager, HttpResponses } from '@kitiumai/vitest-helpers';\n\ndescribe('API tests', () => {\n const httpMock = createHttpMockManager();\n \n beforeEach(() => {\n httpMock.mockGet(\n /api\\/users\\/\\d+/,\n HttpResponses.ok({ id: 1, name: 'John' })\n );\n });\n \n afterEach(() => {\n httpMock.clear();\n });\n \n it('should mock API call', async () => {\n const response = await fetch('/api/users/1');\n const data = await response.json();\n \n expect(data.name).toBe('John');\n \n const requests = httpMock.getRequestsByUrl('api/users');\n expect(requests).toHaveLength(1);\n });\n});\n"; /** * Example: Async utilities */ export declare const asyncExample = "\nimport { describe, it, expect } from 'vitest';\nimport { waitFor, retry } from '@kitiumai/vitest-helpers';\n\ndescribe('Async operations', () => {\n it('should wait for condition', async () => {\n let value = false;\n \n setTimeout(() => { value = true; }, 100);\n \n await waitFor(() => value === true, { timeout: 1000 });\n \n expect(value).toBe(true);\n });\n \n it('should retry operation', async () => {\n let attempts = 0;\n \n const result = await retry(\n async () => {\n attempts++;\n if (attempts < 3) throw new Error('Not ready');\n return 'success';\n },\n { maxAttempts: 5, delay: 10 }\n );\n \n expect(result).toBe('success');\n expect(attempts).toBe(3);\n });\n});\n"; /** * Example: Using presets */ export declare const presetExample = "\n// vitest.config.ts\nimport { VitestPresets } from '@kitiumai/vitest-helpers';\n\nexport default VitestPresets.ci;\n\n// Or customize\nimport { createCustomPreset } from '@kitiumai/vitest-helpers';\n\nexport default createCustomPreset('development', {\n test: {\n coverage: {\n enabled: true,\n thresholds: {\n lines: 90\n }\n }\n }\n});\n"; /** * Example: Workspace configuration */ export declare const workspaceExample = "\n// vitest.workspace.ts\nimport { createMonorepoWorkspace } from '@kitiumai/vitest-helpers/setup';\n\nexport default createMonorepoWorkspace({\n packagePattern: 'packages/*/vitest.config.ts',\n shared: {\n coverage: {\n enabled: true,\n provider: 'v8'\n }\n }\n});\n"; /** * All examples */ export declare const examples: { basic: string; builder: string; httpMock: string; async: string; preset: string; workspace: string; }; //# sourceMappingURL=index.d.ts.map