1- import { afterEach , beforeEach , describe , expect , mock , test } from "bun:test" ;
2- import { mkdir , mkdtemp , readFile , rm , writeFile } from "node:fs/promises" ;
1+ import { afterAll , afterEach , beforeEach , describe , expect , mock , test } from "bun:test" ;
2+ import { mkdir , mkdtemp , rm } from "node:fs/promises" ;
33import { join } from "node:path" ;
44import * as realOs from "node:os" ;
55import { useCaptureLog } from "../../../test/lib/stubs.ts" ;
@@ -10,6 +10,7 @@ import { useCaptureLog } from "../../../test/lib/stubs.ts";
1010// module mock instead — registered at file top, before the clients are imported.
1111let mockHome = realOs . tmpdir ( ) ;
1212mock . module ( "node:os" , ( ) => ( { ...realOs , homedir : ( ) => mockHome } ) ) ;
13+ afterAll ( ( ) => mock . restore ( ) ) ;
1314
1415const mockIsAgent = mock ( ) ;
1516mock . module ( "../../../mode.ts" , ( ) => ( {
@@ -42,7 +43,7 @@ describe("user-scope MCP clients (homedir redirected to a tmpdir)", () => {
4243 describe ( "gemini" , ( ) => {
4344 test ( "encodes the mcp-remote stdio-bridge shape" , async ( ) => {
4445 await geminiClient . upsert ( { name : "clerk" , url : URL } , "/ignored" , false ) ;
45- const parsed = JSON . parse ( await readFile ( geminiClient . configPath ( "/ignored" ) , "utf8" ) ) as {
46+ const parsed = ( await Bun . file ( geminiClient . configPath ( "/ignored" ) ) . json ( ) ) as {
4647 mcpServers : { clerk : { command : string ; args : string [ ] } } ;
4748 } ;
4849 expect ( parsed . mcpServers . clerk ) . toEqual ( { command : "npx" , args : [ "-y" , "mcp-remote" , URL ] } ) ;
@@ -61,7 +62,7 @@ describe("user-scope MCP clients (homedir redirected to a tmpdir)", () => {
6162 // unrelated npx tool must not round-trip as a Clerk MCP entry.
6263 const dir = join ( mockHome , ".gemini" ) ;
6364 await mkdir ( dir , { recursive : true } ) ;
64- await writeFile (
65+ await Bun . write (
6566 join ( dir , "settings.json" ) ,
6667 JSON . stringify ( {
6768 mcpServers : {
@@ -78,7 +79,7 @@ describe("user-scope MCP clients (homedir redirected to a tmpdir)", () => {
7879 describe ( "windsurf" , ( ) => {
7980 test ( "encodes the serverUrl shape and round-trips it on list" , async ( ) => {
8081 await windsurfClient . upsert ( { name : "clerk" , url : URL } , "/ignored" , false ) ;
81- const parsed = JSON . parse ( await readFile ( windsurfClient . configPath ( "/ignored" ) , "utf8" ) ) as {
82+ const parsed = ( await Bun . file ( windsurfClient . configPath ( "/ignored" ) ) . json ( ) ) as {
8283 mcpServers : { clerk : { serverUrl : string } } ;
8384 } ;
8485 expect ( parsed . mcpServers . clerk ) . toEqual ( { serverUrl : URL } ) ;
0 commit comments