@@ -129,35 +129,15 @@ function generateTopologyTests(testSuites, testContext, filter) {
129
129
environmentRequirementList . forEach ( requires => {
130
130
const suiteName = `${ testSuite . name } - ${ requires . topology . join ( ) } ` ;
131
131
describe ( suiteName , {
132
- // FIXME: calling this.skip() inside tests triggers the leak checker, disable until fixed
133
- metadata : { requires, sessions : { skipLeakTests : true } } ,
132
+ metadata : { requires } ,
134
133
test : function ( ) {
135
134
beforeEach ( ( ) => prepareDatabaseForSuite ( testSuite , testContext ) ) ;
136
135
afterEach ( ( ) => testContext . cleanupAfterSuite ( ) ) ;
137
136
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
-
137
+ const maybeIt = shouldRunSpecTest ( this . configuration , requires , spec , filter )
138
+ ? it
139
+ : it . skip ;
140
+ maybeIt ( spec . description , function ( ) {
161
141
let testPromise = Promise . resolve ( ) ;
162
142
if ( spec . failPoint ) {
163
143
testPromise = testPromise . then ( ( ) => testContext . enableFailPoint ( spec . failPoint ) ) ;
@@ -180,6 +160,28 @@ function generateTopologyTests(testSuites, testContext, filter) {
180
160
} ) ;
181
161
}
182
162
163
+ function shouldRunSpecTest ( configuration , requires , spec , filter ) {
164
+ if ( requires . authEnabled && process . env . AUTH !== 'auth' ) {
165
+ // TODO(NODE-3488): We do not have a way to determine if auth is enabled in our mocha metadata
166
+ // We need to do a admin.command({getCmdLineOpts: 1}) if it errors (code=13) auth is on
167
+ return false ;
168
+ }
169
+
170
+ if (
171
+ spec . operations . some (
172
+ op => op . name === 'waitForEvent' && op . arguments . event === 'PoolReadyEvent'
173
+ )
174
+ ) {
175
+ // TODO(NODE-2994): Connection storms work will add new events to connection pool
176
+ return false ;
177
+ }
178
+
179
+ if ( spec . skipReason || ( filter && typeof filter === 'function' && ! filter ( spec , configuration ) ) ) {
180
+ return false ;
181
+ }
182
+ return true ;
183
+ }
184
+
183
185
// Test runner helpers
184
186
function prepareDatabaseForSuite ( suite , context ) {
185
187
context . dbName = suite . database_name || 'spec_db' ;
0 commit comments