How jestjs/jest works
Jest is a JavaScript testing platform: a developer invokes the CLI, which configures and schedules test files, workers run them in isolated environments, and reporters present results and coverage. The README also highlights interactive change-aware watch mode, snapshots, Babel transforms, and configuration generation; these remain distinct capabilities. Edges are limited to relationships explicit in README or shown in sampled source/index references; unsampled subsystems are represented without speculative wiring.
Main entry points: runJest.ts Run orchestration · runTest.ts Test runner · run.ts Jest CLI · eventHandler.ts Circus runner
Components 24
CLI and setup
- Jest CLI
packages/jest-cli/src/run.ts - Configuration
packages/jest-config/src/normalize.ts - Config generator
packages/create-jest/src
Discovery and scheduling
- Run orchestration
packages/jest-core/src/runJest.ts - Test selection
packages/jest-core/src/SearchSource.ts - File and module index
packages/jest-haste-map/src - Changed-file detection
packages/jest-changed-files/src - Test sequencing
packages/jest-test-sequencer/src/index.ts - Test scheduler
packages/jest-core/src/TestScheduler.ts
Test execution
- Test runner
packages/jest-runner/src/runTest.ts - Module runtime
packages/jest-runtime/src/index.ts - Circus runner
packages/jest-circus/src/eventHandler.ts - Jasmine runner
packages/jest-jasmine2/src/index.ts - Test environments
packages/jest-environment/src/index.ts - Assertions and matchers
packages/expect/src/matchers.ts - Mocking
packages/jest-mock/src/index.ts - Worker pool
packages/jest-worker/src/WorkerPool.ts
Results and feedback
- Snapshot testing
packages/jest-snapshot/src - Reporting and coverage
packages/jest-reporters/src/CoverageReporter.ts - Interactive watch
packages/jest-core/src/watch.ts - Test results
packages/jest-test-result/src
Transform and setup
- Script transformation
packages/jest-transform/src/ScriptTransformer.ts - Babel integration
packages/babel-jest/src/babel.ts
Other components
- Developer
Connections 25
- Developer → Jest CLI: invokes
- Jest CLI → Configuration: loads config
- Jest CLI → Run orchestration: starts run
- Developer → Config generator: requests config
- Run orchestration → Test selection: selects tests
- Test selection → File and module index: queries index
- Run orchestration → Changed-file detection: finds changes
- Run orchestration → Test sequencing: orders tests
- Run orchestration → Test scheduler: schedules tests
- Test scheduler → Worker pool: dispatches work
- Worker pool → Test runner: runs test file
- Test runner → Module runtime: loads modules
- Test runner → Test environments: sets environment
- Test runner → Circus runner: executes tests
- Test runner → Jasmine runner: executes tests
- Circus runner → Assertions and matchers: asserts with
- Circus runner → Mocking: uses mocks
- Module runtime → Script transformation: transforms modules
- Script transformation → Babel integration: uses Babel
- Test runner → Snapshot testing: uses snapshots
- Run orchestration → Reporting and coverage: reports results
- Reporting and coverage → Test results: produces results
- Developer → Interactive watch: starts watch
- Interactive watch → Changed-file detection: tracks changes
- Reporting and coverage → Worker pool: dispatches coverage
packages/jest-reporters/src/CoverageReporter.ts