Google Antigravity Directory

The #1 directory for Google Antigravity prompts, rules, workflows & MCP servers. Optimized for Gemini 3 agentic development.

Resources

PromptsMCP ServersAntigravity RulesGEMINI.md GuideBest Practices

Company

Submit PromptAntigravityAI.directory

Popular Prompts

Next.js 14 App RouterReact TypeScriptTypeScript AdvancedFastAPI GuideDocker Best Practices

Legal

Privacy PolicyTerms of ServiceContact Us
Featured on FazierFeatured on WayfindioAntigravity AI - Featured on Startup FameFeatured on Wired BusinessFeatured on Twelve ToolsListed on Turbo0Featured on findly.toolsFeatured on Aura++That App ShowAI ToolzShinyLaunchMillion Dot HomepageSolver ToolsFeatured on FazierFeatured on WayfindioAntigravity AI - Featured on Startup FameFeatured on Wired BusinessFeatured on Twelve ToolsListed on Turbo0Featured on findly.toolsFeatured on Aura++That App ShowAI ToolzShinyLaunchMillion Dot HomepageSolver Tools

© 2026 Antigravity AI Directory. All rights reserved.

The #1 directory for Google Antigravity IDE

This website is not affiliated with, endorsed by, or associated with Google LLC. "Google" and "Gemini" are trademarks of Google LLC.

Antigravity AI Directory
PromptsMCPBest PracticesUse CasesLearn
Home
Prompts
Testing Patterns Guide

Testing Patterns Guide

Comprehensive testing patterns for unit, integration, and E2E tests in Google Antigravity projects

testingvitestjestreact-testing-library
by antigravity-team
⭐0Stars
.antigravity
# Testing Patterns Guide for Google Antigravity

Master comprehensive testing strategies that ensure code quality and reliability in your Google Antigravity IDE projects.

## Unit Testing Configuration

```typescript
// vitest.config.ts - Google Antigravity optimized
import { defineConfig } from "vitest/config";
import react from "@vitejs/plugin-react";
import tsconfigPaths from "vite-tsconfig-paths";

export default defineConfig({
  plugins: [react(), tsconfigPaths()],
  test: {
    environment: "jsdom",
    globals: true,
    setupFiles: ["./src/test/setup.ts"],
    include: ["**/*.{test,spec}.{ts,tsx}"],
    coverage: {
      provider: "v8",
      reporter: ["text", "json", "html"],
      exclude: ["node_modules/", "src/test/"],
      thresholds: {
        global: { branches: 80, functions: 80, lines: 80, statements: 80 }
      }
    },
    mockReset: true,
    restoreMocks: true
  }
});
```

## Component Testing Patterns

```typescript
// src/components/__tests__/UserProfile.test.tsx
import { render, screen, waitFor } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { describe, it, expect, vi, beforeEach } from "vitest";
import { UserProfile } from "../UserProfile";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";

const createWrapper = () => {
  const queryClient = new QueryClient({
    defaultOptions: { queries: { retry: false } }
  });
  return ({ children }: { children: React.ReactNode }) => (
    <QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
  );
};

describe("UserProfile", () => {
  const mockUser = { id: "1", name: "John Doe", email: "john@example.com" };

  beforeEach(() => {
    vi.clearAllMocks();
  });

  it("renders user information correctly", async () => {
    render(<UserProfile userId="1" />, { wrapper: createWrapper() });
    
    await waitFor(() => {
      expect(screen.getByText(mockUser.name)).toBeInTheDocument();
      expect(screen.getByText(mockUser.email)).toBeInTheDocument();
    });
  });

  it("handles edit mode toggle", async () => {
    const user = userEvent.setup();
    render(<UserProfile userId="1" />, { wrapper: createWrapper() });
    
    await user.click(screen.getByRole("button", { name: /edit/i }));
    expect(screen.getByRole("textbox", { name: /name/i })).toBeInTheDocument();
  });

  it("submits form with updated data", async () => {
    const user = userEvent.setup();
    const onUpdate = vi.fn();
    render(<UserProfile userId="1" onUpdate={onUpdate} />, { wrapper: createWrapper() });
    
    await user.click(screen.getByRole("button", { name: /edit/i }));
    await user.clear(screen.getByRole("textbox", { name: /name/i }));
    await user.type(screen.getByRole("textbox", { name: /name/i }), "Jane Doe");
    await user.click(screen.getByRole("button", { name: /save/i }));
    
    await waitFor(() => {
      expect(onUpdate).toHaveBeenCalledWith(expect.objectContaining({ name: "Jane Doe" }));
    });
  });
});
```

