fix: run-workers --by suite parallelization broken by test file sorting (4.x) by mirao · Pull Request #5438 · codeceptjs/CodeceptJS

@mirao mentioned this pull request

Feb 9, 2026

4 tasks

@mirao @claude

…ng (codeceptjs#5412)

The sorting of test files in loadTests() (added in codeceptjs#5386) broke the
--by suite parallelization. When files were sorted before worker
distribution, all workers could receive the same tests instead of
different suites being distributed to different workers.

Fix: Move testFiles.sort() from loadTests() to run(). This ensures:
- Worker distribution uses original (unsorted) file order for consistent
  distribution across workers
- Test execution still uses alphabetical order (sorted in run())

Added unit test to verify files are not sorted after loadTests().

Fixes codeceptjs#5412

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- alphabetical_order_test: avoid calling codecept.run() which hangs
  in CI due to container.started() and event listener setup; test
  loadTests() directly instead
- worker_test: revert custom config assertions to original 4.x
  relaxed values (exact counts are filesystem-dependent)
- worker_test: simplify distribution test to only verify suite
  distribution without assuming glob order

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The test depends on mocha.loadFiles() with full container globals
(Feature, Scenario) which aren't available in unit test context on CI.
The core fix (sort moved from loadTests to run) is already verified
by alphabetical_order_test.js.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

@mirao

Compare loadTests() output against fresh globSync() to verify files
are not sorted, instead of assuming a specific non-alphabetical order.
This works regardless of filesystem glob order (ext4 vs others).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

DenysKuchma