test: refactor runCliSync to unify cli tests#1458
Merged
Timeless0911 merged 2 commits intomainfrom Jan 28, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors the runCliSync function in the test utilities to use spawnSync instead of execSync, improving the handling of stdout, stderr, and exit codes in tests. The function now returns a structured object with status, stdout, and stderr properties instead of just a string.
Changes:
- Refactored
runCliSyncto usespawnSyncfor better control over process execution and output handling - Updated function signature to accept both string and array command formats, returning an object with exit status and cleaned output streams
- Updated 11 integration test files to destructure the new return format and remove error-based control flow in favor of status code checking
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/scripts/shared.ts | Replaced execSync with spawnSync, changed return type to object with status/stdout/stderr, added stripAnsi for output cleaning |
| tests/integration/dts/composite/index.test.ts | Updated to use runCliSync and destructure status from return value |
| tests/integration/dts/bundle/index.test.ts | Updated to use runCliSync and destructure status from return value |
| tests/integration/dts/bundle-false/index.test.ts | Updated to use runCliSync and destructure status from return value |
| tests/integration/dts/build/index.test.ts | Updated to use runCliSync and destructure status/stderr from return value |
| tests/integration/dts-tsgo/bundle/index.test.ts | Updated to use runCliSync and destructure status from return value |
| tests/integration/dts-tsgo/bundle-false/index.test.ts | Updated to use runCliSync and destructure status from return value |
| tests/integration/dts-tsgo/build/index.test.ts | Updated to use runCliSync and destructure status from return value |
| tests/integration/cli/unknown-option/index.test.ts | Replaced try-catch error handling with direct status code checking |
| tests/integration/cli/mf/mf.test.ts | Replaced try-catch error handling with direct status code checking and removed unnecessary stripAnsi import |
| tests/integration/cli/log-level/index.test.ts | Updated to destructure stdout from return value and removed stripAnsi import |
| tests/integration/cli/build/build.test.ts | Updated config file not found test to check status/stderr; changed build options test to use array format for complex arguments |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Refactor
runCliSyncintests/scripts/shared.tsto usespawnSyncinstead ofexecSync. This allows for better handling of stdout/stderr and exit codes in tests. Updated integration tests to match the new return signature.do not use
shell: trueto prevent(node:33665) [DEP0190] DeprecationWarning: Passing args to a child process with shell option true can lead to security vulnerabilities, as the arguments are not escaped, only concatenated.Related Links
Checklist