## Integration Testing

```typescript
// src/api/__tests__/userApi.integration.test.ts
import { describe, it, expect, beforeAll, afterAll } from "vitest";
import { createTestServer } from "../test/server";
import { userApi } from "../userApi";

describe("User API Integration", () => {
  let server: ReturnType<typeof createTestServer>;

  beforeAll(async () => {
    server = createTestServer();
    await server.start();
  });

  afterAll(async () => {
    await server.stop();
  });

  it("creates and retrieves a user", async () => {
    const newUser = { name: "Test User", email: "test@example.com" };
    const created = await userApi.create(newUser);
    
    expect(created.id).toBeDefined();
    expect(created.name).toBe(newUser.name);
    
    const retrieved = await userApi.getById(created.id);
    expect(retrieved).toEqual(created);
  });

  it("handles concurrent operations", async () => {
    const operations = Array.from({ length: 10 }, (_, i) =>
      userApi.create({ name: `User ${i}`, email: `user${i}@example.com` })
    );
    
    const results = await Promise.all(operations);
    expect(results).toHaveLength(10);
    expect(new Set(results.map(r => r.id)).size).toBe(10);
  });
});
```

## Mock Strategies

```typescript
// src/test/mocks/handlers.ts
import { http, HttpResponse } from "msw";

export const handlers = [
  http.get("/api/users/:id", ({ params }) => {
    return HttpResponse.json({
      id: params.id,
      name: "Mock User",
      email: "mock@example.com"
    });
  }),
  
  http.post("/api/users", async ({ request }) => {
    const body = await request.json();
    return HttpResponse.json({ id: crypto.randomUUID(), ...body }, { status: 201 });
  }),
  
  http.delete("/api/users/:id", () => {
    return new HttpResponse(null, { status: 204 });
  })
];
```

## Best Practices

1. **Arrange-Act-Assert pattern** for clear test structure
2. **Test behavior, not implementation** details
3. **Use factory functions** for test data creation
4. **Isolate tests** with proper setup and teardown
5. **Mock external dependencies** at the boundary
6. **Write descriptive test names** that explain intent
7. **Maintain test coverage thresholds** for quality gates

Google Antigravity leverages these patterns to provide intelligent test generation and refactoring suggestions throughout your development workflow.

When to Use This Prompt

This testing prompt is ideal for developers working on:

  • testing applications requiring modern best practices and optimal performance
  • Projects that need production-ready testing code with proper error handling
  • Teams looking to standardize their testing development workflow
  • Developers wanting to learn industry-standard testing patterns and techniques

By using this prompt, you can save hours of manual coding and ensure best practices are followed from the start. It's particularly valuable for teams looking to maintain consistency across their testing implementations.

How to Use

  1. Copy the prompt - Click the copy button above to copy the entire prompt to your clipboard
  2. Paste into your AI assistant - Use with Claude, ChatGPT, Cursor, or any AI coding tool
  3. Customize as needed - Adjust the prompt based on your specific requirements
  4. Review the output - Always review generated code for security and correctness
💡 Pro Tip: For best results, provide context about your project structure and any specific constraints or preferences you have.

Best Practices

  • ✓ Always review generated code for security vulnerabilities before deploying
  • ✓ Test the testing code in a development environment first
  • ✓ Customize the prompt output to match your project's coding standards
  • ✓ Keep your AI assistant's context window in mind for complex requirements
  • ✓ Version control your prompts alongside your code for reproducibility

Frequently Asked Questions

Can I use this testing prompt commercially?

Yes! All prompts on Antigravity AI Directory are free to use for both personal and commercial projects. No attribution required, though it's always appreciated.

Which AI assistants work best with this prompt?

This prompt works excellently with Claude, ChatGPT, Cursor, GitHub Copilot, and other modern AI coding assistants. For best results, use models with large context windows.

How do I customize this prompt for my specific needs?

You can modify the prompt by adding specific requirements, constraints, or preferences. For testing projects, consider mentioning your framework version, coding style, and any specific libraries you're using.

Related Prompts

💬 Comments

Loading comments...