codeceptjs 3.7.5-beta.3 → 3.7.5-beta.5
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.
- package/lib/plugin/failedTestsTracker.js +25 -10
- package/package.json +1 -1
|
@@ -16,14 +16,14 @@ const defaultConfig = {
|
|
|
16
16
|
* Failed Tests Tracker Plugin for CodeceptJS
|
|
17
17
|
*
|
|
18
18
|
* Tracks failed tests and saves them to a file for later re-execution.
|
|
19
|
-
*
|
|
19
|
+
*
|
|
20
20
|
* ## Configuration
|
|
21
21
|
*
|
|
22
22
|
* ```js
|
|
23
23
|
* "plugins": {
|
|
24
24
|
* "failedTestsTracker": {
|
|
25
25
|
* "enabled": true,
|
|
26
|
-
* "outputFile": "
|
|
26
|
+
* "outputFile": "failed-tests.json",
|
|
27
27
|
* "clearOnSuccess": true,
|
|
28
28
|
* "includeStackTrace": true,
|
|
29
29
|
* "includeMetadata": true
|
|
@@ -39,10 +39,25 @@ module.exports = function (config) {
|
|
|
39
39
|
let allTestsPassed = true
|
|
40
40
|
let workerFailedTests = new Map() // Track failed tests from workers
|
|
41
41
|
|
|
42
|
-
// Track test failures
|
|
42
|
+
// Track test failures - only when not using workers
|
|
43
43
|
event.dispatcher.on(event.test.failed, test => {
|
|
44
|
-
|
|
44
|
+
// Skip if main process is using workers (will collect from consolidated results)
|
|
45
|
+
if (store.hasWorkers) {
|
|
46
|
+
return
|
|
47
|
+
}
|
|
45
48
|
|
|
49
|
+
// Skip if we're in a worker thread (CodeceptJS uses worker_threads)
|
|
50
|
+
try {
|
|
51
|
+
const { isMainThread } = require('worker_threads')
|
|
52
|
+
if (!isMainThread) {
|
|
53
|
+
return
|
|
54
|
+
}
|
|
55
|
+
} catch (e) {
|
|
56
|
+
// worker_threads not available, assume main thread
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
allTestsPassed = false
|
|
60
|
+
|
|
46
61
|
const failedTest = {
|
|
47
62
|
title: test.title,
|
|
48
63
|
fullTitle: test.fullTitle(),
|
|
@@ -94,27 +109,27 @@ module.exports = function (config) {
|
|
|
94
109
|
event.dispatcher.on(event.all.result, (result) => {
|
|
95
110
|
// Respect CodeceptJS output directory like other plugins
|
|
96
111
|
const outputDir = global.output_dir || './output'
|
|
97
|
-
const outputPath = path.isAbsolute(options.outputFile)
|
|
98
|
-
? options.outputFile
|
|
112
|
+
const outputPath = path.isAbsolute(options.outputFile)
|
|
113
|
+
? options.outputFile
|
|
99
114
|
: path.resolve(outputDir, options.outputFile)
|
|
100
115
|
let allFailedTests = [...failedTests]
|
|
101
116
|
|
|
102
117
|
// In worker mode, collect failed tests from consolidated result
|
|
103
118
|
if (store.hasWorkers && result && result.tests) {
|
|
104
119
|
const workerFailedTests = result.tests.filter(test => test.state === 'failed' || test.err)
|
|
105
|
-
|
|
120
|
+
|
|
106
121
|
// Use a Set to track unique test identifiers to prevent duplicates
|
|
107
122
|
const existingTestIds = new Set(allFailedTests.map(test => test.uid || `${test.file}:${test.title}`))
|
|
108
|
-
|
|
123
|
+
|
|
109
124
|
workerFailedTests.forEach(test => {
|
|
110
125
|
// Create unique identifier for deduplication
|
|
111
126
|
const testId = test.uid || `${test.file || 'unknown'}:${test.title}`
|
|
112
|
-
|
|
127
|
+
|
|
113
128
|
// Skip if we already have this test
|
|
114
129
|
if (existingTestIds.has(testId)) {
|
|
115
130
|
return
|
|
116
131
|
}
|
|
117
|
-
|
|
132
|
+
|
|
118
133
|
const failedTest = {
|
|
119
134
|
title: test.title,
|
|
120
135
|
fullTitle: test.fullTitle || test.title,
|