codeceptjs 3.7.5-beta.14 → 3.7.5-beta.15
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/command/run-failed-tests.js +43 -34
- package/package.json +1 -1
|
@@ -17,19 +17,19 @@ module.exports = async function (options) {
|
|
|
17
17
|
|
|
18
18
|
const configFile = options.config
|
|
19
19
|
let config = getConfig(configFile)
|
|
20
|
-
|
|
20
|
+
|
|
21
21
|
if (options.override) {
|
|
22
22
|
config = Config.append(JSON.parse(options.override))
|
|
23
23
|
}
|
|
24
|
-
|
|
24
|
+
|
|
25
25
|
const testRoot = getTestRoot(configFile)
|
|
26
26
|
createOutputDir(config, testRoot)
|
|
27
27
|
|
|
28
28
|
// Determine failed tests file path - respect CodeceptJS output directory
|
|
29
29
|
const failedTestsFile = options.file || 'failed-tests.json'
|
|
30
30
|
const failedTestsPath = path.isAbsolute(failedTestsFile)
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
? failedTestsFile
|
|
32
|
+
: path.resolve(global.output_dir || './output', failedTestsFile)
|
|
33
33
|
|
|
34
34
|
// Check if failed tests file exists
|
|
35
35
|
if (!fs.existsSync(failedTestsPath)) {
|
|
@@ -85,10 +85,10 @@ module.exports = async function (options) {
|
|
|
85
85
|
for (const [file, tests] of testsByFile) {
|
|
86
86
|
testPatterns.push(file)
|
|
87
87
|
}
|
|
88
|
-
|
|
88
|
+
|
|
89
89
|
// Create a map of exact test titles to target for filtering
|
|
90
90
|
const failedTestTitles = new Set(failedTestsData.tests.map(test => test.title).filter(Boolean))
|
|
91
|
-
|
|
91
|
+
|
|
92
92
|
if (failedTestTitles.size > 0) {
|
|
93
93
|
output.print(`Targeting ${failedTestTitles.size} specific failed tests by exact title matching`)
|
|
94
94
|
options.exactTestTitles = Array.from(failedTestTitles)
|
|
@@ -116,7 +116,7 @@ module.exports = async function (options) {
|
|
|
116
116
|
async function runWithWorkers(config, options, testPatterns, failedTestsData) {
|
|
117
117
|
const numberOfWorkers = parseInt(options.workers, 10)
|
|
118
118
|
const overrideConfigs = tryOrDefault(() => JSON.parse(options.override || '{}'), {})
|
|
119
|
-
|
|
119
|
+
|
|
120
120
|
// Determine test split strategy
|
|
121
121
|
let by = 'test' // default for failed tests
|
|
122
122
|
if (options.by) {
|
|
@@ -181,7 +181,7 @@ async function runWithWorkers(config, options, testPatterns, failedTestsData) {
|
|
|
181
181
|
}
|
|
182
182
|
})
|
|
183
183
|
output.print('')
|
|
184
|
-
|
|
184
|
+
|
|
185
185
|
const { getMachineInfo } = require('./info')
|
|
186
186
|
await getMachineInfo()
|
|
187
187
|
}
|
|
@@ -210,40 +210,49 @@ async function runWithoutWorkers(config, options, testPatterns, failedTestsData,
|
|
|
210
210
|
codecept.loadTests()
|
|
211
211
|
}
|
|
212
212
|
|
|
213
|
-
// If we have specific test titles,
|
|
213
|
+
// If we have specific test titles, use exact matching
|
|
214
214
|
if (options.exactTestTitles && options.exactTestTitles.length > 0) {
|
|
215
|
+
// Store the exact failed tests globally for runtime verification
|
|
216
|
+
global.__EXACT_FAILED_TESTS__ = failedTestsData.tests.map(test => ({
|
|
217
|
+
fullTitle: test.fullTitle,
|
|
218
|
+
stableId: test.stableId,
|
|
219
|
+
title: test.title,
|
|
220
|
+
file: test.file
|
|
221
|
+
}))
|
|
222
|
+
|
|
223
|
+
// Override the test loading mechanism to filter tests after loading
|
|
215
224
|
const Container = require('../container')
|
|
216
225
|
const mocha = Container.mocha()
|
|
217
226
|
|
|
218
|
-
//
|
|
219
|
-
mocha.loadFiles()
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
const filterSuite = (suite) => {
|
|
223
|
-
// Filter direct tests in this suite
|
|
224
|
-
suite.tests = suite.tests.filter(test => {
|
|
225
|
-
return options.exactTestTitles.some(title => title === test.title)
|
|
226
|
-
})
|
|
227
|
+
// Override Mocha's loadFiles to filter tests after loading
|
|
228
|
+
const originalLoadFiles = mocha.loadFiles.bind(mocha)
|
|
229
|
+
mocha.loadFiles = function() {
|
|
230
|
+
const result = originalLoadFiles()
|
|
227
231
|
|
|
228
|
-
//
|
|
229
|
-
suite
|
|
232
|
+
// Filter the suite after files are loaded to ensure only exact matches run
|
|
233
|
+
const filterSuite = (suite) => {
|
|
234
|
+
// Filter direct tests in this suite
|
|
235
|
+
suite.tests = suite.tests.filter(test => {
|
|
236
|
+
const testFullTitle = test.fullTitle()
|
|
237
|
+
return global.__EXACT_FAILED_TESTS__.some(failedTest =>
|
|
238
|
+
failedTest.fullTitle === testFullTitle
|
|
239
|
+
)
|
|
240
|
+
})
|
|
241
|
+
|
|
242
|
+
// Recursively filter child suites
|
|
243
|
+
suite.suites.forEach(childSuite => filterSuite(childSuite))
|
|
244
|
+
|
|
245
|
+
// Remove empty child suites
|
|
246
|
+
suite.suites = suite.suites.filter(childSuite =>
|
|
247
|
+
childSuite.tests.length > 0 || childSuite.suites.length > 0
|
|
248
|
+
)
|
|
249
|
+
}
|
|
230
250
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
childSuite.tests.length > 0 || childSuite.suites.length > 0
|
|
234
|
-
)
|
|
251
|
+
filterSuite(this.suite)
|
|
252
|
+
return result
|
|
235
253
|
}
|
|
236
254
|
|
|
237
|
-
|
|
238
|
-
filterSuite(mocha.suite)
|
|
239
|
-
|
|
240
|
-
output.print(`Filtered to ${options.exactTestTitles.length} specific failed tests by exact title matching`)
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
if (options.verbose) {
|
|
244
|
-
global.debugMode = true
|
|
245
|
-
const { getMachineInfo } = require('./info')
|
|
246
|
-
await getMachineInfo()
|
|
255
|
+
output.print(`Filtered to ${failedTestsData.tests.length} specific failed tests using exact matching`)
|
|
247
256
|
}
|
|
248
257
|
|
|
249
258
|
// Display information about what we're running
|