find-cypress-specs 1.44.16 → 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 +34 -39
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.16",
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,36 +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)
67
-
63
+ function getJustTheTestMarkdown(tests, parentName = '', markdown = []) {
68
64
  if (!tests) {
69
65
  return
70
66
  }
71
67
 
68
+ const name = parentName + tests.name
69
+
72
70
  if (tests.type === 'test') {
73
- justNames.push(parentName + tests.name)
71
+ const tags = tests?.tags?.join(', ') ?? ''
72
+
73
+ markdown.push(`| \`${name}\` | ${tags} |`)
74
+
74
75
  return
75
76
  } else if (tests.type === 'suite') {
76
- const prefix = parentName
77
- ? parentName + tests.name + ' / '
78
- : tests.name + ' / '
79
- getJustTheTestNames(tests.tests, prefix, justNames)
80
- if (tests.suites) {
81
- tests.suites.forEach((suite) => {
82
- getJustTheTestNames(suite, prefix, justNames)
83
- })
84
- }
77
+ const prefix = `${name} / `
78
+
79
+ getJustTheTestMarkdown(tests.tests, prefix, markdown)
80
+
81
+ tests.suites?.forEach((suite) => {
82
+ getJustTheTestMarkdown(suite, prefix, markdown)
83
+ })
84
+
85
85
  return
86
86
  }
87
87
 
88
88
  // tests can include regular tests plus suites nodes
89
- tests.forEach((testOrSuite) => {
90
- getJustTheTestNames(testOrSuite, parentName, justNames)
91
- })
92
- return justNames
89
+ tests.forEach((testOrSuite) =>
90
+ getJustTheTestMarkdown(testOrSuite, parentName, markdown),
91
+ )
92
+
93
+ return markdown
93
94
  }
94
95
 
95
96
  /**
@@ -98,31 +99,25 @@ function getJustTheTestNames(tests, parentName = '', justNames = []) {
98
99
  * @returns {string}
99
100
  */
100
101
  function stringMarkdownTests(allInfo) {
102
+ const testWord = (counts) => pluralize('test', counts.tests, true)
103
+
101
104
  const counts = sumTestCounts(allInfo)
102
105
  const specNames = Object.keys(allInfo)
103
106
  const specWord = pluralize('Spec', specNames.length, true)
104
- const testWord = pluralize('test', counts.tests, true)
105
107
 
106
- const title = `| ${specWord} with ${testWord} |\n| --- |\n`
107
- const allInfoString =
108
- title +
109
- specNames
110
- .map((fileName) => {
111
- const fileInfo = allInfo[fileName]
112
- const n = fileInfo.counts.tests
113
- // console.log(fileInfo)
114
-
115
- let specTest =
116
- '| **`' + fileName + '`**' + ` (${n} ${pluralize('test', n)}) |\n`
117
- const testNames = getJustTheTestNames(fileInfo.tests)
118
- testNames.forEach((name) => {
119
- specTest += '| `' + name + '` |\n'
120
- })
121
- return specTest
122
- })
123
- .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
+ })
124
119
 
125
- return allInfoString
120
+ return markdown.join('\n')
126
121
  }
127
122
 
128
123
  module.exports = {