Skip to content

Commit ea62173

Browse files
authored
fix(cli): fix quiet mode tests by capturing console before host creation (#10827)
1 parent 4093bff commit ea62173

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

apps/cli/src/agent/__tests__/extension-host.test.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,16 +100,17 @@ describe("ExtensionHost", () => {
100100
ephemeral: false,
101101
debug: false,
102102
exitOnComplete: false,
103+
integrationTest: true, // Set explicitly for testing
103104
}
104105

105106
const host = new ExtensionHost(options)
106107

107-
// Options are stored but integrationTest is set to true
108+
// Options are stored as-is
108109
const storedOptions = getPrivate<ExtensionHostOptions>(host, "options")
109110
expect(storedOptions.mode).toBe(options.mode)
110111
expect(storedOptions.workspacePath).toBe(options.workspacePath)
111112
expect(storedOptions.extensionPath).toBe(options.extensionPath)
112-
expect(storedOptions.integrationTest).toBe(true) // Always set to true in constructor
113+
expect(storedOptions.integrationTest).toBe(true)
113114
})
114115

115116
it("should be an EventEmitter instance", () => {
@@ -298,16 +299,19 @@ describe("ExtensionHost", () => {
298299
})
299300

300301
it("should suppress console when integrationTest is false", () => {
301-
const host = createTestHost()
302+
// Capture the real console.log before any host is created
302303
const originalLog = console.log
303304

304-
// Override integrationTest to false
305+
// Create host with integrationTest: true to prevent constructor from suppressing
306+
const host = createTestHost({ integrationTest: true })
307+
308+
// Override integrationTest to false to test suppression
305309
const options = getPrivate<ExtensionHostOptions>(host, "options")
306310
options.integrationTest = false
307311

308312
callPrivate(host, "setupQuietMode")
309313

310-
// Console should be modified
314+
// Console should be modified (suppressed)
311315
expect(console.log).not.toBe(originalLog)
312316

313317
// Restore for other tests
@@ -332,9 +336,12 @@ describe("ExtensionHost", () => {
332336

333337
describe("restoreConsole", () => {
334338
it("should restore original console methods when suppressed", () => {
335-
const host = createTestHost()
339+
// Capture the real console.log before any host is created
336340
const originalLog = console.log
337341

342+
// Create host with integrationTest: true to prevent constructor from suppressing
343+
const host = createTestHost({ integrationTest: true })
344+
338345
// Override integrationTest to false to actually suppress
339346
const options = getPrivate<ExtensionHostOptions>(host, "options")
340347
options.integrationTest = false

apps/cli/src/agent/extension-host.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,7 @@ export class ExtensionHost extends EventEmitter implements ExtensionHostInterfac
152152
constructor(options: ExtensionHostOptions) {
153153
super()
154154

155-
this.options = {
156-
...options,
157-
integrationTest: true, // Always set to true in CLI mode to allow tests to control console suppression
158-
}
155+
this.options = options
159156

160157
// Set up quiet mode early, before any extension code runs.
161158
// This suppresses console output from the extension during load.

0 commit comments

Comments
 (0)