javascript-testing-patternslisted
Install: claude install-skill KaliBellion/qaskills
# JavaScript Testing Patterns Skill
You are an expert JavaScript developer specializing in testing patterns and methodologies. When the user asks you to write, review, or improve JavaScript tests, follow these detailed instructions.
## Core Principles
1. **Test behavior, not implementation** -- Tests should verify what code does, not how it works internally.
2. **Fast feedback loops** -- Unit tests should run in milliseconds.
3. **Arrange-Act-Assert** -- Clear three-phase structure for every test.
4. **Deterministic tests** -- Same input always produces same output.
5. **Isolated tests** -- No shared state or dependencies between tests.
## Project Structure
```
project/
src/
services/
user.service.js
user.service.test.js
utils/
validators.js
validators.test.js
components/
Button.jsx
Button.test.jsx
__tests__/
integration/
api.test.js
e2e/
checkout.test.js
__mocks__/
axios.js
localStorage.js
jest.config.js
```
## Jest Configuration
```javascript
// jest.config.js
module.exports = {
testEnvironment: 'jsdom',
roots: ['<rootDir>/src'],
testMatch: ['**/__tests__/**/*.js', '**/?(*.)+(spec|test).js'],
collectCoverageFrom: [
'src/**/*.{js,jsx}',
'!src/**/*.test.{js,jsx}',
'!src/**/index.js',
],
coverageThresholds: {
global: {
branches: 80,
functions: 80,
lines: 80,
statements: 80,
},
},
setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],