MCPcopy Index your code
hub / github.com/codeceptjs/CodeceptJS / filterTestById

Function filterTestById

lib/command/workers/runTests.js:396–430  ·  view source on GitHub ↗
(testUid)

Source from the content-addressed store, hash-verified

394}
395
396function filterTestById(testUid) {
397 // In pool mode with ESM, test files are already loaded once at initialization
398 // We just need to filter the existing mocha suite to only include the target test
399
400 // Get the existing mocha instance
401 const mocha = container.mocha()
402
403 // Save reference to all suites before clearing
404 const allSuites = [...mocha.suite.suites]
405
406 // Clear suites and tests but preserve other mocha settings
407 mocha.suite.suites = []
408 mocha.suite.tests = []
409
410 // Find and add only the suite containing our target test
411 let foundTest = false
412 for (const suite of allSuites) {
413 const originalTests = [...suite.tests]
414
415 // Check if this suite has our target test
416 const targetTest = originalTests.find(test => test.uid === testUid)
417
418 if (targetTest) {
419 // Create a filtered suite with only the target test
420 suite.tests = [targetTest]
421 mocha.suite.suites.push(suite)
422 foundTest = true
423 break // Only include one test
424 }
425 }
426
427 if (!foundTest) {
428 console.error(`WARNING: Test with UID ${testUid} not found in mocha suites`)
429 }
430}
431
432function filterTests() {
433 const files = codecept.testFiles

Callers

nothing calls this directly

Calls 3

mochaMethod · 0.80
pushMethod · 0.80
findMethod · 0.45

Tested by

no test coverage detected