codeceptjs 3.7.5-beta.11 → 3.7.5-beta.13
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 +12 -32
- package/lib/workers.js +4 -7
- package/package.json +1 -1
|
@@ -86,21 +86,14 @@ module.exports = async function (options) {
|
|
|
86
86
|
testPatterns.push(file)
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
//
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
options.stableIds = failedTestStableIds
|
|
89
|
+
// Create a map of exact test titles to target for filtering
|
|
90
|
+
const failedTestTitles = new Set(failedTestsData.tests.map(test => test.title).filter(Boolean))
|
|
91
|
+
|
|
92
|
+
if (failedTestTitles.size > 0) {
|
|
93
|
+
output.print(`Targeting ${failedTestTitles.size} specific failed tests by exact title matching`)
|
|
94
|
+
options.exactTestTitles = Array.from(failedTestTitles)
|
|
96
95
|
} else {
|
|
97
|
-
output.print('
|
|
98
|
-
// Fallback to grep pattern matching if no stable IDs
|
|
99
|
-
const testTitles = failedTestsData.tests.map(test => test.title).filter(Boolean)
|
|
100
|
-
if (testTitles.length > 0) {
|
|
101
|
-
const escapedTitles = testTitles.map(title => title.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'))
|
|
102
|
-
options.grep = new RegExp(`^(${escapedTitles.join('|')})$`)
|
|
103
|
-
}
|
|
96
|
+
output.print('No specific test titles found, running all tests in files')
|
|
104
97
|
}
|
|
105
98
|
} else {
|
|
106
99
|
// Fallback: use test titles with exact match grep
|
|
@@ -217,35 +210,22 @@ async function runWithoutWorkers(config, options, testPatterns, failedTestsData,
|
|
|
217
210
|
codecept.loadTests()
|
|
218
211
|
}
|
|
219
212
|
|
|
220
|
-
// If we have specific test
|
|
221
|
-
if (
|
|
213
|
+
// If we have specific test titles, filter the loaded tests to only include those
|
|
214
|
+
if (options.exactTestTitles && options.exactTestTitles.length > 0) {
|
|
222
215
|
const Container = require('../container')
|
|
223
216
|
const mocha = Container.mocha()
|
|
224
217
|
|
|
225
|
-
// Filter suites to only include tests with matching
|
|
218
|
+
// Filter suites to only include tests with exact matching titles
|
|
226
219
|
for (const suite of mocha.suite.suites) {
|
|
227
220
|
suite.tests = suite.tests.filter(test => {
|
|
228
|
-
|
|
229
|
-
if (options.tests && options.tests.includes(test.uid)) {
|
|
230
|
-
return true
|
|
231
|
-
}
|
|
232
|
-
// Check stable ID match
|
|
233
|
-
if (options.stableIds) {
|
|
234
|
-
const testFile = test.file || test.parent?.file || 'unknown'
|
|
235
|
-
const testTitle = test.title || 'unknown'
|
|
236
|
-
const testStableId = `${testFile}:${testTitle}`
|
|
237
|
-
return options.stableIds.includes(testStableId)
|
|
238
|
-
}
|
|
239
|
-
return false
|
|
221
|
+
return options.exactTestTitles.some(title => title === test.title)
|
|
240
222
|
})
|
|
241
223
|
}
|
|
242
224
|
|
|
243
225
|
// Remove empty suites
|
|
244
226
|
mocha.suite.suites = mocha.suite.suites.filter(suite => suite.tests.length > 0)
|
|
245
227
|
|
|
246
|
-
|
|
247
|
-
const filterCount = options.stableIds ? options.stableIds.length : options.tests.length
|
|
248
|
-
output.print(`Filtered to ${filterCount} specific failed tests by ${filterType}`)
|
|
228
|
+
output.print(`Filtered to ${options.exactTestTitles.length} specific failed tests by exact title matching`)
|
|
249
229
|
}
|
|
250
230
|
|
|
251
231
|
if (options.verbose) {
|
package/lib/workers.js
CHANGED
|
@@ -312,7 +312,7 @@ class Workers extends EventEmitter {
|
|
|
312
312
|
|
|
313
313
|
// If specific tests are provided (e.g., from run-failed-tests), only include those
|
|
314
314
|
const targetTests = this.options && this.options.tests
|
|
315
|
-
const
|
|
315
|
+
const exactTestTitles = this.options && this.options.exactTestTitles
|
|
316
316
|
|
|
317
317
|
mocha.suite.eachTest(test => {
|
|
318
318
|
if (test) {
|
|
@@ -322,12 +322,9 @@ class Workers extends EventEmitter {
|
|
|
322
322
|
if (targetTests && targetTests.length > 0) {
|
|
323
323
|
shouldInclude = targetTests.includes(test.uid)
|
|
324
324
|
}
|
|
325
|
-
// If we have
|
|
326
|
-
else if (
|
|
327
|
-
|
|
328
|
-
const testTitle = test.title || 'unknown'
|
|
329
|
-
const testStableId = `${testFile}:${testTitle}`
|
|
330
|
-
shouldInclude = targetStableIds.includes(testStableId)
|
|
325
|
+
// If we have exact test titles, only include tests with exact matching titles
|
|
326
|
+
else if (exactTestTitles && exactTestTitles.length > 0) {
|
|
327
|
+
shouldInclude = exactTestTitles.some(title => title === test.title)
|
|
331
328
|
}
|
|
332
329
|
|
|
333
330
|
if (shouldInclude) {
|