codeceptjs 3.7.5-beta.5 → 3.7.5-beta.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -105,7 +105,7 @@ module.exports = function (config) {
105
105
  output.print(`Failed Tests Tracker: Recorded failed test - ${test.title}`)
106
106
  })
107
107
 
108
- // Save failed tests to file after all tests complete
108
+ // Handle test completion and save failed tests
109
109
  event.dispatcher.on(event.all.result, (result) => {
110
110
  // Respect CodeceptJS output directory like other plugins
111
111
  const outputDir = global.output_dir || './output'
@@ -133,7 +133,7 @@ module.exports = function (config) {
133
133
  const failedTest = {
134
134
  title: test.title,
135
135
  fullTitle: test.fullTitle || test.title,
136
- file: test.file || (test.parent && test.parent.file),
136
+ file: test.file || 'unknown',
137
137
  uid: test.uid,
138
138
  timestamp: new Date().toISOString(),
139
139
  }
@@ -176,6 +176,8 @@ module.exports = function (config) {
176
176
  allFailedTests.push(failedTest)
177
177
  existingTestIds.add(testId)
178
178
  })
179
+
180
+ output.print(`Failed Tests Tracker: Collected ${workerFailedTests.length} failed tests from workers`)
179
181
  }
180
182
 
181
183
  if (allFailedTests.length === 0) {
@@ -222,7 +224,99 @@ module.exports = function (config) {
222
224
 
223
225
  // Handle worker mode - listen to workers.result event for consolidated results
224
226
  event.dispatcher.on(event.workers.result, (result) => {
225
- // This event is fired in worker mode with consolidated results
226
- // The event.all.result handler above will process the consolidated data
227
+ // Respect CodeceptJS output directory like other plugins
228
+ const outputDir = global.output_dir || './output'
229
+ const outputPath = path.isAbsolute(options.outputFile)
230
+ ? options.outputFile
231
+ : path.resolve(outputDir, options.outputFile)
232
+
233
+ let allFailedTests = []
234
+
235
+ // In worker mode, collect failed tests from consolidated result
236
+ if (result && result.tests) {
237
+ const workerFailedTests = result.tests.filter(test => test.state === 'failed' || test.err)
238
+ console.log('DEBUG: Found', workerFailedTests.length, 'failed tests in worker results')
239
+
240
+ workerFailedTests.forEach(test => {
241
+ const failedTest = {
242
+ title: test.title,
243
+ fullTitle: test.fullTitle || test.title,
244
+ file: test.file || 'unknown',
245
+ uid: test.uid,
246
+ timestamp: new Date().toISOString(),
247
+ }
248
+
249
+ // Add parent suite information
250
+ if (test.parent) {
251
+ failedTest.suite = test.parent.title
252
+ failedTest.suiteFile = test.parent.file
253
+ }
254
+
255
+ // Add error information if available
256
+ if (test.err && options.includeStackTrace) {
257
+ failedTest.error = {
258
+ message: test.err.message || 'Test failed',
259
+ stack: test.err.stack || '',
260
+ name: test.err.name || 'Error',
261
+ }
262
+ }
263
+
264
+ // Add metadata if available
265
+ if (options.includeMetadata) {
266
+ failedTest.metadata = {
267
+ tags: test.tags || [],
268
+ meta: test.meta || {},
269
+ opts: test.opts || {},
270
+ duration: test.duration || 0,
271
+ retries: test.retries || 0,
272
+ }
273
+ }
274
+
275
+ // Add BDD/Gherkin information if available
276
+ if (test.parent && test.parent.feature) {
277
+ failedTest.bdd = {
278
+ feature: test.parent.feature.name || test.parent.title,
279
+ scenario: test.title,
280
+ featureFile: test.parent.file,
281
+ }
282
+ }
283
+
284
+ allFailedTests.push(failedTest)
285
+ })
286
+
287
+ output.print(`Failed Tests Tracker: Collected ${workerFailedTests.length} failed tests from workers`)
288
+ }
289
+
290
+ if (allFailedTests.length === 0) {
291
+ if (options.clearOnSuccess && fs.existsSync(outputPath)) {
292
+ try {
293
+ fs.unlinkSync(outputPath)
294
+ output.print(`Failed Tests Tracker: Cleared previous failed tests file (all tests passed)`)
295
+ } catch (error) {
296
+ output.print(`Failed Tests Tracker: Could not clear failed tests file: ${error.message}`)
297
+ }
298
+ }
299
+ return
300
+ }
301
+
302
+ // Save failed tests to file
303
+ try {
304
+ const failedTestsData = {
305
+ timestamp: new Date().toISOString(),
306
+ totalFailed: allFailedTests.length,
307
+ tests: allFailedTests,
308
+ }
309
+
310
+ // Ensure output directory exists
311
+ const dir = path.dirname(outputPath)
312
+ if (!fs.existsSync(dir)) {
313
+ fs.mkdirSync(dir, { recursive: true })
314
+ }
315
+
316
+ fs.writeFileSync(outputPath, JSON.stringify(failedTestsData, null, 2))
317
+ output.print(`Failed Tests Tracker: Saved ${allFailedTests.length} failed tests to ${outputPath}`)
318
+ } catch (error) {
319
+ output.print(`Failed Tests Tracker: Failed to save failed tests: ${error.message}`)
320
+ }
227
321
  })
228
322
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codeceptjs",
3
- "version": "3.7.5-beta.5",
3
+ "version": "3.7.5-beta.6",
4
4
  "description": "Supercharged End 2 End Testing Framework for NodeJS",
5
5
  "keywords": [
6
6
  "acceptance",