원클릭으로
testing
Comprehensive testing strategies covering unit, integration, and end-to-end testing with Jest, React Testing Library, and Cypress
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Comprehensive testing strategies covering unit, integration, and end-to-end testing with Jest, React Testing Library, and Cypress
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Use this skill to learn hot to use the IBM Cloud CLI (`ibmcloud`) commands, flags, command patterns, or troubleshooting guidance. Covers core CLI workflows: install/verify/update, login with SSO or API keys, select account/region/resource group targets, inspect and configure CLI output, manage plug-ins (e.g. `vpc-infrastructure` / `ibmcloud is ...` for VPC infrastructure.).
Build voice-enabled agents in watsonx Orchestrate using the ADK. This guide covers initial setup, key concepts for building your first voice agent.
Reusable skills for the Turbonomic Resource Dashboard project. Each skill is a specialized workflow that Bob can activate to help with specific development tasks.
Deploy and manage HashiCorp Vault using Ansible automation with proper configuration, permissions, and security setup.
Plan and run evaluations, red-teaming, and runtime observability for watsonx Orchestrate (WXO) agents across Developer Edition and SaaS. Use when validating WXO agents pre-deploy, authoring benchmark JSON DAGs, interpreting Journey Success / Tool Call Recall / Agent Routing F1 / RAG Faithfulness, diagnosing agent failures, running adversarial red-teaming (Instruction Override, Jailbreaking, Crescendo Attack), searching runtime traces, exporting traces via the Python SDK, wiring Langfuse for cost & latency analysis, or registering model pricing in Langfuse. Interview-first; emits bash commands for the user to run in their IDE terminal.
Evaluate GenAI applications — RAG pipelines, LLM/chatbot outputs, and AI agents with tool-calling — before deployment using IBM watsonx.governance metrics. Use when scoring RAG faithfulness / answer relevance / context relevance / retrieval precision, screening LLM outputs for HAP / PII / social bias / jailbreak / prompt safety risk, evaluating agentic tool-call accuracy / parameter accuracy / relevance / syntactic validity, authoring custom LLM-as-judge metrics (criteria_judge or prompt_template styles) for domain-specific concerns, preparing eval datasets in the watsonx-gov SDK format, interpreting results against pass/fail thresholds, or producing prioritized [CRITICAL]/[WARNING]/[INFO] recommendations. Partners install `ibm-watsonx-gov[metrics,agentic,tools,llmaj]` directly and call the SDK in-process; no MCP server, no hosted dependency.
| name | testing |
| description | Comprehensive testing strategies covering unit, integration, and end-to-end testing with Jest, React Testing Library, and Cypress |
Use this skill when writing tests, setting up testing infrastructure, ensuring code quality through automated testing, or implementing test-driven development.
/\
/ \
/ E2E \ Few - Slow - Expensive
/______\
/ \
/Integration\ Some - Medium - Moderate
/____________\
/ \
/ Unit Tests \ Many - Fast - Cheap
/__________________\
import { render, screen, fireEvent } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { MyComponent } from './MyComponent';
describe('MyComponent', () => {
test('renders without crashing', () => {
render(<MyComponent />);
expect(screen.getByText(/expected text/i)).toBeInTheDocument();
});
test('handles user interaction', async () => {
const user = userEvent.setup();
render(<MyComponent />);
const button = screen.getByRole('button', { name: /submit/i });
await user.click(button);
expect(screen.getByText(/success/i)).toBeInTheDocument();
});
test('displays error state', () => {
render(<MyComponent error="Error message" />);
expect(screen.getByText(/error message/i)).toBeInTheDocument();
});
});
const request = require('supertest');
const app = require('../src/server');
describe('API Endpoints', () => {
describe('GET /health', () => {
test('returns healthy status', async () => {
const response = await request(app).get('/health');
expect(response.status).toBe(200);
expect(response.body).toHaveProperty('status', 'healthy');
});
});
describe('POST /api/data', () => {
test('creates new data', async () => {
const newData = { name: 'Test', value: 123 };
const response = await request(app)
.post('/api/data')
.send(newData);
expect(response.status).toBe(201);
expect(response.body).toMatchObject(newData);
});
test('validates required fields', async () => {
const response = await request(app)
.post('/api/data')
.send({});
expect(response.status).toBe(400);
expect(response.body).toHaveProperty('error');
});
});
});
import { render, screen, waitFor } from '@testing-library/react';
import { rest } from 'msw';
import { setupServer } from 'msw/node';
import App from './App';
const server = setupServer(
rest.get('/api/data', (req, res, ctx) => {
return res(ctx.json([
{ id: 1, name: 'Item 1' },
{ id: 2, name: 'Item 2' }
]));
})
);
beforeAll(() => server.listen());
afterEach(() => server.resetHandlers());
afterAll(() => server.close());
describe('App Integration', () => {
test('loads and displays data', async () => {
render(<App />);
await waitFor(() => {
expect(screen.getByText('Item 1')).toBeInTheDocument();
expect(screen.getByText('Item 2')).toBeInTheDocument();
});
});
test('handles API errors', async () => {
server.use(
rest.get('/api/data', (req, res, ctx) => {
return res(ctx.status(500));
})
);
render(<App />);
await waitFor(() => {
expect(screen.getByText(/error/i)).toBeInTheDocument();
});
});
});
describe('User Journey', () => {
beforeEach(() => {
cy.visit('/');
});
it('completes full workflow', () => {
// Navigate to form
cy.contains('Get Started').click();
// Fill in form
cy.get('input[name="email"]').type('user@example.com');
cy.get('input[name="password"]').type('password123');
// Submit form
cy.get('button[type="submit"]').click();
// Verify success
cy.contains('Welcome').should('be.visible');
cy.url().should('include', '/dashboard');
});
it('validates form inputs', () => {
cy.contains('Get Started').click();
cy.get('button[type="submit"]').click();
cy.contains('Email is required').should('be.visible');
});
});
import { renderHook, act } from '@testing-library/react';
import { useCounter } from './useCounter';
describe('useCounter', () => {
test('initializes with default value', () => {
const { result } = renderHook(() => useCounter());
expect(result.current.count).toBe(0);
});
test('increments counter', () => {
const { result } = renderHook(() => useCounter());
act(() => {
result.current.increment();
});
expect(result.current.count).toBe(1);
});
});
test('fetches data successfully', async () => {
render(<DataComponent />);
// Wait for loading to finish
await waitFor(() => {
expect(screen.queryByText(/loading/i)).not.toBeInTheDocument();
});
// Verify data is displayed
expect(screen.getByText('Data loaded')).toBeInTheDocument();
});
const nock = require('nock');
describe('External API', () => {
afterEach(() => {
nock.cleanAll();
});
test('calls external API', async () => {
nock('https://api.example.com')
.get('/data')
.reply(200, { result: 'success' });
const result = await fetchExternalData();
expect(result).toEqual({ result: 'success' });
});
});
// jest.config.js
module.exports = {
testEnvironment: 'jsdom',
setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
collectCoverageFrom: [
'src/**/*.{js,jsx}',
'!src/index.js',
'!src/**/*.test.{js,jsx}',
'!src/**/__tests__/**'
],
coverageThresholds: {
global: {
branches: 80,
functions: 80,
lines: 80,
statements: 80
}
}
};
# Run all tests
npm test
# Run with coverage
npm test -- --coverage
# Run specific test file
npm test -- MyComponent.test.js
# Run in watch mode
npm test -- --watch
# Update snapshots
npm test -- -u
name: Test
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm test -- --coverage
- name: Upload coverage
uses: codecov/codecov-action@v3
with:
files: ./coverage/lcov.info
src/
├── components/
│ ├── MyComponent.jsx
│ └── __tests__/
│ └── MyComponent.test.jsx
├── services/
│ ├── api.js
│ └── __tests__/
│ └── api.test.js
└── utils/
├── helpers.js
└── __tests__/
└── helpers.test.js
// Unit tests
describe('ComponentName', () => {
describe('methodName', () => {
test('should do something when condition', () => {
// Test implementation
});
});
});
// Integration tests
describe('Feature Integration', () => {
test('completes user workflow successfully', () => {
// Test implementation
});
});
// E2E tests
describe('User Journey', () => {
it('allows user to complete task', () => {
// Test implementation
});
});
Refer to the following files in this skill folder for detailed guidance:
unit-testing.md - Unit testing patterns and examplesintegration-testing.md - Integration testing strategiese2e-testing.md - End-to-end testing with Cypressmocking.md - Mocking strategies and patternscoverage.md - Test coverage requirements and toolsTests timing out:
// Increase timeout for slow tests
test('slow operation', async () => {
// Test code
}, 10000); // 10 second timeout
Async tests not waiting:
// Use waitFor for async operations
await waitFor(() => {
expect(screen.getByText('Loaded')).toBeInTheDocument();
});
Mock not working:
// Reset mocks between tests
afterEach(() => {
jest.clearAllMocks();
});