Create tests

From Melvynx/benchmarks · View interactive version

Create tests is an AI agent skill from the GitHub repository Melvynx/benchmarks. This skill should be used when the user asks to "create tests", "write tests", "add unit tests", "add e2e tests", "test this component", or mentions testing, Vitest, Playwright, or test coverage. Covers unit tests with Vitest and e2e tests with Playwright including organization logic.

How to use this skill

Skill file

<objective>

Create comprehensive tests for NowStack application using Vitest for unit tests and Playwright for e2e tests. Ensure proper mocking, organization logic handling, and test data management.

</objective>

<quick_start>

<unit_test>

Create unit test in __tests__/ directory:

import { describe, expect, it, vi } from "vitest";
import { screen, waitFor } from "@testing-library/react";
import { setup } from "@test/setup";

describe("ComponentName", () => {
  it("should render correctly", async () => {
    const { user } = setup(<ComponentName />);

    expect(screen.getByText("Expected Text")).toBeInTheDocument();
  });
});

Run: pnpm test:ci

</unit_test>

<e2e_test>

Create e2e test in e2e/ directory:

import { expect, test } from "@playwright/test";
import { createTestAccount } from "./utils/auth-test";

test("user flow description", async ({ page }) => {
  const userData = await createTestAccount({
    page,
    callbackURL: "/orgs",
  });

  await page.waitForURL(/\/orgs\/.*/);
  expect(page.url()).toMatch(/\/orgs\/.*/);
});

Run: pnpm test:e2e:ci

</e2e_test>

</quick_start>

<test_commands>

CRITICAL - Always use CI commands:

NEVER use interactive commands (pnpm test, pnpm test:e2e)

</test_commands>

<directory_structure>

nowts/
├── __tests__/           # Unit tests (Vitest)
├── e2e/                 # E2E tests (Playwright)
│   └── utils/           # E2E helpers
├── test/
│   ├── vitest.setup.ts  # Global mocks
│   └── setup.tsx        # Render helper

</directory_structure>

<when_to_use_which>

| Test Type | Use For | Location |

|-----------|---------|----------|

| Unit | Utilities, components, stores, Convex-adjacent helpers | __tests__/ |

| E2E | User flows, auth, organization workflows | e2e/ |

Unit tests: Fast, isolated, mock dependencies

E2E tests: Real browser, real database, full user journeys

</when_to_use_which>

<mocking_patterns>

Global mocks available in test/vitest.setup.ts (no Prisma — backend is Convex):

</mocking_patterns>

<reference_guides>

For detailed patterns and complete examples:

</reference_guides>

<success_criteria>

</success_criteria>

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.