بنقرة واحدة
debug-test-failures
Workflow for investigating and fixing failing tests in this project
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Workflow for investigating and fixing failing tests in this project
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
Debug code using detailed profiling and critical path timing before making suggestions
Making Python or TypeScript packages shareable (pip/npm)
Setup pytest with coverage reporting and watch mode for this Python project
Commands to execute tests in this project with various options and configurations
Format code according to project standards and fix linting issues
Git branch strategy, commit conventions, and PR process for this project
| name | debug-test-failures |
| description | Workflow for investigating and fixing failing tests in this project |
| auto-activates | ["debug test","test failing","fix failing test","why is test failing","test not passing"] |
This skill activates when you need to:
This assumes tests are configured and running. Use run-tests skill to execute tests first.
Run tests with verbose output:
# Python
pytest -v
# JavaScript
npm test -- --verbose
# Go
go test -v ./...
Identify the failing test(s):
Python (pytest):
pytest tests/test_file.py::test_function_name -v
JavaScript (Jest):
npm test -- tests/example.test.js -t "test name pattern"
Go:
go test -run TestFunctionName -v
Python - Add print statements:
def test_example():
result = my_function(input_data)
print(f"DEBUG: result = {result}") # Debug output
print(f"DEBUG: type = {type(result)}")
assert result == expected
Run with output visible:
pytest -s tests/test_file.py::test_function_name
Python - Use pytest's debugging:
# Drop into debugger on failure
pytest --pdb
# Drop into debugger on first failure
pytest -x --pdb
JavaScript - Add console.log:
test('example', () => {
const result = myFunction(inputData);
console.log('DEBUG: result =', result);
expect(result).toBe(expected);
});
Cause: Expected value doesn't match actual value
Debug steps:
Example fix:
# Before - fails due to extra whitespace
assert result == "hello"
# After - strip whitespace
assert result.strip() == "hello"
Cause: Module path issues or missing dependencies
Debug steps:
pip list | grep modulepip install -e .Example fix:
# Add to tests/conftest.py
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent.parent / "src"))
Cause: Test taking too long or blocking operation
Debug steps:
Example fix:
# Pytest - increase timeout
@pytest.mark.timeout(300)
def test_slow_operation():
result = slow_function()
assert result is not None
Cause: Test fixtures or setup not working
Debug steps:
Example fix:
# Check fixture is working
def test_example(sample_data):
print(f"Fixture value: {sample_data}") # Debug
assert sample_data is not None
Cause: Race conditions, timing issues, or external dependencies
Debug steps:
pytest --count=10Example fix:
# Mock random values
from unittest.mock import patch
@patch('random.randint', return_value=5)
def test_with_random(mock_random):
result = function_using_random()
assert result == expected_value
Drop into debugger on failure:
pytest --pdb
Add breakpoint in code:
def test_example():
data = prepare_data()
breakpoint() # Python 3.7+
# or: import pdb; pdb.set_trace()
result = process(data)
assert result == expected
pdb commands:
l - list coden - next lines - step into functionc - continue executionp variable - print variablepp variable - pretty printq - quit debuggerNode.js debugger:
node --inspect-brk node_modules/.bin/jest --runInBand
Add debugger statement:
test('example', () => {
const data = prepareData();
debugger; // Pauses here in debugger
const result = process(data);
expect(result).toBe(expected);
});
Python .vscode/launch.json:
{
"name": "Python: Debug Tests",
"type": "python",
"request": "launch",
"module": "pytest",
"args": ["tests/test_file.py", "-v"]
}
JavaScript .vscode/launch.json:
{
"name": "Jest: Debug",
"type": "node",
"request": "launch",
"program": "${workspaceFolder}/node_modules/.bin/jest",
"args": ["--runInBand", "--no-cache"],
"console": "integratedTerminal"
}
Solutions:
Solutions:
pytest --cache-clear or jest --clearCacheSolutions:
-vv for extra verbose output