@@ -130,9 +130,17 @@ describe('CliRepl', () => {
130
130
131
131
context ( 'with an actual server' , ( ) => {
132
132
const testServer = startTestServer ( 'shared' ) ;
133
+ let cliRepl : CliRepl ;
133
134
134
- it ( 'connects to a server and interacts with it' , async ( ) => {
135
+ beforeEach ( ( ) => {
135
136
cliRepl = new CliRepl ( cliReplOptions ) ;
137
+ } ) ;
138
+
139
+ afterEach ( async ( ) => {
140
+ await cliRepl . mongoshRepl . close ( ) ;
141
+ } ) ;
142
+
143
+ it ( 'connects to a server and interacts with it' , async ( ) => {
136
144
await cliRepl . start ( await testServer . connectionString ( ) , { } ) ;
137
145
138
146
output = '' ;
@@ -154,7 +162,6 @@ describe('CliRepl', () => {
154
162
} ) ;
155
163
156
164
it ( 'asks for a password if one is required' , async ( ) => {
157
- cliRepl = new CliRepl ( cliReplOptions ) ;
158
165
outputStream . on ( 'data' , ( chunk ) => {
159
166
if ( chunk . includes ( 'Enter password' ) ) {
160
167
setImmediate ( ( ) => input . write ( 'i want food\n' ) ) ;
@@ -174,7 +181,6 @@ describe('CliRepl', () => {
174
181
} ) ;
175
182
176
183
it ( 'respects a canceled password input' , async ( ) => {
177
- cliRepl = new CliRepl ( cliReplOptions ) ;
178
184
outputStream . on ( 'data' , ( chunk ) => {
179
185
if ( chunk . includes ( 'Enter password' ) ) {
180
186
setImmediate ( ( ) => input . write ( '\u0003' ) ) ; // Ctrl+C
0 commit comments