@@ -40,6 +40,12 @@ const templates = {}
4040 * npx codeceptjs run --plugins stepByStepReport
4141 * ```
4242 *
43+ * Run tests with workers:
44+ *
45+ * ```
46+ * npx codeceptjs run-workers 2 --plugins stepByStepReport
47+ * ```
48+ *
4349 * #### Configuration
4450 *
4551 * ```js
@@ -60,6 +66,11 @@ const templates = {}
6066 * * `screenshotsForAllureReport`: If Allure plugin is enabled this plugin attaches each saved screenshot to allure report. Default: false.
6167 * * `disableScreenshotOnFail : Disables the capturing of screeshots after the failed step. Default: true.
6268 *
69+ * #### Worker Support
70+ *
71+ * When using `run-workers`, screenshots from all workers are automatically consolidated into a shared directory
72+ * to ensure the final step-by-step report contains all screenshots from all workers.
73+ *
6374 * @param {* } config
6475 */
6576
@@ -87,7 +98,25 @@ module.exports = function (config) {
8798
8899 const recordedTests = { }
89100 const pad = '0000'
90- const reportDir = config . output ? path . resolve ( global . codecept_dir , config . output ) : defaultConfig . output
101+
102+ // When running with workers, use the shared output directory instead of worker-specific directories
103+ // This ensures that all workers save their screenshots to the same location so the final consolidated
104+ // report can find all screenshots in one place
105+ let reportDir
106+ if ( process . env . RUNS_WITH_WORKERS === 'true' && global . codecept_dir ) {
107+ // Extract the base output directory from the worker-specific path
108+ // Worker paths are typically like: /project/output/worker_name
109+ // We want to extract: /project/output and create: /project/output/stepByStepReport
110+ const currentOutputDir = config . output ? path . resolve ( global . codecept_dir , config . output ) : defaultConfig . output
111+ const workerDirPattern = / [ / \\ ] [ ^ / \\ ] + $ / // Match the last directory segment (worker name)
112+ const baseOutputDir = currentOutputDir . replace ( workerDirPattern , '' )
113+ reportDir = path . join ( baseOutputDir , 'stepByStepReport' )
114+ } else {
115+ reportDir = config . output ? path . resolve ( global . codecept_dir , config . output ) : defaultConfig . output
116+ }
117+
118+ // Ensure the report directory exists
119+ mkdirp . sync ( reportDir )
91120
92121 event . dispatcher . on ( event . suite . before , suite => {
93122 stepNum = - 1
0 commit comments