一键导入
platxa-testing
Automated testing patterns for Platxa platform using pytest, Vitest, and E2E frameworks. Run tests, generate fixtures, configure CI/CD pipelines.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Automated testing patterns for Platxa platform using pytest, Vitest, and E2E frameworks. Run tests, generate fixtures, configure CI/CD pipelines.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Autonomous skill creator for Claude Code CLI. Use when the user asks to "create a skill", "generate a skill", or "build a new slash command". Uses multi-phase orchestrated workflow with Task tool subagents to research domains, design architecture, generate content, validate quality, and iteratively improve via eval infrastructure. Creates production-ready skills following the Agent Skills open standard and Claude Code extensions.
Automatically generates and improves code documentation across Python, JavaScript/TypeScript, Java, Go, and Rust. Detects language conventions, applies appropriate docstring standards, and validates documentation quality.
Generate conventional commit messages by analyzing staged git changes. Detects change type, suggests scope, and formats messages following the Conventional Commits specification.
Guide for structured error handling across Platxa stack. Covers error types, retry patterns with exponential backoff, logging, and HTTP response mapping for Python, TypeScript, and Go.
Generate production-ready React/Next.js components for Platxa platform. Creates Server/Client components, forms, data tables, and UI primitives following App Router patterns, TypeScript best practices, and Tailwind/Shadcn styling.
Generate RS256 JWT authentication with JWKS endpoint for Platxa services. Creates secure token infrastructure with key rotation support.
| name | platxa-testing |
| description | Automated testing patterns for Platxa platform using pytest, Vitest, and E2E frameworks. Run tests, generate fixtures, configure CI/CD pipelines. |
| allowed-tools | ["Read","Write","Edit","Bash","Glob","Grep"] |
| metadata | {"version":"1.0.0","tags":["automation","testing","pytest","vitest","e2e"]} |
| user-invocable | true |
Automation skill for testing patterns in the Platxa platform.
| Framework | Language | Use Case |
|---|---|---|
| pytest | Python | Unit, integration, E2E tests |
| Vitest | TypeScript | Unit tests, async patterns |
| Playwright | TypeScript | Visual regression, browser E2E |
| Kind | Kubernetes | E2E cluster testing |
NO MOCKS OR SIMULATIONS - All tests use real operations:
# Python testing
pip install pytest pytest-timeout tiktoken pyyaml
# TypeScript testing
pnpm add -D vitest @types/node
# E2E testing
brew install kind kubectl # macOS
# or apt install kind kubectl # Linux
[pytest]
testpaths = tests
python_files = test_*.py
python_classes = Test*
python_functions = test_*
addopts = -v --tb=short --strict-markers -ra
markers =
unit: Unit tests (fast, no external dependencies)
integration: Integration tests (service interactions)
e2e: End-to-end tests (full lifecycle)
slow: Tests that take > 30 seconds
timeout = 300
log_cli = true
log_cli_level = INFO
filterwarnings =
ignore::DeprecationWarning
import pytest
import tempfile
import subprocess
import os
from pathlib import Path
from typing import Generator, Callable
@pytest.fixture
def temp_dir() -> Generator[Path, None, None]:
"""Creates isolated temporary directory."""
with tempfile.TemporaryDirectory(prefix="test_") as tmpdir:
yield Path(tmpdir)
@pytest.fixture
def run_script(scripts_dir: Path) -> Callable[[str, Path], subprocess.CompletedProcess]:
"""Returns function to execute scripts."""
def _run(script_name: str, target: Path) -> subprocess.CompletedProcess:
return subprocess.run(
[str(scripts_dir / script_name), str(target)],
capture_output=True, text=True,
env={**os.environ, "TERM": "dumb"},
)
return _run
@pytest.mark.unit
class TestFeatureValidation:
"""Tests for feature validation logic."""
def test_valid_input_passes(self, temp_dir):
"""Feature #1: Valid input is accepted."""
test_file = temp_dir / "valid.txt"
test_file.write_text("content")
result = validate(test_file)
assert result.success is True
def test_invalid_input_fails(self, temp_dir):
"""Feature #2: Invalid input is rejected."""
test_file = temp_dir / "invalid.txt"
test_file.write_text("")
result = validate(test_file)
assert result.success is False
{
"scripts": {
"test": "vitest",
"test:run": "vitest run",
"test:coverage": "vitest run --coverage"
}
}
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
import * as fs from 'fs';
import * as path from 'path';
import * as os from 'os';
describe('FeatureName', () => {
let testDir: string;
beforeEach(() => {
testDir = fs.mkdtempSync(path.join(os.tmpdir(), 'test-'));
});
afterEach(() => {
fs.rmSync(testDir, { recursive: true, force: true });
});
it('handles valid input correctly', () => {
fs.writeFileSync(path.join(testDir, 'input.json'), '{"key": "value"}');
const result = processFile(path.join(testDir, 'input.json'));
expect(result.success).toBe(true);
});
});
#!/bin/bash
cat <<EOF | kind create cluster --name platxa-test --config=-
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
extraPortMappings:
- containerPort: 30080
hostPort: 8080
protocol: TCP
EOF
@pytest.mark.e2e
class TestInstanceLifecycle:
"""E2E tests for complete instance lifecycle."""
def test_complete_lifecycle(self, test_instance):
instance = create_instance("e2e-test")
assert instance.status == "draft"
instance.provision()
assert instance.status == "active"
assert namespace_exists(instance.namespace)
instance.suspend()
assert instance.status == "suspended"
instance.resume()
assert instance.status == "active"
instance.delete()
assert instance.status == "deleted"
import { test, expect } from '@playwright/test';
test('button matches snapshot', async ({ page }) => {
await page.goto('/components/button');
await expect(page.locator('button')).toHaveScreenshot('button.png', {
maxDiffPixels: 100, threshold: 0.2, animations: 'disabled'
});
});
| Scenario | Framework | Markers |
|---|---|---|
| Business logic | pytest | @pytest.mark.unit |
| API integration | pytest | @pytest.mark.integration |
| Full lifecycle | pytest + Kind | @pytest.mark.e2e |
| TypeScript utils | vitest | describe/it |
| Visual regression | Playwright | test() |
# Python project
tests/
├── conftest.py # Shared fixtures
├── test_feature_a.py # Feature tests
└── test_feature_b.py
# TypeScript project
src/utils/__tests__/feature.test.ts
tests/e2e/visual.spec.ts
# pytest
pytest tests/ -v # All tests
pytest tests/ -m unit # Unit only
pytest tests/ -m "not slow" # Skip slow
# vitest
pnpm test # Watch mode
pnpm test:run # Single run
name: Tests
on: [push, pull_request]
jobs:
unit-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- run: pip install pytest pytest-timeout
- run: pytest tests/ -m "unit" -v
e2e-tests:
runs-on: ubuntu-latest
needs: unit-tests
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- uses: helm/kind-action@v1
- run: pytest tests/ -m "e2e" -v --timeout=600
User: "Write tests for a validation function"
@pytest.mark.unit
class TestValidation:
def test_valid_yaml_passes(self, temp_dir):
"""Feature #1: Valid YAML files are accepted."""
yaml_file = temp_dir / "valid.yaml"
yaml_file.write_text("name: test\nversion: 1.0")
result = validate_yaml(yaml_file)
assert result.valid is True
def test_invalid_yaml_fails(self, temp_dir):
"""Feature #2: Invalid YAML files are rejected."""
yaml_file = temp_dir / "invalid.yaml"
yaml_file.write_text("name: test\n bad indent")
result = validate_yaml(yaml_file)
assert result.valid is False
User: "Test async file operations"
describe('fileOps', () => {
let testDir: string;
beforeEach(() => {
testDir = fs.mkdtempSync(path.join(os.tmpdir(), 'fileops-'));
});
afterEach(() => {
fs.rmSync(testDir, { recursive: true, force: true });
});
it('reads JSON file correctly', async () => {
fs.writeFileSync(path.join(testDir, 'data.json'), '{"key": "value"}');
const result = await readJsonFile(path.join(testDir, 'data.json'));
expect(result).toEqual({ key: 'value' });
});
});
User: "Test Kubernetes deployment"
@pytest.mark.e2e
class TestKubernetesDeployment:
@classmethod
def setup_class(cls):
config.load_kube_config(context="kind-platxa-test")
cls.apps_v1 = client.AppsV1Api()
def test_deployment_creates_pods(self):
deploy = self.apps_v1.read_namespaced_deployment("my-app", "default")
assert deploy.spec.replicas == 2
| Issue | Cause | Fix |
|---|---|---|
| Tests hang | Missing timeout | Add timeout = 300 in pytest.ini |
| Flaky tests | Shared state | Use temp directories, cleanup |
| Import errors | Missing conftest | Add __init__.py to tests/ |
| K8s connection | Wrong context | kubectl config use-context |
| Permission denied | Script not executable | chmod +x scripts/*.sh |
After writing tests:
See references/ for detailed patterns: pytest-patterns.md, vitest-patterns.md, e2e-patterns.md