Write comprehensive tests: unit tests for transformations, integration tests for upload workflow, malware detection tests, thumbnail generation tests. Test with various image formats and sizes. Coverage > 85%. By the end, image handling is well-tested and reliable.
← Back to Module 08 overviewInstall: npm install --save-dev jest ts-jest @types/jest testcontainers
Create jest.config.js:
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
roots: ['/src'],
testMatch: ['**/__tests__/**/*.test.ts'],
collectCoverageFrom: [
'src/**/*.ts',
'!src/**/*.d.ts',
'!src/index.ts'
],
coverageThreshold: {
global: { branches: 80, functions: 85, lines: 85, statements: 85 }
}
};