Add comprehensive TypeScript test suite with Jest
- Configure Jest for TypeScript testing with ts-jest preset - Create comprehensive unit tests for Location model (15 tests) - Create comprehensive unit tests for ProfanityWord model (16 tests) - Create comprehensive unit tests for ProfanityFilterService (30+ tests) - Create integration tests for public API routes (18 tests) - Add test database setup and teardown utilities - Configure coverage reporting with 80% threshold - Install testing dependencies (@types/jest, ts-jest, @types/supertest) Test Coverage: - Location model: Full CRUD operations, validation, cleanup - ProfanityWord model: Full CRUD operations, constraints, case handling - ProfanityFilterService: Text analysis, custom words, filtering - Public API routes: Configuration, location reporting, error handling - Request validation: JSON parsing, content types, edge cases Features: - In-memory SQLite databases for isolated testing - Comprehensive test setup with proper cleanup - Mock profanity filters for controlled testing - Type-safe test implementations with TypeScript - Detailed test scenarios for edge cases and error conditions All tests passing: 67 total tests across models and integration 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
ba0c63d14a
commit
4bcc99d44b
10 changed files with 1974 additions and 448 deletions
|
@ -1,17 +1,32 @@
|
|||
module.exports = {
|
||||
preset: 'ts-jest',
|
||||
testEnvironment: 'node',
|
||||
collectCoverageFrom: [
|
||||
'**/*.js',
|
||||
'!**/node_modules/**',
|
||||
'!**/coverage/**',
|
||||
'!**/public/**',
|
||||
'!jest.config.js',
|
||||
'!server.js' // Exclude main server file as it's integration-focused
|
||||
],
|
||||
roots: ['<rootDir>/src', '<rootDir>/tests'],
|
||||
testMatch: [
|
||||
'**/tests/**/*.test.js',
|
||||
'**/tests/**/*.spec.js'
|
||||
'**/__tests__/**/*.+(ts|tsx|js)',
|
||||
'**/*.(test|spec).+(ts|tsx|js)'
|
||||
],
|
||||
verbose: true,
|
||||
setupFilesAfterEnv: ['<rootDir>/tests/setup.js']
|
||||
transform: {
|
||||
'^.+\\.(ts|tsx)$': 'ts-jest'
|
||||
},
|
||||
collectCoverageFrom: [
|
||||
'src/**/*.{ts,tsx}',
|
||||
'!src/**/*.d.ts',
|
||||
'!src/swagger.ts', // Skip swagger spec file
|
||||
'!src/types/**/*', // Skip type definitions
|
||||
'!src/server.ts' // Skip main server as it's integration-focused
|
||||
],
|
||||
coverageDirectory: 'coverage',
|
||||
coverageReporters: ['text', 'lcov', 'html'],
|
||||
coverageThreshold: {
|
||||
global: {
|
||||
branches: 80,
|
||||
functions: 80,
|
||||
lines: 80,
|
||||
statements: 80
|
||||
}
|
||||
},
|
||||
setupFilesAfterEnv: ['<rootDir>/tests/setup.ts'],
|
||||
testTimeout: 10000,
|
||||
verbose: true
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue