find-cypress-specs 1.44.15 → 1.45.0

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.
Files changed (3) hide show
  1. package/README.md +1 -1
  2. package/package.json +1 -1
  3. package/src/print.js +37 -38
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  > Find Cypress spec files using the config settings
4
4
 
5
- ![Cypress tests](https://img.shields.io/badge/cy%20tests-E2E%205%20%7C%20component%202-blue)
5
+ ![Cypress tests](https://img.shields.io/badge/cy%20tests-E2E%206%20%7C%20component%202-blue)
6
6
 
7
7
  ```bash
8
8
  $ npx find-cypress-specs
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "find-cypress-specs",
3
- "version": "1.44.15",
3
+ "version": "1.45.0",
4
4
  "description": "Find Cypress spec files using the config settings",
5
5
  "main": "src",
6
6
  "files": [
package/src/print.js CHANGED
@@ -60,32 +60,37 @@ function stringAllInfo(allInfo, tagged) {
60
60
  }
61
61
  }
62
62
 
63
- function getJustTheTestNames(tests, parentName = '', justNames = []) {
64
- // console.log(tests)
65
- // console.log(justNames)
66
- // console.log('parent name "%s"', parentName)
63
+ function getJustTheTestMarkdown(tests, parentName = '', markdown = []) {
64
+ if (!tests) {
65
+ return
66
+ }
67
+
68
+ const name = parentName + tests.name
67
69
 
68
70
  if (tests.type === 'test') {
69
- justNames.push(parentName + tests.name)
71
+ const tags = tests?.tags?.join(', ') ?? ''
72
+
73
+ markdown.push(`| \`${name}\` | ${tags} |`)
74
+
70
75
  return
71
76
  } else if (tests.type === 'suite') {
72
- const prefix = parentName
73
- ? parentName + tests.name + ' / '
74
- : tests.name + ' / '
75
- getJustTheTestNames(tests.tests, prefix, justNames)
76
- if (tests.suites) {
77
- tests.suites.forEach((suite) => {
78
- getJustTheTestNames(suite, prefix, justNames)
79
- })
80
- }
77
+ const prefix = `${name} / `
78
+
79
+ getJustTheTestMarkdown(tests.tests, prefix, markdown)
80
+
81
+ tests.suites?.forEach((suite) => {
82
+ getJustTheTestMarkdown(suite, prefix, markdown)
83
+ })
84
+
81
85
  return
82
86
  }
83
87
 
84
88
  // tests can include regular tests plus suites nodes
85
- tests.forEach((testOrSuite) => {
86
- getJustTheTestNames(testOrSuite, parentName, justNames)
87
- })
88
- return justNames
89
+ tests.forEach((testOrSuite) =>
90
+ getJustTheTestMarkdown(testOrSuite, parentName, markdown),
91
+ )
92
+
93
+ return markdown
89
94
  }
90
95
 
91
96
  /**
@@ -94,31 +99,25 @@ function getJustTheTestNames(tests, parentName = '', justNames = []) {
94
99
  * @returns {string}
95
100
  */
96
101
  function stringMarkdownTests(allInfo) {
102
+ const testWord = (counts) => pluralize('test', counts.tests, true)
103
+
97
104
  const counts = sumTestCounts(allInfo)
98
105
  const specNames = Object.keys(allInfo)
99
106
  const specWord = pluralize('Spec', specNames.length, true)
100
- const testWord = pluralize('test', counts.tests, true)
101
107
 
102
- const title = `| ${specWord} with ${testWord} |\n| --- |\n`
103
- const allInfoString =
104
- title +
105
- specNames
106
- .map((fileName) => {
107
- const fileInfo = allInfo[fileName]
108
- const n = fileInfo.counts.tests
109
- // console.log(fileInfo)
110
-
111
- let specTest =
112
- '| **`' + fileName + '`**' + ` (${n} ${pluralize('test', n)}) |\n`
113
- const testNames = getJustTheTestNames(fileInfo.tests)
114
- testNames.forEach((name) => {
115
- specTest += '| `' + name + '` |\n'
116
- })
117
- return specTest
118
- })
119
- .join('')
108
+ const markdown = [
109
+ `| ${specWord} with ${testWord(counts)} | Tags |`,
110
+ '| --- | --- |',
111
+ ]
112
+
113
+ specNames.forEach((fileName) => {
114
+ const { counts, tests } = allInfo[fileName]
115
+
116
+ markdown.push(`| **\`${fileName}\`** (${testWord(counts)}) ||`)
117
+ markdown.push(...getJustTheTestMarkdown(tests))
118
+ })
120
119
 
121
- return allInfoString
120
+ return markdown.join('\n')
122
121
  }
123
122
 
124
123
  module.exports = {