Skip to content
Back to skills

Testing

ASecurity

- **Framework**: Jest 29/30 + ts-jest - **Files**: `*.test.ts` or `*.test.tsx` - **Command**: `pnpm turbo test`

  • 2 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 24, 2026
testingtypescriptgobashtestingapisecurity

Works with

  • cursor
  • cli
  • api
  • mcp

Security analysis

A100/100

Pro scans all 5 files and shows the line behind each finding

Scanned November 24, 2026

npx -y skills add iDorgham/Workspace-Factory --skill testing --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Testing?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Testing
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/idorgham-testing/badge)](https://www.skillsdirectory.com/skills/idorgham-testing)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
type: Skill
subagents: [core-validator, integrity-bot]
agents: [master-guide, swarm-router]
dependencies: [core-orchestration, global-sync]
version: 1.0.0
---



# Workspace Factory Testing

## Stack

- **Framework**: Jest 29/30 + ts-jest
- **Files**: `*.test.ts` or `*.test.tsx`
- **Command**: `pnpm turbo test`

## Commands

```bash
pnpm turbo test
pnpm turbo test --filter=client-dashboard
pnpm turbo test --filter=scanner-app
cd apps/client-dashboard && pnpm test --watch
pnpm turbo test -- --coverage
```

## Unit Test Template

```typescript
import { describe, it, expect, jest, beforeEach } from '@jest/globals';

describe('MyFunction', () => {
  beforeEach(() => jest.clearAllMocks());

  it('should handle valid input', () => {
    expect(myFunction('valid')).toBe('expected');
  });

  it('should throw on invalid input', () => {
    expect(() => myFunction('')).toThrow('Invalid input');
  });
});
```

## API Route Test

```typescript
jest.mock('@/lib/require-auth');
jest.mock('@gate-access/db', () => ({
  prisma: { gate: { findMany: jest.fn() } },
}));

describe('GET /api/gates', () => {
  it('returns gates for auth user', async () => {
    (requireAuth as jest.Mock).mockResolvedValue({ orgId: 'org1', role: 'TENANT_ADMIN' });
    (prisma.gate.findMany as jest.Mock).mockResolvedValue([{ id: 'g1', name: 'Gate' }]);

    const res = await GET(new Request('http://localhost/api/gates'));
    const data = await res.json();

    expect(data).toHaveLength(1);
    expect(prisma.gate.findMany).toHaveBeenCalledWith({
      where: { organizationId: 'org1', deletedAt: null },
    });
  });

  it('returns 401 when unauthenticated', async () => {
    (requireAuth as jest.Mock).mockResolvedValue(NextResponse.json({}, { status: 401 }));
    const res = await GET(new Request('http://localhost/api/gates'));
    expect(res.status).toBe(401);
  });
});
```

## Multi-Tenant Isolation Test

```typescript
it('only returns data for user org', async () => {
  await prisma.gate.createMany({
    data: [
      { name: 'Org1 Gate', organizationId: 'org1' },
      { name: 'Org2 Gate', organizationId: 'org2' },
    ],
  });

  const org1Gates = await getGatesForOrg('org1');
  expect(org1Gates).toHaveLength(1);
  expect(org1Gates[0].name).toBe('Org1 Gate');
});
```

## Mocking

```typescript
// Prisma
jest.mock('@gate-access/db', () => ({
  prisma: { model: { findMany: jest.fn(), create: jest.fn() } },
}));

// Auth
jest.mock('@/lib/require-auth', () => ({ requireAuth: jest.fn() }));

// Fetch
global.fetch = jest.fn(() =>
  Promise.resolve({ ok: true, json: () => Promise.resolve({}) })
) as jest.Mock;
```

## Coverage Goals

- Unit: 80%+
- Critical paths: 100%
- Security functions: 100%
- API routes: 80%+

## MCP: E2E Verification

When **cursor-ide-browser** MCP is enabled, use for:

- Login flow verification
- Navigation, filters, exports
- i18n checks (AR/EN, RTL)
- Screenshot capture for broken states

**Alternative:** browser-use subagent for complex multi-step flows.

**Templates:** `.antigravity/templates/TEMPLATE_API_test.md` (API tests), `TEMPLATE_E2E_flow.md` (E2E flow spec), `TEMPLATE_E2E_playwright.md` (Playwright).

**Reference:** `apps/client-dashboard/src/lib/*.test.ts`, `apps/scanner-app/src/lib/*.test.ts`

Files in this skill

  • core.py331 B
  • manifest.yaml162 B
  • skill.md3.2 KB
  • skill.md.meta.json781 B
  • tests/test_core.py275 B

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in testing →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.