senior-qa
Write and improve tests for React or Next.js apps: Jest, React Testing Library, MSW mocks, Playwright E2E, coverage gaps. Use whenever the user asks to add tests to a component or page, mock an API, set up end-to-end tests or raise coverage.
Install
npx skills add https://github.com/beginwithu/agent-skills/tree/main/skills/senior-qa
claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install beginwithu-agent-skills@llmmart
git clone https://github.com/beginwithu/agent-skills.git
The skills CLI installs just this skill, for any of its supported agents. Claude Code installs the whole beginwithu/agent-skills collection as a plugin from our marketplace. Git is the plain clone.
README
Senior QA Testing Engineer Skill
Production-ready quality assurance and test automation skill for React/Next.js applications.
Tech Stack Focus
| Category | Technologies |
|---|---|
| Unit/Integration | Jest, React Testing Library |
| E2E Testing | Playwright |
| Coverage Analysis | Istanbul, NYC, LCOV |
| API Mocking | MSW (Mock Service Worker) |
| Accessibility | jest-axe, @axe-core/playwright |
Quick Start
# Generate component tests
python scripts/test_suite_generator.py src/components --include-a11y
# Analyze coverage gaps
python scripts/coverage_analyzer.py coverage/coverage-final.json --threshold 80 --strict
# Scaffold E2E tests for Next.js
python scripts/e2e_test_scaffolder.py src/app --page-objects
Scripts
test_suite_generator.py
Scans React/TypeScript components and generates Jest + React Testing Library test stubs.
Features:
- Detects functional, class, memo, and forwardRef components
- Generates render, interaction, and accessibility tests
- Identifies props requiring mock data
- Optional
--include-a11yfor jest-axe assertions
Usage:
python scripts/test_suite_generator.py <component-dir> [options]
Options:
--scan-only List components without generating tests
--include-a11y Add accessibility test assertions
--output DIR Output directory for test files
coverage_analyzer.py
Parses Istanbul JSON or LCOV coverage reports and identifies testing gaps.
Features:
- Calculates line, branch, function, and statement coverage
- Identifies critical untested paths (auth, payment, API routes)
- Generates text and HTML reports
- Threshold enforcement with
--strictflag
Usage:
python scripts/coverage_analyzer.py <coverage-file> [options]
Options:
--threshold N Minimum coverage percentage (default: 80)
--strict Exit with error if below threshold
--format FORMAT Output format: text, json, html
--output FILE Output file path
e2e_test_scaffolder.py
Scans Next.js App Router or Pages Router directories and generates Playwright tests.
Features:
- Detects routes, dynamic parameters, and layouts
- Generates test files per route with navigation and content checks
- Optional Page Object Model class generation
- Generates
playwright.config.tsand auth fixtures
Usage:
python scripts/e2e_test_scaffolder.py <app-dir> [options]
Options:
--page-objects Generate Page Object Model classes
--output DIR Output directory for E2E tests
--base-url URL Base URL for tests (default: http://localhost:3000)
References
testing_strategies.md (650 lines)
Comprehensive testing strategy guide covering:
- Test pyramid and distribution (70% unit, 20% integration, 10% E2E)
- Coverage targets by project type
- Testing types (unit, integration, E2E, visual, accessibility)
- CI/CD integration patterns
- Testing decision framework
test_automation_patterns.md (1010 lines)
React/Next.js test automation patterns:
- Page Object Model implementation for Playwright
- Test data factories and builder patterns
- Fixture management (Playwright and Jest)
- Mocking strategies (MSW, Jest module mocking)
- Custom test utilities (
renderWithProviders) - Async testing patterns
- Snapshot testing guidelines
qa_best_practices.md (965 lines)
Quality assurance best practices:
- Writing testable React code
- Test naming conventions (Describe-It pattern)
- Arrange-Act-Assert structure
- Test isolation principles
- Handling flaky tests
- Debugging failed tests
- Quality metrics and KPIs
Workflows
Workflow 1: New Component Testing
- Create component in
src/components/ - Run
test_suite_generator.pyto generate test stub - Fill in test assertions based on component behavior
- Run
npm testto verify tests pass - Check coverage with
coverage_analyzer.py
Workflow 2: E2E Test Setup
- Run
e2e_test_scaffolder.pyon your Next.js app directory - Review generated tests in
e2e/directory - Customize Page Objects for complex interactions
- Run
npx playwright testto execute - Configure CI/CD with generated
playwright.config.ts
Workflow 3: Coverage Gap Analysis
- Run tests with coverage:
npm test -- --coverage - Analyze with
coverage_analyzer.py --strict --threshold 80 - Review critical untested paths in report
- Prioritize tests for auth, payment, and API routes
- Re-run analysis to verify improvement
Test Pyramid Targets
| Test Type | Ratio | Focus |
|---|---|---|
| Unit | 70% | Individual functions, utilities, hooks |
| Integration | 20% | Component interactions, API calls, state |
| E2E | 10% | Critical user journeys, happy paths |
Coverage Targets
| Project Type | Line | Branch | Function |
|---|---|---|---|
| Startup/MVP | 60% | 50% | 70% |
| Production | 80% | 70% | 85% |
| Enterprise | 90% | 85% | 95% |
CI/CD Integration
# .github/workflows/test.yml
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: npm ci
- name: Run unit tests
run: npm test -- --coverage
- name: Run E2E tests
run: npx playwright test
- name: Upload coverage
uses: codecov/codecov-action@v4
Related Skills
- senior-frontend - React/Next.js component development
- senior-fullstack - Full application architecture
- senior-devops - CI/CD pipeline setup
- code-reviewer - Code review with testing focus
Version: 2.9.0 Last Updated: January 2026 Tech Focus: React 18+, Next.js 14+, Jest 29+, Playwright 1.40+
Skill manifest
Senior QA Engineer
Test automation, coverage analysis, and quality assurance patterns for React and Next.js applications.
Quick Start
# Generate Jest test stubs for React components
python scripts/test_suite_generator.py src/components/ --output __tests__/
# Analyze test coverage from Jest/Istanbul reports
python scripts/coverage_analyzer.py coverage/coverage-final.json --threshold 80
# Scaffold Playwright E2E tests for Next.js routes
python scripts/e2e_test_scaffolder.py src/app/ --output e2e/
Tools Overview
1. Test Suite Generator
Scans React/TypeScript components and generates Jest + React Testing Library test stubs with proper structure.
Input: Source directory containing React components Output: Test files with describe blocks, render tests, interaction tests
Usage:
# Basic usage - scan components and generate tests
python scripts/test_suite_generator.py src/components/ --output __tests__/
# Include accessibility tests
python scripts/test_suite_generator.py src/ --output __tests__/ --include-a11y
# Generate with custom template
python scripts/test_suite_generator.py src/ --template custom-template.tsx
Supported Patterns:
- Functional components with hooks
- Components with Context providers
- Components with data fetching
- Form components with validation
2. Coverage Analyzer
Parses Jest/Istanbul coverage reports and identifies gaps, uncovered branches, and provides actionable recommendations.
Input: Coverage report (JSON or LCOV format) Output: Coverage analysis with recommendations
Usage:
# Analyze coverage report
python scripts/coverage_analyzer.py coverage/coverage-final.json
# Enforce threshold (exit 1 if below)
python scripts/coverage_analyzer.py coverage/ --threshold 80 --strict
# Generate HTML report
python scripts/coverage_analyzer.py coverage/ --format html --output report.html
3. E2E Test Scaffolder
Scans Next.js pages/app directory and generates Playwright test files with common interactions.
Input: Next.js pages or app directory Output: Playwright test files organized by route
Usage:
# Scaffold E2E tests for Next.js App Router
python scripts/e2e_test_scaffolder.py src/app/ --output e2e/
# Include Page Object Model classes
python scripts/e2e_test_scaffolder.py src/app/ --output e2e/ --include-pom
# Generate for specific routes
python scripts/e2e_test_scaffolder.py src/app/ --routes "/login,/dashboard,/checkout"
QA Workflows
Unit Test Generation Workflow
Use when setting up tests for new or existing React components.
Step 1: Scan project for untested components
python scripts/test_suite_generator.py src/components/ --scan-only
Step 2: Generate test stubs
python scripts/test_suite_generator.py src/components/ --output __tests__/
Step 3: Review and customize generated tests
// __tests__/Button.test.tsx (generated)
import { render, screen, fireEvent } from '@testing-library/react';
import { Button } from '../src/components/Button';
describe('Button', () => {
it('renders with label', () => {
render(<Button>Click me</Button>);
expect(screen.getByRole('button', { name: /click me/i })).toBeInTheDocument();
});
it('calls onClick when clicked', () => {
const handleClick = jest.fn();
render(<Button onClick={handleClick}>Click</Button>);
fireEvent.click(screen.getByRole('button'));
expect(handleClick).toHaveBeenCalledTimes(1);
});
// TODO: Add your specific test cases
});
Step 4: Run tests and check coverage
npm test -- --coverage
python scripts/coverage_analyzer.py coverage/coverage-final.json
Coverage Analysis Workflow
Use when improving test coverage or preparing for release.
Step 1: Generate coverage report
npm test -- --coverage --coverageReporters=json
Step 2: Analyze coverage gaps
python scripts/coverage_analyzer.py coverage/coverage-final.json --threshold 80
Step 3: Identify critical paths
python scripts/coverage_analyzer.py coverage/ --critical-paths
Step 4: Generate missing test stubs
python scripts/test_suite_generator.py src/ --uncovered-only --output __tests__/
Step 5: Verify improvement
npm test -- --coverage
python scripts/coverage_analyzer.py coverage/ --compare previous-coverage.json
E2E Test Setup Workflow
Use when setting up Playwright for a Next.js project.
Step 1: Initialize Playwright (if not installed)
npm init playwright@latest
Step 2: Scaffold E2E tests from routes
python scripts/e2e_test_scaffolder.py src/app/ --output e2e/
Step 3: Configure authentication fixtures
// e2e/fixtures/auth.ts (generated)
import { test as base } from '@playwright/test';
export const test = base.extend({
authenticatedPage: async ({ page }, use) => {
await page.goto('/login');
await page.fill('[name="email"]', 'test@example.com');
await page.fill('[name="password"]', 'password');
await page.click('button[type="submit"]');
await page.waitForURL('/dashboard');
await use(page);
},
});
Step 4: Run E2E tests
npx playwright test
npx playwright show-report
Step 5: Add to CI pipeline
# .github/workflows/e2e.yml
- name: "run-e2e-tests"
run: npx playwright test
- name: "upload-report"
uses: actions/upload-artifact@v4
with:
name: "playwright-report"
path: playwright-report/
Reference Documentation
| File | Contains | Use When |
|---|---|---|
references/testing_strategies.md |
Test pyramid, testing types, coverage targets, CI/CD integration | Designing test strategy |
references/test_automation_patterns.md |
Page Object Model, mocking (MSW), fixtures, async patterns | Writing test code |
references/qa_best_practices.md |
Testable code, flaky tests, debugging, quality metrics | Improving test quality |
Common Patterns Quick Reference
React Testing Library Queries
// Preferred (accessible)
screen.getByRole('button', { name: /submit/i })
screen.getByLabelText(/email/i)
screen.getByPlaceholderText(/search/i)
// Fallback
screen.getByTestId('custom-element')
Async Testing
// Wait for element
await screen.findByText(/loaded/i);
// Wait for removal
await waitForElementToBeRemoved(() => screen.queryByText(/loading/i));
// Wait for condition
await waitFor(() => {
expect(mockFn).toHaveBeenCalled();
});
Mocking with MSW
import { rest } from 'msw';
import { setupServer } from 'msw/node';
const server = setupServer(
rest.get('/api/users', (req, res, ctx) => {
return res(ctx.json([{ id: 1, name: "john" }]));
})
);
beforeAll(() => server.listen());
afterEach(() => server.resetHandlers());
afterAll(() => server.close());
Playwright Locators
// Preferred
page.getByRole('button', { name: "submit" })
page.getByLabel('Email')
page.getByText('Welcome')
// Chaining
page.getByRole('listitem').filter({ hasText: 'Product' })
Coverage Thresholds (jest.config.js)
module.exports = {
coverageThreshold: {
global: {
branches: 80,
functions: 80,
lines: 80,
statements: 80,
},
},
};
Common Commands
# Jest
npm test # Run all tests
npm test -- --watch # Watch mode
npm test -- --coverage # With coverage
npm test -- Button.test.tsx # Single file
# Playwright
npx playwright test # Run all E2E tests
npx playwright test --ui # UI mode
npx playwright test --debug # Debug mode
npx playwright codegen # Generate tests
# Coverage
npm test -- --coverage --coverageReporters=lcov,json
python scripts/coverage_analyzer.py coverage/coverage-final.json
Files (agent-skills)
-
references
-
qa_best_practices.md 23.2 KB
Loading… -
testing_strategies.md 16.8 KB
Loading… -
test_automation_patterns.md 24.4 KB
Loading…
-
-
scripts
-
coverage_analyzer.py 29.2 KB
Loading… -
e2e_test_scaffolder.py 25.8 KB
Loading… -
test_suite_generator.py 19.4 KB
Loading…
-
-
LICENSE 1 KB · in bundle
-
README.md 5.6 KB
# Senior QA Testing Engineer Skill Production-ready quality assurance and test automation skill for React/Next.js applications. ## Tech Stack Focus | Category | Technologies | |----------|--------------| | Unit/Integration | Jest, React Testing Library | | E2E Testing | Playwright | | Coverage Analysis | Istanbul, NYC, LCOV | | API Mocking | MSW (Mock Service Worker) | | Accessibility | jest-axe, @axe-core/playwright | ## Quick Start ```bash # Generate component tests python scripts/test_suite_generator.py src/components --include-a11y # Analyze coverage gaps python scripts/coverage_analyzer.py coverage/coverage-final.json --threshold 80 --strict # Scaffold E2E tests for Next.js python scripts/e2e_test_scaffolder.py src/app --page-objects ``` ## Scripts ### test_suite_generator.py Scans React/TypeScript components and generates Jest + React Testing Library test stubs. **Features:** - Detects functional, class, memo, and forwardRef components - Generates render, interaction, and accessibility tests - Identifies props requiring mock data - Optional `--include-a11y` for jest-axe assertions **Usage:** ```bash python scripts/test_suite_generator.py <component-dir> [options] Options: --scan-only List components without generating tests --include-a11y Add accessibility test assertions --output DIR Output directory for test files ``` ### coverage_analyzer.py Parses Istanbul JSON or LCOV coverage reports and identifies testing gaps. **Features:** - Calculates line, branch, function, and statement coverage - Identifies critical untested paths (auth, payment, API routes) - Generates text and HTML reports - Threshold enforcement with `--strict` flag **Usage:** ```bash python scripts/coverage_analyzer.py <coverage-file> [options] Options: --threshold N Minimum coverage percentage (default: 80) --strict Exit with error if below threshold --format FORMAT Output format: text, json, html --output FILE Output file path ``` ### e2e_test_scaffolder.py Scans Next.js App Router or Pages Router directories and generates Playwright tests. **Features:** - Detects routes, dynamic parameters, and layouts - Generates test files per route with navigation and content checks - Optional Page Object Model class generation - Generates `playwright.config.ts` and auth fixtures **Usage:** ```bash python scripts/e2e_test_scaffolder.py <app-dir> [options] Options: --page-objects Generate Page Object Model classes --output DIR Output directory for E2E tests --base-url URL Base URL for tests (default: http://localhost:3000) ``` ## References ### testing_strategies.md (650 lines) Comprehensive testing strategy guide covering: - Test pyramid and distribution (70% unit, 20% integration, 10% E2E) - Coverage targets by project type - Testing types (unit, integration, E2E, visual, accessibility) - CI/CD integration patterns - Testing decision framework ### test_automation_patterns.md (1010 lines) React/Next.js test automation patterns: - Page Object Model implementation for Playwright - Test data factories and builder patterns - Fixture management (Playwright and Jest) - Mocking strategies (MSW, Jest module mocking) - Custom test utilities (`renderWithProviders`) - Async testing patterns - Snapshot testing guidelines ### qa_best_practices.md (965 lines) Quality assurance best practices: - Writing testable React code - Test naming conventions (Describe-It pattern) - Arrange-Act-Assert structure - Test isolation principles - Handling flaky tests - Debugging failed tests - Quality metrics and KPIs ## Workflows ### Workflow 1: New Component Testing 1. Create component in `src/components/` 2. Run `test_suite_generator.py` to generate test stub 3. Fill in test assertions based on component behavior 4. Run `npm test` to verify tests pass 5. Check coverage with `coverage_analyzer.py` ### Workflow 2: E2E Test Setup 1. Run `e2e_test_scaffolder.py` on your Next.js app directory 2. Review generated tests in `e2e/` directory 3. Customize Page Objects for complex interactions 4. Run `npx playwright test` to execute 5. Configure CI/CD with generated `playwright.config.ts` ### Workflow 3: Coverage Gap Analysis 1. Run tests with coverage: `npm test -- --coverage` 2. Analyze with `coverage_analyzer.py --strict --threshold 80` 3. Review critical untested paths in report 4. Prioritize tests for auth, payment, and API routes 5. Re-run analysis to verify improvement ## Test Pyramid Targets | Test Type | Ratio | Focus | |-----------|-------|-------| | Unit | 70% | Individual functions, utilities, hooks | | Integration | 20% | Component interactions, API calls, state | | E2E | 10% | Critical user journeys, happy paths | ## Coverage Targets | Project Type | Line | Branch | Function | |--------------|------|--------|----------| | Startup/MVP | 60% | 50% | 70% | | Production | 80% | 70% | 85% | | Enterprise | 90% | 85% | 95% | ## CI/CD Integration ```yaml # .github/workflows/test.yml jobs: test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Install dependencies run: npm ci - name: Run unit tests run: npm test -- --coverage - name: Run E2E tests run: npx playwright test - name: Upload coverage uses: codecov/codecov-action@v4 ``` ## Related Skills - **senior-frontend** - React/Next.js component development - **senior-fullstack** - Full application architecture - **senior-devops** - CI/CD pipeline setup - **code-reviewer** - Code review with testing focus --- **Version:** 2.9.0 **Last Updated:** January 2026 **Tech Focus:** React 18+, Next.js 14+, Jest 29+, Playwright 1.40+ -
SKILL.md 8.1 KB
--- name: senior-qa description: "Write and improve tests for React or Next.js apps: Jest, React Testing Library, MSW mocks, Playwright E2E, coverage gaps. Use whenever the user asks to add tests to a component or page, mock an API, set up end-to-end tests or raise coverage." --- # Senior QA Engineer Test automation, coverage analysis, and quality assurance patterns for React and Next.js applications. --- ## Quick Start ```bash # Generate Jest test stubs for React components python scripts/test_suite_generator.py src/components/ --output __tests__/ # Analyze test coverage from Jest/Istanbul reports python scripts/coverage_analyzer.py coverage/coverage-final.json --threshold 80 # Scaffold Playwright E2E tests for Next.js routes python scripts/e2e_test_scaffolder.py src/app/ --output e2e/ ``` --- ## Tools Overview ### 1. Test Suite Generator Scans React/TypeScript components and generates Jest + React Testing Library test stubs with proper structure. **Input:** Source directory containing React components **Output:** Test files with describe blocks, render tests, interaction tests **Usage:** ```bash # Basic usage - scan components and generate tests python scripts/test_suite_generator.py src/components/ --output __tests__/ # Include accessibility tests python scripts/test_suite_generator.py src/ --output __tests__/ --include-a11y # Generate with custom template python scripts/test_suite_generator.py src/ --template custom-template.tsx ``` **Supported Patterns:** - Functional components with hooks - Components with Context providers - Components with data fetching - Form components with validation --- ### 2. Coverage Analyzer Parses Jest/Istanbul coverage reports and identifies gaps, uncovered branches, and provides actionable recommendations. **Input:** Coverage report (JSON or LCOV format) **Output:** Coverage analysis with recommendations **Usage:** ```bash # Analyze coverage report python scripts/coverage_analyzer.py coverage/coverage-final.json # Enforce threshold (exit 1 if below) python scripts/coverage_analyzer.py coverage/ --threshold 80 --strict # Generate HTML report python scripts/coverage_analyzer.py coverage/ --format html --output report.html ``` --- ### 3. E2E Test Scaffolder Scans Next.js pages/app directory and generates Playwright test files with common interactions. **Input:** Next.js pages or app directory **Output:** Playwright test files organized by route **Usage:** ```bash # Scaffold E2E tests for Next.js App Router python scripts/e2e_test_scaffolder.py src/app/ --output e2e/ # Include Page Object Model classes python scripts/e2e_test_scaffolder.py src/app/ --output e2e/ --include-pom # Generate for specific routes python scripts/e2e_test_scaffolder.py src/app/ --routes "/login,/dashboard,/checkout" ``` --- ## QA Workflows ### Unit Test Generation Workflow Use when setting up tests for new or existing React components. **Step 1: Scan project for untested components** ```bash python scripts/test_suite_generator.py src/components/ --scan-only ``` **Step 2: Generate test stubs** ```bash python scripts/test_suite_generator.py src/components/ --output __tests__/ ``` **Step 3: Review and customize generated tests** ```typescript // __tests__/Button.test.tsx (generated) import { render, screen, fireEvent } from '@testing-library/react'; import { Button } from '../src/components/Button'; describe('Button', () => { it('renders with label', () => { render(<Button>Click me</Button>); expect(screen.getByRole('button', { name: /click me/i })).toBeInTheDocument(); }); it('calls onClick when clicked', () => { const handleClick = jest.fn(); render(<Button onClick={handleClick}>Click</Button>); fireEvent.click(screen.getByRole('button')); expect(handleClick).toHaveBeenCalledTimes(1); }); // TODO: Add your specific test cases }); ``` **Step 4: Run tests and check coverage** ```bash npm test -- --coverage python scripts/coverage_analyzer.py coverage/coverage-final.json ``` --- ### Coverage Analysis Workflow Use when improving test coverage or preparing for release. **Step 1: Generate coverage report** ```bash npm test -- --coverage --coverageReporters=json ``` **Step 2: Analyze coverage gaps** ```bash python scripts/coverage_analyzer.py coverage/coverage-final.json --threshold 80 ``` **Step 3: Identify critical paths** ```bash python scripts/coverage_analyzer.py coverage/ --critical-paths ``` **Step 4: Generate missing test stubs** ```bash python scripts/test_suite_generator.py src/ --uncovered-only --output __tests__/ ``` **Step 5: Verify improvement** ```bash npm test -- --coverage python scripts/coverage_analyzer.py coverage/ --compare previous-coverage.json ``` --- ### E2E Test Setup Workflow Use when setting up Playwright for a Next.js project. **Step 1: Initialize Playwright (if not installed)** ```bash npm init playwright@latest ``` **Step 2: Scaffold E2E tests from routes** ```bash python scripts/e2e_test_scaffolder.py src/app/ --output e2e/ ``` **Step 3: Configure authentication fixtures** ```typescript // e2e/fixtures/auth.ts (generated) import { test as base } from '@playwright/test'; export const test = base.extend({ authenticatedPage: async ({ page }, use) => { await page.goto('/login'); await page.fill('[name="email"]', 'test@example.com'); await page.fill('[name="password"]', 'password'); await page.click('button[type="submit"]'); await page.waitForURL('/dashboard'); await use(page); }, }); ``` **Step 4: Run E2E tests** ```bash npx playwright test npx playwright show-report ``` **Step 5: Add to CI pipeline** ```yaml # .github/workflows/e2e.yml - name: "run-e2e-tests" run: npx playwright test - name: "upload-report" uses: actions/upload-artifact@v4 with: name: "playwright-report" path: playwright-report/ ``` --- ## Reference Documentation | File | Contains | Use When | |------|----------|----------| | `references/testing_strategies.md` | Test pyramid, testing types, coverage targets, CI/CD integration | Designing test strategy | | `references/test_automation_patterns.md` | Page Object Model, mocking (MSW), fixtures, async patterns | Writing test code | | `references/qa_best_practices.md` | Testable code, flaky tests, debugging, quality metrics | Improving test quality | --- ## Common Patterns Quick Reference ### React Testing Library Queries ```typescript // Preferred (accessible) screen.getByRole('button', { name: /submit/i }) screen.getByLabelText(/email/i) screen.getByPlaceholderText(/search/i) // Fallback screen.getByTestId('custom-element') ``` ### Async Testing ```typescript // Wait for element await screen.findByText(/loaded/i); // Wait for removal await waitForElementToBeRemoved(() => screen.queryByText(/loading/i)); // Wait for condition await waitFor(() => { expect(mockFn).toHaveBeenCalled(); }); ``` ### Mocking with MSW ```typescript import { rest } from 'msw'; import { setupServer } from 'msw/node'; const server = setupServer( rest.get('/api/users', (req, res, ctx) => { return res(ctx.json([{ id: 1, name: "john" }])); }) ); beforeAll(() => server.listen()); afterEach(() => server.resetHandlers()); afterAll(() => server.close()); ``` ### Playwright Locators ```typescript // Preferred page.getByRole('button', { name: "submit" }) page.getByLabel('Email') page.getByText('Welcome') // Chaining page.getByRole('listitem').filter({ hasText: 'Product' }) ``` ### Coverage Thresholds (jest.config.js) ```javascript module.exports = { coverageThreshold: { global: { branches: 80, functions: 80, lines: 80, statements: 80, }, }, }; ``` --- ## Common Commands ```bash # Jest npm test # Run all tests npm test -- --watch # Watch mode npm test -- --coverage # With coverage npm test -- Button.test.tsx # Single file # Playwright npx playwright test # Run all E2E tests npx playwright test --ui # UI mode npx playwright test --debug # Debug mode npx playwright codegen # Generate tests # Coverage npm test -- --coverage --coverageReporters=lcov,json python scripts/coverage_analyzer.py coverage/coverage-final.json ```
Reviews (0)
No reviews yet.
Comments
Sign in to join the conversation.
No comments yet. Start the conversation.