Skip to content

Commit 38b70dc

Browse files
committed
test: better skipping in legacy spec runner
1 parent 4a10389 commit 38b70dc

File tree

1 file changed

+27
-23
lines changed

1 file changed

+27
-23
lines changed

test/functional/spec-runner/index.js

+27-23
Original file line numberDiff line numberDiff line change
@@ -135,29 +135,8 @@ function generateTopologyTests(testSuites, testContext, filter) {
135135
beforeEach(() => prepareDatabaseForSuite(testSuite, testContext));
136136
afterEach(() => testContext.cleanupAfterSuite());
137137
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 () {
161140
let testPromise = Promise.resolve();
162141
if (spec.failPoint) {
163142
testPromise = testPromise.then(() => testContext.enableFailPoint(spec.failPoint));
@@ -180,6 +159,31 @@ function generateTopologyTests(testSuites, testContext, filter) {
180159
});
181160
}
182161

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+
183187
// Test runner helpers
184188
function prepareDatabaseForSuite(suite, context) {
185189
context.dbName = suite.database_name || 'spec_db';

0 commit comments

Comments
 (0)