From 0d034a1a768b8231dd24c5deef06e00dfe09ae08 Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Sun, 28 May 2023 17:18:57 +0100 Subject: [PATCH] CLI: Change internal displayAvailableReporters to be static No longer dynamically enumerate reporters, which would include the newly added invisible "perf" reporter that is currently browser-only. --- bin/qunit.js | 3 +-- src/cli/find-reporter.js | 9 ++++++--- test/cli/fixtures/expected/tap-outputs.js | 4 ++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/bin/qunit.js b/bin/qunit.js index 9b6b40ee8..500594fcb 100755 --- a/bin/qunit.js +++ b/bin/qunit.js @@ -39,8 +39,7 @@ program const opts = program.opts(); if (opts.reporter === true) { - const requireQUnit = require('../src/cli/require-qunit'); - displayAvailableReporters(requireQUnit().reporters); + displayAvailableReporters(); } const options = { diff --git a/src/cli/find-reporter.js b/src/cli/find-reporter.js index a76c9f2bf..b0e0da3f9 100644 --- a/src/cli/find-reporter.js +++ b/src/cli/find-reporter.js @@ -25,17 +25,20 @@ function findReporter (reporterName, builtin) { } // If we didn't find a reporter, display the available reporters and exit - displayAvailableReporters(builtin, reporterName); + displayAvailableReporters(reporterName); } -function displayAvailableReporters (builtin, inputReporterName) { +function displayAvailableReporters (inputReporterName) { const message = []; if (inputReporterName) { message.push(`No reporter found matching "${inputReporterName}".`); } - const jsReporters = Object.keys(builtin).sort(); + const jsReporters = [ + 'console', + 'tap' + ].sort(); message.push(`Built-in reporters: ${jsReporters.join(', ')}`); const npmReporters = getReportersFromDependencies(); diff --git a/test/cli/fixtures/expected/tap-outputs.js b/test/cli/fixtures/expected/tap-outputs.js index 39c21d78b..1abcd4b72 100644 --- a/test/cli/fixtures/expected/tap-outputs.js +++ b/test/cli/fixtures/expected/tap-outputs.js @@ -172,14 +172,14 @@ ok 5 A-Test > derp 'qunit --reporter does-not-exist': `# stderr No reporter found matching "does-not-exist". -Built-in reporters: console, perf, tap +Built-in reporters: console, tap Extra reporters found among package dependencies: npm-reporter # exit code: 1`, 'qunit --reporter': `# stderr -Built-in reporters: console, perf, tap +Built-in reporters: console, tap Extra reporters found among package dependencies: npm-reporter # exit code: 1`,