codeceptjs 3.7.5-beta.4 → 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 +21 -11
- 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,15 +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 - only
|
|
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
45
|
if (store.hasWorkers) {
|
|
46
46
|
return
|
|
47
47
|
}
|
|
48
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
|
+
|
|
49
59
|
allTestsPassed = false
|
|
50
|
-
|
|
60
|
+
|
|
51
61
|
const failedTest = {
|
|
52
62
|
title: test.title,
|
|
53
63
|
fullTitle: test.fullTitle(),
|
|
@@ -99,27 +109,27 @@ module.exports = function (config) {
|
|
|
99
109
|
event.dispatcher.on(event.all.result, (result) => {
|
|
100
110
|
// Respect CodeceptJS output directory like other plugins
|
|
101
111
|
const outputDir = global.output_dir || './output'
|
|
102
|
-
const outputPath = path.isAbsolute(options.outputFile)
|
|
103
|
-
? options.outputFile
|
|
112
|
+
const outputPath = path.isAbsolute(options.outputFile)
|
|
113
|
+
? options.outputFile
|
|
104
114
|
: path.resolve(outputDir, options.outputFile)
|
|
105
115
|
let allFailedTests = [...failedTests]
|
|
106
116
|
|
|
107
117
|
// In worker mode, collect failed tests from consolidated result
|
|
108
118
|
if (store.hasWorkers && result && result.tests) {
|
|
109
119
|
const workerFailedTests = result.tests.filter(test => test.state === 'failed' || test.err)
|
|
110
|
-
|
|
120
|
+
|
|
111
121
|
// Use a Set to track unique test identifiers to prevent duplicates
|
|
112
122
|
const existingTestIds = new Set(allFailedTests.map(test => test.uid || `${test.file}:${test.title}`))
|
|
113
|
-
|
|
123
|
+
|
|
114
124
|
workerFailedTests.forEach(test => {
|
|
115
125
|
// Create unique identifier for deduplication
|
|
116
126
|
const testId = test.uid || `${test.file || 'unknown'}:${test.title}`
|
|
117
|
-
|
|
127
|
+
|
|
118
128
|
// Skip if we already have this test
|
|
119
129
|
if (existingTestIds.has(testId)) {
|
|
120
130
|
return
|
|
121
131
|
}
|
|
122
|
-
|
|
132
|
+
|
|
123
133
|
const failedTest = {
|
|
124
134
|
title: test.title,
|
|
125
135
|
fullTitle: test.fullTitle || test.title,
|