codeceptjs 3.7.5-beta.13 → 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.
@@ -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
- ? failedTestsFile
32
- : path.resolve(global.output_dir || './output', failedTestsFile)
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,28 +210,49 @@ async function runWithoutWorkers(config, options, testPatterns, failedTestsData,
210
210
  codecept.loadTests()
211
211
  }
212
212
 
213
- // If we have specific test titles, filter the loaded tests to only include those
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
- // Filter suites to only include tests with exact matching titles
219
- for (const suite of mocha.suite.suites) {
220
- suite.tests = suite.tests.filter(test => {
221
- return options.exactTestTitles.some(title => title === test.title)
222
- })
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()
231
+
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
+ }
250
+
251
+ filterSuite(this.suite)
252
+ return result
223
253
  }
224
254
 
225
- // Remove empty suites
226
- mocha.suite.suites = mocha.suite.suites.filter(suite => suite.tests.length > 0)
227
-
228
- output.print(`Filtered to ${options.exactTestTitles.length} specific failed tests by exact title matching`)
229
- }
230
-
231
- if (options.verbose) {
232
- global.debugMode = true
233
- const { getMachineInfo } = require('./info')
234
- await getMachineInfo()
255
+ output.print(`Filtered to ${failedTestsData.tests.length} specific failed tests using exact matching`)
235
256
  }
236
257
 
237
258
  // Display information about what we're running
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codeceptjs",
3
- "version": "3.7.5-beta.13",
3
+ "version": "3.7.5-beta.15",
4
4
  "description": "Supercharged End 2 End Testing Framework for NodeJS",
5
5
  "keywords": [
6
6
  "acceptance",