Skip to content

Commit e4e8b0a

Browse files
sahrizviclaude
andcommitted
test(workspace): return a subprocess-like emitter from the open stub
`mock.module` is process-wide in Bun, and `oauth-browser.test.ts` mocks the same module. The MCP OAuth path attaches `error`/`exit` handlers to whatever `open` resolves to, so a stub resolving to `undefined` could break those tests if it were the registered one. Return an `EventEmitter`, as that file does. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent b324131 commit e4e8b0a

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

‎packages/opencode/test/altimate/workspace/create-then-rebind.test.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
// always failed. A test that only checks payloads cannot see that, which is why
99
// these assert the *sequence of endpoints* instead.
1010
import { afterAll, afterEach, beforeEach, describe, expect, mock, test } from "bun:test"
11+
import { EventEmitter } from "node:events"
1112
import { mkdirSync, writeFileSync } from "node:fs"
1213
import path from "node:path"
1314
import os from "node:os"
@@ -31,11 +32,14 @@ writeFileSync(
3132

3233
// A create opens the new workspace's manage URL in the browser. Stubbed before
3334
// the modules under test load, so a local run does not open real tabs; recorded,
34-
// so the tests still prove the open happens.
35+
// so the tests still prove the open happens. Returns a subprocess-like emitter,
36+
// as `oauth-browser.test.ts` does: `mock.module` is process-wide in Bun, and the
37+
// MCP OAuth path attaches `error`/`exit` handlers to whatever `open` resolves to.
3538
const opened: string[] = []
3639
mock.module("open", () => ({
3740
default: async (url: string) => {
3841
opened.push(url)
42+
return new EventEmitter()
3943
},
4044
}))
4145

0 commit comments

Comments
 (0)