@@ -6,13 +6,29 @@ import {
66 setupIntegrationTest ,
77 waitUntilMcpClientIsSet ,
88} from "../../helpers.js" ;
9- import { describe , expect , it } from "vitest" ;
9+ import { afterEach , describe , expect , it } from "vitest" ;
1010
1111const isMacOSInGitHubActions = process . platform === "darwin" && process . env . GITHUB_ACTIONS === "true" ;
1212
1313// Docker is not available on macOS in GitHub Actions
1414// That's why we skip the tests on macOS in GitHub Actions
1515describe ( "atlas-local-connect-deployment" , ( ) => {
16+ let deploymentNamesToCleanup : string [ ] = [ ] ;
17+
18+ afterEach ( async ( ) => {
19+ // Clean up any deployments created during the test
20+ for ( const deploymentName of deploymentNamesToCleanup ) {
21+ try {
22+ await integration . mcpClient ( ) . callTool ( {
23+ name : "atlas-local-delete-deployment" ,
24+ arguments : { deploymentName } ,
25+ } ) ;
26+ } catch ( error ) {
27+ console . warn ( `Failed to delete deployment ${ deploymentName } :` , error ) ;
28+ }
29+ }
30+ deploymentNamesToCleanup = [ ] ;
31+ } ) ;
1632 const integration = setupIntegrationTest (
1733 ( ) => defaultTestConfig ,
1834 ( ) => defaultDriverOptions
@@ -69,6 +85,7 @@ describe("atlas-local-connect-deployment", () => {
6985 await waitUntilMcpClientIsSet ( integration . mcpServer ( ) , signal ) ;
7086 // Create a deployment
7187 const deploymentName = `test-deployment-${ Date . now ( ) } ` ;
88+ deploymentNamesToCleanup . push ( deploymentName ) ;
7289 await integration . mcpClient ( ) . callTool ( {
7390 name : "atlas-local-create-deployment" ,
7491 arguments : { deploymentName } ,
@@ -84,15 +101,5 @@ describe("atlas-local-connect-deployment", () => {
84101 expect ( elements [ 0 ] ?. text ) . toContain (
85102 'Successfully connected to Atlas Local deployment "' + deploymentName + '".'
86103 ) ;
87-
88- // cleanup
89- try {
90- await integration . mcpClient ( ) . callTool ( {
91- name : "atlas-local-delete-deployment" ,
92- arguments : { deploymentName } ,
93- } ) ;
94- } catch ( error ) {
95- console . warn ( `Failed to delete deployment ${ deploymentName } :` , error ) ;
96- }
97104 } ) ;
98105} ) ;
0 commit comments