Skip to content

Commit 9f421ea

Browse files
committed
improve test script
1 parent a39fe33 commit 9f421ea

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

epicshop/test.js

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ async function main() {
7979
choices: ['All', ...choices],
8080
multiple: true,
8181
suggest: (input, choices) => {
82-
return matchSorter(choices, input)
82+
return matchSorter(choices, input, { keys: ['name'] })
8383
},
8484
})
8585

@@ -88,6 +88,18 @@ async function main() {
8888
: response.appDisplayNames.map(appDisplayName =>
8989
displayNameMap.get(appDisplayName),
9090
)
91+
92+
// Update this block to use process.argv
93+
const appPattern =
94+
selectedApps.length === allApps.length
95+
? '*'
96+
: selectedApps
97+
.map(app => `${app.exerciseNumber}.${app.stepNumber}.${app.type}`)
98+
.join(',')
99+
const additionalArgsString =
100+
additionalArgs.length > 0 ? ` -- ${additionalArgs.join(' ')}` : ''
101+
console.log(`\nℹ️ To skip the prompt next time, use this command:`)
102+
console.log(`npm test -- ${appPattern}${additionalArgsString}\n`)
91103
}
92104

93105
if (selectedApps.length === 0) {
@@ -124,10 +136,11 @@ async function main() {
124136
console.log('Outputting results of running tests:')
125137
for (const [app, output] of runningProcesses.entries()) {
126138
if (output.hasOutput()) {
127-
console.log(`\nPartial results for ${app.relativePath}:`)
139+
console.log(`\nPartial results for ${app.relativePath}:\n\n`)
128140
output.replay()
141+
console.log('\n\n')
129142
} else {
130-
console.log(`ℹ️ No output captured for ${app.relativePath}`)
143+
console.log(`ℹ️ No output captured for ${app.relativePath}`)
131144
}
132145
}
133146
// Allow some time for output to be written before exiting
@@ -166,19 +179,21 @@ async function main() {
166179

167180
if (exitCode !== 0) {
168181
hasFailures = true
169-
console.error(`\n❌ Tests failed for ${app.relativePath}:`)
182+
console.error(`\n❌ Tests failed for ${app.relativePath}:\n\n`)
170183
output.replay()
184+
console.log('\n\n')
171185
} else {
172186
console.log(`✅ Finished tests for ${app.relativePath}`)
173187
}
174188
} catch (error) {
175189
runningProcesses.delete(app)
176190
hasFailures = true
177191
console.error(
178-
`\n❌ An error occurred while running tests for ${app.relativePath}:`,
192+
`\n❌ An error occurred while running tests for ${app.relativePath}:\n\n`,
179193
)
180194
console.error(error.message)
181195
output.replay()
196+
console.log('\n\n')
182197
}
183198
}),
184199
)

0 commit comments

Comments
 (0)