From df91c210d5c551167805f85839fcd2e95ec5f4e3 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 16 Nov 2025 06:57:20 +0000 Subject: [PATCH 1/4] Initial plan From 0b7105ed66527336d1b0da09fdbc4aa555641492 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 16 Nov 2025 07:24:43 +0000 Subject: [PATCH 2/4] Fix worker test configuration and test root path - Fixed Workers#_initWorkers to pass test root directory instead of config file path - Fixed 'should create worker by function' test to configure helpers via options - Fixed helper configurations in other worker tests - Test now passes consistently (483 passed, 5 failed, 16 skipped) --- lib/workers.js | 2 +- test/unit/worker_test.js | 38 +++++++++++++++++++++++--------------- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/lib/workers.js b/lib/workers.js index aaf8f65a0..80dca4e1b 100644 --- a/lib/workers.js +++ b/lib/workers.js @@ -315,7 +315,7 @@ class Workers extends EventEmitter { this.splitTestsByGroups(numberOfWorkers, config) // For function-based grouping, use the actual number of test groups created const actualNumberOfWorkers = isFunction(config.by) ? this.testGroups.length : numberOfWorkers - this.workers = createWorkerObjects(this.testGroups, this.codecept.config, config.testConfig, config.options, config.selectedRuns) + this.workers = createWorkerObjects(this.testGroups, this.codecept.config, getTestRoot(config.testConfig), config.options, config.selectedRuns) this.numberOfWorkers = this.workers.length } diff --git a/test/unit/worker_test.js b/test/unit/worker_test.js index 77a77ceac..635f00b72 100644 --- a/test/unit/worker_test.js +++ b/test/unit/worker_test.js @@ -60,21 +60,23 @@ describe('Workers', function () { const workerConfig = { by: createTestGroups, testConfig: './test/data/sandbox/codecept.customworker.js', + options: { + override: JSON.stringify({ + helpers: { + FileSystem: {}, + Workers: { + require: './workers_helper', + }, + CustomWorkers: { + require: './custom_worker_helper', + }, + }, + }), + }, } const workers = new Workers(-1, workerConfig) - for (const worker of workers.getWorkers()) { - worker.addConfig({ - helpers: { - FileSystem: {}, - Workers: { - require: './custom_worker_helper.js', - }, - }, - }) - } - workers.run() workers.on(event.all.result, result => { @@ -110,7 +112,7 @@ describe('Workers', function () { // Clean up event listeners workers.removeListener(event.test.failed, onTestFailed) workers.removeListener(event.test.passed, onTestPassed) - + // The main assertion is that workers ran and some tests failed (indicating they executed) expect(result.hasFailed).equal(true) // In test suite context, event counting has timing issues, but functionality works @@ -141,7 +143,10 @@ describe('Workers', function () { helpers: { FileSystem: {}, Workers: { - require: './custom_worker_helper.js', + require: './workers_helper', + }, + CustomWorkers: { + require: './custom_worker_helper', }, }, }) @@ -176,7 +181,10 @@ describe('Workers', function () { helpers: { FileSystem: {}, Workers: { - require: './custom_worker_helper.js', + require: './workers_helper', + }, + CustomWorkers: { + require: './custom_worker_helper', }, }, }) @@ -233,7 +241,7 @@ describe('Workers', function () { testConfig: './test/data/sandbox/codecept.non-test-events-worker.js', } - let workers = new Workers(2, workerConfig) + let workers = new Workers(2, workerConfig) workers.run() From 68a1bcdb4a600c11192d07162edd2c5f33517119 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 16 Nov 2025 13:01:40 +0000 Subject: [PATCH 3/4] Changes before error encountered Co-authored-by: kobenguyent <7845001+kobenguyent@users.noreply.github.com> --- lib/container.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/container.js b/lib/container.js index 6c49d1c66..e1f68008a 100644 --- a/lib/container.js +++ b/lib/container.js @@ -22,6 +22,7 @@ let container = { helpers: {}, support: {}, proxySupport: {}, + proxySupportConfig: {}, // Track config used to create proxySupport plugins: {}, actor: null, /** @@ -67,7 +68,8 @@ class Container { container.support = {} container.helpers = await createHelpers(config.helpers || {}) container.translation = await loadTranslation(config.translation || null, config.vocabularies || []) - container.proxySupport = createSupportObjects(config.include || {}) + container.proxySupportConfig = config.include || {} + container.proxySupport = createSupportObjects(container.proxySupportConfig) container.plugins = await createPlugins(config.plugins || {}, opts) container.result = new Result() @@ -207,8 +209,10 @@ class Container { // If new support objects are added, update the proxy support if (newContainer.support) { - const newProxySupport = createSupportObjects(newContainer.support) - container.proxySupport = { ...container.proxySupport, ...newProxySupport } + // Merge the new support config with existing config + container.proxySupportConfig = { ...container.proxySupportConfig, ...newContainer.support } + // Recreate the proxy with merged config + container.proxySupport = createSupportObjects(container.proxySupportConfig) } debug('appended', JSON.stringify(newContainer).slice(0, 300)) @@ -224,6 +228,7 @@ class Container { static async clear(newHelpers = {}, newSupport = {}, newPlugins = {}) { container.helpers = newHelpers container.translation = await loadTranslation() + container.proxySupportConfig = newSupport container.proxySupport = createSupportObjects(newSupport) container.plugins = newPlugins container.sharedKeys = new Set() // Clear shared keys From 12382b0c4988110a6a50ae85b8f4c0a63daaea79 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 16 Nov 2025 15:28:35 +0000 Subject: [PATCH 4/4] Changes before error encountered Co-authored-by: kobenguyent <7845001+kobenguyent@users.noreply.github.com> --- lib/helper/REST.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/helper/REST.js b/lib/helper/REST.js index ad5b09319..3c272d958 100644 --- a/lib/helper/REST.js +++ b/lib/helper/REST.js @@ -218,8 +218,9 @@ class REST extends Helper { } } - if (this.options.onRequest) { - await this.options.onRequest(request) + const onRequest = this.options.onRequest || this.config.onRequest + if (onRequest) { + await onRequest(request) } try { @@ -248,8 +249,9 @@ class REST extends Helper { } response = err.response } - if (this.options.onResponse) { - await this.options.onResponse(response) + const onResponse = this.options.onResponse || this.config.onResponse + if (onResponse) { + await onResponse(response) } try { this.options.prettyPrintJson ? this.debugSection('Response', beautify(JSON.stringify(response.data))) : this.debugSection('Response', JSON.stringify(response.data))