codeceptjs 3.7.5-beta.10 → 3.7.5-beta.11

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.
@@ -87,21 +87,19 @@ module.exports = async function (options) {
87
87
  }
88
88
 
89
89
  // Extract exact test UIDs for precise filtering
90
- const failedTestUIDs = failedTestsData.tests
91
- .map(test => test.uid)
92
- .filter(Boolean)
93
-
94
- if (failedTestUIDs.length > 0) {
95
- // Pass UIDs to options for precise test filtering
96
- options.tests = failedTestUIDs
97
- output.print(`Targeting ${failedTestUIDs.length} specific failed tests by UID`)
90
+ // Use stable identifiers (file:title) instead of UIDs since UIDs change between runs
91
+ const failedTestStableIds = failedTestsData.tests.map(test => test.stableId || `${test.file}:${test.title}`).filter(Boolean)
92
+
93
+ if (failedTestStableIds.length > 0) {
94
+ output.print(`Targeting failed tests by stable ID (${failedTestStableIds.length} tests)`)
95
+ options.stableIds = failedTestStableIds
98
96
  } else {
99
- // Fallback to title-based grep if no UIDs available
97
+ output.print('Targeting failed tests by title pattern (no stable IDs available)')
98
+ // Fallback to grep pattern matching if no stable IDs
100
99
  const testTitles = failedTestsData.tests.map(test => test.title).filter(Boolean)
101
100
  if (testTitles.length > 0) {
102
- const grepPattern = testTitles.map(title => `^${title.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}$`).join('|')
103
- options.grep = grepPattern
104
- output.print(`Targeting failed tests by title pattern (no UIDs available)`)
101
+ const escapedTitles = testTitles.map(title => title.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'))
102
+ options.grep = new RegExp(`^(${escapedTitles.join('|')})$`)
105
103
  }
106
104
  }
107
105
  } else {
@@ -219,20 +217,35 @@ async function runWithoutWorkers(config, options, testPatterns, failedTestsData,
219
217
  codecept.loadTests()
220
218
  }
221
219
 
222
- // If we have specific test UIDs, filter the loaded tests to only include those
223
- if (options.tests && options.tests.length > 0) {
220
+ // If we have specific test UIDs or stable IDs, filter the loaded tests to only include those
221
+ if ((options.tests && options.tests.length > 0) || (options.stableIds && options.stableIds.length > 0)) {
224
222
  const Container = require('../container')
225
223
  const mocha = Container.mocha()
226
224
 
227
- // Filter suites to only include tests with matching UIDs
225
+ // Filter suites to only include tests with matching UIDs or stable IDs
228
226
  for (const suite of mocha.suite.suites) {
229
- suite.tests = suite.tests.filter(test => options.tests.includes(test.uid))
227
+ suite.tests = suite.tests.filter(test => {
228
+ // Check UID match first
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
240
+ })
230
241
  }
231
242
 
232
243
  // Remove empty suites
233
244
  mocha.suite.suites = mocha.suite.suites.filter(suite => suite.tests.length > 0)
234
245
 
235
- output.print(`Filtered to ${options.tests.length} specific failed tests by UID`)
246
+ const filterType = options.stableIds ? 'stable ID' : 'UID'
247
+ const filterCount = options.stableIds ? options.stableIds.length : options.tests.length
248
+ output.print(`Filtered to ${filterCount} specific failed tests by ${filterType}`)
236
249
  }
237
250
 
238
251
  if (options.verbose) {
@@ -190,6 +190,8 @@ module.exports = function (config) {
190
190
  fullTitle: testFullTitle,
191
191
  file: filePath,
192
192
  uid: testUid,
193
+ // Add stable identifier for targeting tests across runs
194
+ stableId: `${filePath}:${testTitle}`,
193
195
  timestamp: new Date().toISOString(),
194
196
  }
195
197
 
package/lib/workers.js CHANGED
@@ -312,18 +312,25 @@ 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 targetStableIds = this.options && this.options.stableIds
315
316
 
316
317
  mocha.suite.eachTest(test => {
317
318
  if (test) {
318
- // If we have specific target tests, only include matching UIDs
319
+ let shouldInclude = true
320
+
321
+ // If we have specific target tests by UID, only include matching UIDs
319
322
  if (targetTests && targetTests.length > 0) {
320
- if (targetTests.includes(test.uid)) {
321
- const i = groupCounter % groups.length
322
- groups[i].push(test.uid)
323
- groupCounter++
324
- }
325
- } else {
326
- // Default behavior: include all tests
323
+ shouldInclude = targetTests.includes(test.uid)
324
+ }
325
+ // If we have specific target tests by stable ID, only include matching stable IDs
326
+ else if (targetStableIds && targetStableIds.length > 0) {
327
+ const testFile = test.file || test.parent?.file || 'unknown'
328
+ const testTitle = test.title || 'unknown'
329
+ const testStableId = `${testFile}:${testTitle}`
330
+ shouldInclude = targetStableIds.includes(testStableId)
331
+ }
332
+
333
+ if (shouldInclude) {
327
334
  const i = groupCounter % groups.length
328
335
  groups[i].push(test.uid)
329
336
  groupCounter++
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codeceptjs",
3
- "version": "3.7.5-beta.10",
3
+ "version": "3.7.5-beta.11",
4
4
  "description": "Supercharged End 2 End Testing Framework for NodeJS",
5
5
  "keywords": [
6
6
  "acceptance",