Skip to content

fix: initialize sourcePatterns in tester context to prevent undefined error#10020

Merged
davidfirst merged 1 commit into
masterfrom
fix-jest-tester-source-patterns
Oct 1, 2025
Merged

fix: initialize sourcePatterns in tester context to prevent undefined error#10020
davidfirst merged 1 commit into
masterfrom
fix-jest-tester-source-patterns

Conversation

@davidfirst
Copy link
Copy Markdown
Member

Fixes the issue where Jest tester with useSourceFiles: true crashes with Cannot read properties of undefined (reading 'toArray') during bit test.

Problem

When Jest tester is configured with useSourceFiles: true, it expects context.sourcePatterns to be available. However, during bit test, the tester context only included patterns but not sourcePatterns, causing an undefined error. The sourcePatterns was only being populated during bit build task by the tester-task component.

Solution

Initialize sourcePatterns in the tester service to default to the same value as patterns. This ensures:

  • During bit test: sourcePatterns equals patterns, allowing jest-tester to work correctly with source files
  • During bit build: The jest-tester-task can still override sourcePatterns with capsule-specific paths

@davidfirst davidfirst enabled auto-merge (squash) October 1, 2025 15:22
@davidfirst davidfirst merged commit 6e8b29e into master Oct 1, 2025
11 checks passed
@davidfirst davidfirst deleted the fix-jest-tester-source-patterns branch October 1, 2025 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants