feat: programmatic API with getSuites(), executeSuite(), executeTest()#5518
Open
feat: programmatic API with getSuites(), executeSuite(), executeTest()#5518
Conversation
…est() Add clean programmatic API to Codecept class that wraps Mocha internals, eliminating duplicated boilerplate across dryRun, workers, and custom scripts. - getSuites(pattern?) returns parsed suites with tests as plain objects - executeSuite(suite) runs all tests in a suite - executeTest(test) runs a single test by fullTitle - Refactor workers.js to use getSuites() (removes ~30 lines of Mocha boilerplate) - Refactor dryRun.js to use getSuites() (removes Container.mocha() dependency) - Export Result class from lib/index.js - Rewrite docs/internal-api.md with full programmatic API reference Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
f28103a to
c8a7be8
Compare
- Create lib/runner.js with Runner class that owns all Mocha interactions: getSuites(), run(), runSuite(), runTest() backed by a single _execute() core - Codecept.run/runSuite/runTest/getSuites now delegate to this.runner - Remove duplicated executeTest() that was copy of run() - Refactor check.js to use codecept.getSuites() instead of manual Mocha - Export Runner from lib/index.js Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…yRunConfig - Remove dead code: activeWorkers Map, maxWorkers, empty recorder placeholder - Simplify _initializeTestPool to 4 lines - Remove redundant configWithoutFunctions variable in WorkerObject.addConfig - Remove hardcoded mochawesome/mocha-junit-reporter path manipulation from createWorkerObjects — fragile, incomplete, and redundant with output dir override - Extract getOverridenConfig to Config.applyRunConfig() in lib/config.js, shared by both workers.js and run-multiple.js Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
getSuites(pattern?)toCodeceptclass — returns parsed suites with tests as plain objects, using a temporary Mocha instance to avoid polluting container stateexecuteSuite(suite)andexecuteTest(test)— clean execution methods that accept objects returned bygetSuites()workers.js—createGroupsOfTests()andcreateGroupsOfSuites()now usegetSuites()instead of duplicated Mocha boilerplate (~30 lines removed)dryRun.js—printTests()now usesgetSuites(), removing directContainer.mocha()dependencyResultclass fromlib/index.jsdocs/internal-api.mdas full "Programmatic API" referenceUsage
Test plan
dry-runcommand works with refactoredgetSuites()(tested with grep filtering)run-workers 2🤖 Generated with Claude Code