Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion packages/cli/src/commands/pw-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,8 @@ export default class PwTestCommand extends AuthCommand {
const checkBundles = Object.values(projectBundle.data.check)

if (!checkBundles.length) {
this.log(`Unable to find checks to run`)
this.style.shortError('Unable to find checks to run.')
this.style.shortInfo('Check your Playwright configuration to ensure it targets your test files.')
return
}

Expand Down Expand Up @@ -305,10 +306,15 @@ export default class PwTestCommand extends AuthCommand {
}, links))
})

const noTestsFoundChecks = new Set<string>()

runner.on(Events.CHECK_SUCCESSFUL,
(sequenceId: SequenceId, check, result, testResultId, links?: TestResultsShortLinks) => {
if (result.hasFailures) {
process.exitCode = 1
if (noTestsFoundChecks.has(check.logicalId)) {
this.style.shortInfo('Check your Playwright configuration to ensure it targets your test files.')
}
}

reporters.forEach(r => r.onCheckEnd(sequenceId, {
Expand All @@ -326,6 +332,9 @@ export default class PwTestCommand extends AuthCommand {
hasFailures: true,
runError: message,
}))
if (message.includes('No tests found')) {
this.style.shortInfo('Check your Playwright configuration to ensure it targets your test files.')
}
process.exitCode = 1
})
runner.on(Events.RUN_FINISHED, () => reporters.forEach(r => r.onEnd()))
Expand All @@ -335,6 +344,10 @@ export default class PwTestCommand extends AuthCommand {
})
runner.on(Events.STREAM_LOGS, (check: any, sequenceId: SequenceId, logs) => {
reporters.forEach(r => r.onStreamLogs(check, sequenceId, logs))
const hasNoTestsFound = logs.some((log: { message: string }) => log.message?.includes('No tests found'))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels quite brittle and I can already see us forgetting to update the message in both places, but I don't have a better solution that would be as easy to implement. 🤷

if (hasNoTestsFound) {
noTestsFoundChecks.add(check.logicalId)
}
})
await runner.run()
}
Expand Down