Skip to content

Commit af8c4c1

Browse files
committed
Revert "test: remove fragile worker distribution test"
This reverts commit 5c03e7a.
1 parent 5c03e7a commit af8c4c1

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

test/unit/worker_test.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,4 +383,33 @@ describe('Workers', function () {
383383
workers.run()
384384
})
385385

386+
it('should distribute suites across workers for --by suite (issue #5412)', async () => {
387+
// This test verifies the fix for issue #5412:
388+
// Test files should NOT be sorted in loadTests() because that affects worker distribution.
389+
// Sorting should only happen in run() for execution order.
390+
//
391+
// The bug was: sorting in loadTests() changed the order of suites during distribution,
392+
// causing all workers to receive the same tests instead of different suites.
393+
394+
// Ensure clean state
395+
Container.clear()
396+
Container.createMocha()
397+
398+
const workerConfig = {
399+
by: 'suite',
400+
testConfig: './test/data/sandbox/codecept.customworker.js',
401+
}
402+
403+
const workers = new Workers(3, workerConfig)
404+
await workers._ensureInitialized()
405+
406+
// Verify that test files were loaded
407+
const testFiles = workers.codecept.testFiles
408+
expect(testFiles.length).to.be.greaterThan(0, 'Test files should be loaded')
409+
410+
// Verify that suites are distributed across multiple worker groups
411+
const groups = workers.testGroups
412+
const nonEmptyGroups = groups.filter(g => g.length > 0)
413+
expect(nonEmptyGroups.length).to.be.greaterThan(1, 'Suites should be distributed across multiple worker groups')
414+
})
386415
})

0 commit comments

Comments
 (0)