find-cypress-specs 1.30.0 → 1.30.2

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/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # find-cypress-specs [![renovate-app badge][renovate-badge]][renovate-app] ![cypress version](https://img.shields.io/badge/cypress-12.7.0-brightgreen) [![ci](https://github.com/bahmutov/find-cypress-specs/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/bahmutov/find-cypress-specs/actions/workflows/ci.yml)
1
+ # find-cypress-specs [![renovate-app badge][renovate-badge]][renovate-app] ![cypress version](https://img.shields.io/badge/cypress-12.8.0-brightgreen) [![ci](https://github.com/bahmutov/find-cypress-specs/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/bahmutov/find-cypress-specs/actions/workflows/ci.yml)
2
2
 
3
3
  > Find Cypress spec files using the config settings
4
4
 
@@ -159,6 +159,7 @@ $ npx find-cypress-specs --names --tagged <tag1>,<tag2>,<tag3>,...
159
159
  # finds all specs and tests, then filters the output showing all tests
160
160
  # tagged with tag1 or tag2 or tag3 or ...
161
161
  ```
162
+
162
163
  ## File names filtered by a tag
163
164
 
164
165
  ```
@@ -257,6 +258,12 @@ Finding tests in the individual specs uses [find-test-names](https://github.com/
257
258
  $ DEBUG=find-cypress-specs,find-test-names npx find-cypress-specs --names
258
259
  ```
259
260
 
261
+ To debug finding changed specs against a branch, use `find-cypress-specs:git`
262
+
263
+ ```
264
+ $ DEBUG=find-cypress-specs:git npx find-cypress-specs --branch main
265
+ ```
266
+
260
267
  ## Videos
261
268
 
262
269
  - [Use Ava Snapshots And Execa-wrap To Write End-to-End Tests For CLI Utilities](https://youtu.be/rsw17RqP0G0)
package/bin/find.js CHANGED
@@ -60,15 +60,8 @@ debug('arguments %o', args)
60
60
  const specType = args['--component'] ? 'component' : 'e2e'
61
61
 
62
62
  const specs = getSpecs(undefined, specType)
63
- if (args['--tagged']) {
64
- const { jsonResults, tagTestCounts } = getTests(specs, {
65
- tags: args['--tags'],
66
- tagged: args['--tagged'],
67
- skipped: args['--skipped'],
68
- })
69
- const str = stringAllInfo(jsonResults, true)
70
- console.log(str)
71
- } else if (args['--names'] || args['--tags']) {
63
+
64
+ if (args['--names'] || args['--tags'] || args['--tagged']) {
72
65
  // counts the number of tests for each tag across all specs
73
66
  const { jsonResults, tagTestCounts } = getTests(specs, {
74
67
  tags: args['--tags'],
@@ -110,6 +103,12 @@ if (args['--tagged']) {
110
103
  console.log(table)
111
104
  }
112
105
  }
106
+
107
+ if (!args['--names'] && !args['--tags']) {
108
+ debug('printing the spec names list only')
109
+ const specNames = Object.keys(jsonResults).join(',')
110
+ console.log(specNames)
111
+ }
113
112
  } else if (args['--branch']) {
114
113
  debug('determining specs changed against branch %s', args['--branch'])
115
114
  let changedFiles = findChangedFiles(args['--branch'], args['--parent'])
@@ -207,5 +206,6 @@ if (args['--tagged']) {
207
206
  console.log(changedSpecs.join(','))
208
207
  }
209
208
  } else {
209
+ debug('printing just %d spec names', specs.length)
210
210
  console.log(specs.join(','))
211
211
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "find-cypress-specs",
3
- "version": "1.30.0",
3
+ "version": "1.30.2",
4
4
  "description": "Find Cypress spec files using the config settings",
5
5
  "main": "src",
6
6
  "files": [
@@ -47,7 +47,7 @@
47
47
  "homepage": "https://github.com/bahmutov/find-cypress-specs#readme",
48
48
  "devDependencies": {
49
49
  "ava": "^4.0.0",
50
- "cypress": "12.7.0",
50
+ "cypress": "12.8.0",
51
51
  "execa-wrap": "^1.4.0",
52
52
  "prettier": "^2.5.1",
53
53
  "really-need": "^1.9.2",
package/src/index.js CHANGED
@@ -3,6 +3,7 @@ const { getTestNames, countTags } = require('find-test-names')
3
3
  const { pickTaggedTestsFrom, leavePendingTestsOnly } = require('../src/tagged')
4
4
 
5
5
  const debug = require('debug')('find-cypress-specs')
6
+ const debugGit = require('debug')('find-cypress-specs:git')
6
7
  const fs = require('fs')
7
8
  const path = require('path')
8
9
  const globby = require('globby')
@@ -294,25 +295,25 @@ function findChangedFiles(branch, useParent) {
294
295
  }
295
296
 
296
297
  // can we find updated and added files?
297
- debug('finding changed files against %s', branch)
298
- debug('using parent?', useParent)
298
+ debugGit('finding changed files against %s', branch)
299
+ debugGit('using parent?', useParent)
299
300
 
300
301
  if (useParent) {
301
302
  let result = shell.exec(`git merge-base origin/${branch} HEAD`, {
302
303
  silent: true,
303
304
  })
304
305
  if (result.code !== 0) {
305
- debug('git failed to find merge base with the branch %s', branch)
306
+ debugGit('git failed to find merge base with the branch %s', branch)
306
307
  return []
307
308
  }
308
309
 
309
310
  const commit = result.stdout.trim()
310
- debug('merge commit with branch "%s" is %s', branch, commit)
311
+ debugGit('merge commit with branch "%s" is %s', branch, commit)
311
312
  result = shell.exec(`git diff --name-only --diff-filter=AMR ${commit}..`, {
312
313
  silent: true,
313
314
  })
314
315
  if (result.code !== 0) {
315
- debug('git diff failed with code %d', result.code)
316
+ debugGit('git diff failed with code %d', result.code)
316
317
  return []
317
318
  }
318
319
 
@@ -320,14 +321,19 @@ function findChangedFiles(branch, useParent) {
320
321
  .split('\n')
321
322
  .map((s) => s.trim())
322
323
  .filter(Boolean)
324
+ debugGit(
325
+ 'found %d changed files against branch %s',
326
+ filenames.length,
327
+ branch,
328
+ )
323
329
  return filenames
324
330
  } else {
325
331
  const command = `git diff --name-only --diff-filter=AMR origin/${branch}`
326
- debug('command: %s', command)
332
+ debugGit('command: %s', command)
327
333
 
328
334
  const result = shell.exec(command, { silent: true })
329
335
  if (result.code !== 0) {
330
- debug('git diff failed with code %d', result.code)
336
+ debugGit('git diff failed with code %d', result.code)
331
337
  return []
332
338
  }
333
339
 
@@ -335,7 +341,7 @@ function findChangedFiles(branch, useParent) {
335
341
  .split('\n')
336
342
  .map((s) => s.trim())
337
343
  .filter(Boolean)
338
- debug(
344
+ debugGit(
339
345
  'found %d changed %s',
340
346
  filenames.length,
341
347
  pluralize('file', filenames.length),
@@ -398,7 +404,7 @@ function getTests(specs, options = {}) {
398
404
  .split(',')
399
405
  .map((s) => s.trim())
400
406
  .filter(Boolean)
401
- debug('filtering all tests by tag "%o"', splitTags)
407
+ debug('filtering all tests by tag %o', splitTags)
402
408
  pickTaggedTestsFrom(jsonResults, splitTags)
403
409
  // recompute the number of tests
404
410
  addCounts(jsonResults)