wellnua-lite/jest.config.js
Sergei a1e30939a6 Fix race condition with AbortController in VoiceContext
Problem:
- Multiple rapid calls to sendTranscript() created race conditions
- Old requests continued using local abortController variable
- Responses from superseded requests could still be processed
- Session stop didn't reliably prevent pending responses

Solution:
- Changed abort checks from `abortController.signal.aborted` to
  `abortControllerRef.current !== abortController`
- Ensures request checks if it's still the active one, not just aborted
- Added checks at 4 critical points: before API call, after API call,
  before retry, and after retry

Changes:
- VoiceContext.tsx:268 - Check before initial API call
- VoiceContext.tsx:308 - Check after API response
- VoiceContext.tsx:344 - Check before retry
- VoiceContext.tsx:359 - Check after retry response

Testing:
- Added Jest test configuration
- Added test suite with 5 race condition scenarios
- Added manual testing documentation
- Verified with TypeScript linting (no new errors)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-29 11:03:08 -08:00

28 lines
810 B
JavaScript

module.exports = {
preset: 'jest-expo',
testEnvironment: 'jsdom',
setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
transformIgnorePatterns: [
'node_modules/(?!((jest-)?react-native|@react-native(-community)?)|expo(nent)?|@expo(nent)?/.*|@expo-google-fonts/.*|react-navigation|@react-navigation/.*|@unimodules/.*|unimodules|sentry-expo|native-base|react-native-svg)',
],
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/$1',
},
collectCoverageFrom: [
'contexts/**/*.{ts,tsx}',
'services/**/*.{ts,tsx}',
'hooks/**/*.{ts,tsx}',
'!**/*.d.ts',
'!**/node_modules/**',
'!**/__tests__/**',
],
testMatch: [
'**/__tests__/**/*.test.{ts,tsx}',
'**/?(*.)+(spec|test).{ts,tsx}',
],
testPathIgnorePatterns: [
'/node_modules/',
'/.ralphy-worktrees/',
],
};