testing
Comprehensive testing requirements for all code changes. Use this to ensure tests are never skipped and all failures are fixed before completion.
When & Why to Use This Skill
This Claude skill establishes a rigorous framework for software testing and quality assurance, ensuring that code changes are robust, maintainable, and regression-free. It enforces a strict 'never-skip' policy for tests, provides standardized structures for unit and integration testing using frameworks like Jest and Bun, and integrates linting and build verification into the core development workflow to maintain high code quality standards.
Use Cases
- Automated Quality Gates: Enforcing mandatory linting, testing, and building steps after every code change to prevent bugs from reaching production.
- Standardized Test Development: Utilizing provided templates and best practices to create consistent, descriptive unit and integration tests across complex projects.
- Systematic Debugging and Resolution: Guiding developers through a structured workflow to analyze test failures, identify root causes, and verify fixes without bypassing quality checks.
- CI/CD Readiness: Ensuring that all local code changes pass comprehensive validation (lint, test, build) before being committed to a continuous integration pipeline.
- Environment-Specific Testing: Streamlining the setup of test environments, including managing sensitive environment variables and project-specific configurations using tools like Nx and 1Password CLI.
| name | testing |
|---|---|
| description | Comprehensive testing requirements for all code changes. Use this to ensure tests are never skipped and all failures are fixed before completion. |
Testing Guidelines
Strict requirements for testing code changes across the Hey Jarvis project.
Critical Rules
Never Skip Tests
CRITICAL: Tests must NEVER be skipped or disabled.
❌ NEVER use .skip() to disable tests
❌ NEVER comment out failing tests
❌ NEVER disable tests in CI/CD environments
❌ NEVER ignore test failures
✅ ALWAYS let tests fail properly if requirements are not met ✅ ALWAYS fix the root cause of test failures
Required After Changes
Testing and linting are MANDATORY after making code changes:
- Lint your changes: Run
bunx nx lint <project>orbunx nx affected --target=lint - Test your changes: Run
bunx nx test <project>orbunx nx affected --target=test - Build your changes: Run
bunx nx build <project>if applicable
If any of these fail, you MUST fix the issues. Do not proceed until all checks pass.
Keep Fixing Until It Works
When tests or linting fail, you MUST:
- Analyze the failure output carefully
- Fix the root cause (not the symptom)
- Re-run the tests/linting
- Repeat until ALL tests and linting pass
Do NOT:
- Skip tests to make things "pass"
- Reduce thresholds or expectations
- Work around the issue without fixing it
- Give up and leave failures unaddressed
Test Structure Best Practices
Use Proper Test Frameworks
- Use Jest/Bun test for unit and integration tests
- Follow existing test patterns in the repository
- Use descriptive test names that explain what is being tested
Test Organization
describe('Feature/Component Name', () => {
describe('method or function name', () => {
it('should behave correctly when condition', () => {
// Arrange
const input = setupTestData();
// Act
const result = functionUnderTest(input);
// Assert
expect(result).toBeDefined();
expect(result.value).toBe(expectedValue);
});
});
});
Validation and Error Handling
// Check for validation errors
if (isValidationError(result)) {
throw new Error(`Validation failed: ${result.message}`);
}
// Always validate structure and expected values
expect(result).toBeDefined();
expect(result.property).toBe(expectedValue);
Timeouts
Set appropriate timeouts for async operations:
it('should complete async operation', async () => {
// test code
}, 30000); // 30 second timeout for integration tests
Environment Setup
Tests may require environment variables. Use 1Password CLI to load them:
eval $(op signin) # If not already authenticated
Check test files for required environment variables and ensure they are configured.
Running Tests
Single Project
bunx nx test <project-name>
All Affected Projects
bunx nx affected --target=test
With Coverage
bunx nx test <project-name> --coverage
Running Linting
Single Project
bunx nx lint <project-name>
All Affected Projects
bunx nx affected --target=lint
Auto-fix Issues
bunx biome check --write .
Workflow
When making code changes, follow this workflow:
- Make your changes - Implement the feature or fix
- Run linting -
bunx nx lint <project>and fix any issues - Run tests -
bunx nx test <project>and fix any failures - Run build -
bunx nx build <project>if applicable - Verify manually - Test the functionality works as expected
- Repeat - If any step fails, fix and re-run all checks
Do NOT consider your work complete until:
- ✅ All linting passes without warnings or errors
- ✅ All tests pass without skipping any
- ✅ The build succeeds (if applicable)
- ✅ Manual verification confirms functionality works
Common Issues
Test Failures
- Read the error message carefully
- Check if environment variables are missing
- Verify test data and mocks are set up correctly
- Debug the actual code being tested
- Fix the root cause, not the test
Linting Failures
- Run
bunx biome check --write .to auto-fix formatting - For remaining issues, read the linting error and fix manually
- Never disable linting rules to make code pass
Build Failures
- Check for TypeScript type errors
- Ensure all imports are correct
- Verify dependencies are installed
- Fix compilation errors in the code
What NOT to Do
❌ Never skip tests with .skip()
❌ Never reduce test expectations to make them pass
❌ Never disable linting rules without good reason
❌ Never ignore build warnings or errors
❌ Never commit code with failing tests
❌ Never commit commented-out tests
❌ Never proceed if tests fail - fix them first
❌ Never give up on fixing issues - keep iterating until resolved