Repository navigation
Add a class to help mock child_process.spawn() and make "pub add" tests faster using it - #6166
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The new mocks include a type-invalid super(...) call and a stray ;; that will break type-check/lint, so the PR is not in a mergeable state yet.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR targets faster CI/test execution (Issue #6165) by avoiding real pub add/process execution in tests and instead verifying the extension attempted to spawn the expected processes.
Changes:
- Added a reusable
child_process.spawn()stub that captures/validates invocations and fakes immediate successful completion. - Updated Dart/Flutter
pub addtests to assert spawned commands instead of waiting for real Pubspec mutations. - Moved/introduced a
FakeProcessStdIOServiceundersrc/test/mocksand exported a couple of process helpers needed by the stub.
File summaries
| File | Description |
|---|---|
| src/test/mocks/fake_stdio_service.ts | Adds a fake StdIOService for tests to feed stdout/stderr/exit/errors without spawning real processes. |
| src/test/mocks/child_process_spawn_stub.ts | Introduces a child_process.spawn sinon stub for capturing/asserting spawned commands while faking completion. |
| src/test/flutter/pub/add.test.ts | Switches Flutter pub add tests from asserting pubspec edits to asserting spawned flutter pub add calls. |
| src/test/flutter/device_manager.test.ts | Updates import to the new FakeProcessStdIOService location. |
| src/test/dart/services/stdio_service.test.ts | Updates import to the new FakeProcessStdIOService location. |
| src/test/dart/pub/add.test.ts | Switches Dart pub add tests from asserting pubspec edits to asserting spawned dart pub ... calls. |
| src/shared/processes.ts | Exports simpleCommandRegex and quoteAndEscapeArg for reuse in test stubs. |
Review details
- Files reviewed: 6/7 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #6166 +/- ##
==========================================
- Coverage 70.85% 70.82% -0.04%
==========================================
Files 170 170
Lines 13157 13158 +1
Branches 2649 2649
==========================================
- Hits 9323 9319 -4
- Misses 3315 3319 +4
- Partials 519 520 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…ts faster using it See #6165
e62635e to
fddeeb8
Compare
See #6165