@@ -135,29 +135,8 @@ function generateTopologyTests(testSuites, testContext, filter) {
135
135
beforeEach ( ( ) => prepareDatabaseForSuite ( testSuite , testContext ) ) ;
136
136
afterEach ( ( ) => testContext . cleanupAfterSuite ( ) ) ;
137
137
testSuite . tests . forEach ( spec => {
138
- it ( spec . description , function ( ) {
139
- if ( requires . authEnabled && process . env . AUTH !== 'auth' ) {
140
- // TODO: We do not have a way to determine if auth is enabled in our mocha metadata
141
- // We need to do a admin.command({getCmdLineOpts: 1}) if it errors (code=13) auth is on
142
- this . skip ( ) ;
143
- }
144
-
145
- if (
146
- spec . operations . some (
147
- op => op . name === 'waitForEvent' && op . arguments . event === 'PoolReadyEvent'
148
- )
149
- ) {
150
- // TODO(NODE-2994): Connection storms work will add new events to connection pool
151
- this . skip ( ) ;
152
- }
153
-
154
- if (
155
- spec . skipReason ||
156
- ( filter && typeof filter === 'function' && ! filter ( spec , this . configuration ) )
157
- ) {
158
- return this . skip ( ) ;
159
- }
160
-
138
+ const maybeIt = shouldRunSpecTest . call ( this , requires , spec , filter ) ? it : it . skip ;
139
+ maybeIt ( spec . description , function ( ) {
161
140
let testPromise = Promise . resolve ( ) ;
162
141
if ( spec . failPoint ) {
163
142
testPromise = testPromise . then ( ( ) => testContext . enableFailPoint ( spec . failPoint ) ) ;
@@ -180,6 +159,31 @@ function generateTopologyTests(testSuites, testContext, filter) {
180
159
} ) ;
181
160
}
182
161
162
+ function shouldRunSpecTest ( requires , spec , filter ) {
163
+ if ( requires . authEnabled && process . env . AUTH !== 'auth' ) {
164
+ // TODO: We do not have a way to determine if auth is enabled in our mocha metadata
165
+ // We need to do a admin.command({getCmdLineOpts: 1}) if it errors (code=13) auth is on
166
+ return false ;
167
+ }
168
+
169
+ if (
170
+ spec . operations . some (
171
+ op => op . name === 'waitForEvent' && op . arguments . event === 'PoolReadyEvent'
172
+ )
173
+ ) {
174
+ // TODO(NODE-2994): Connection storms work will add new events to connection pool
175
+ return false ;
176
+ }
177
+
178
+ if (
179
+ spec . skipReason ||
180
+ ( filter && typeof filter === 'function' && ! filter ( spec , this . configuration ) )
181
+ ) {
182
+ return false ;
183
+ }
184
+ return true ;
185
+ }
186
+
183
187
// Test runner helpers
184
188
function prepareDatabaseForSuite ( suite , context ) {
185
189
context . dbName = suite . database_name || 'spec_db' ;
0 commit comments