diff --git a/packages/run-run/src/program/__tests__/__snapshots__/snapshots.test.ts.snap b/packages/run-run/src/program/__tests__/__snapshots__/snapshots.test.ts.snap index 52425b6..92bf829 100644 --- a/packages/run-run/src/program/__tests__/__snapshots__/snapshots.test.ts.snap +++ b/packages/run-run/src/program/__tests__/__snapshots__/snapshots.test.ts.snap @@ -1,6 +1,6 @@ // Bun Snapshot v1, https://goo.gl/fbAQLP -exports[`should match command: "help" 1`] = ` +exports[`should match all root commands: root-command-help 1`] = ` "๐ŸฆŠ R U N - R U N: The CLI toolbox to fullstack common scripts in Variable Land ๐Ÿ‘Š Usage: rr|run-run [options] @@ -27,7 +27,7 @@ Acknowledgment: " `; -exports[`should match command: "--help" 1`] = ` +exports[`should match all root commands: root-command---help 1`] = ` "๐ŸฆŠ R U N - R U N: The CLI toolbox to fullstack common scripts in Variable Land ๐Ÿ‘Š Usage: rr|run-run [options] @@ -54,17 +54,17 @@ Acknowledgment: " `; -exports[`should match command: "--version" 1`] = ` +exports[`should match all root commands: root-command---version 1`] = ` "0.0.0-test " `; -exports[`should match command: "-v" 1`] = ` +exports[`should match all root commands: root-command--v 1`] = ` "0.0.0-test " `; -exports[`should match help message for command "run" 1`] = ` +exports[`should match help messages for all commands: help-command-run 1`] = ` "Usage: rr run [options] Arguments: @@ -75,7 +75,7 @@ Options: " `; -exports[`should match help message for command "check" 1`] = ` +exports[`should match help messages for all commands: help-command-check 1`] = ` "Usage: rr check|test:static [options] check format and lint issues ๐Ÿ” @@ -89,7 +89,7 @@ Under the hood, this command uses the biome CLI to check the code. " `; -exports[`should match help message for command "lint" 1`] = ` +exports[`should match help messages for all commands: help-command-lint 1`] = ` "Usage: rr lint [options] lint the code ๐Ÿงน @@ -103,7 +103,7 @@ Under the hood, this command uses the biome CLI to lint the code. " `; -exports[`should match help message for command "fmt" 1`] = ` +exports[`should match help messages for all commands: help-command-fmt 1`] = ` "Usage: rr fmt|format [options] format the code ๐ŸŽจ @@ -117,7 +117,7 @@ Under the hood, this command uses the biome CLI to format the code. " `; -exports[`should match help message for command "tsc" 1`] = ` +exports[`should match help messages for all commands: help-command-tsc 1`] = ` "Usage: rr tsc|typecheck [options] check if TypeScript code is well typed ๐ŸŽจ @@ -129,7 +129,7 @@ Under the hood, this command uses the TypeScript CLI to check the code. " `; -exports[`should match help message for command "clean" 1`] = ` +exports[`should match help messages for all commands: help-command-clean 1`] = ` "Usage: rr clean [options] delete dirty folders or files such as node_modules, etc ๐Ÿ—‘๏ธ @@ -143,7 +143,7 @@ Under the hood, this command uses the rimraf.js to delete dirty folders or files " `; -exports[`should match help message for command "tools" 1`] = ` +exports[`should match help messages for all commands: help-command-tools 1`] = ` "Usage: rr tools [options] [command] expose the internal tools ๐Ÿ› ๏ธ diff --git a/packages/run-run/src/program/__tests__/snapshots.test.ts b/packages/run-run/src/program/__tests__/snapshots.test.ts index e49d6e1..6c6d0cb 100644 --- a/packages/run-run/src/program/__tests__/snapshots.test.ts +++ b/packages/run-run/src/program/__tests__/snapshots.test.ts @@ -10,20 +10,29 @@ afterEach(() => { mocked($).mockClear(); }); -for (const cmd of rootCommands) { - test(`should match command: "${cmd}"`, async () => { - const { stdout } = await execCli(cmd); - - expect(stdout).toMatchSnapshot(); - }); -} - -for (const command of program.commands) { - const cmd = command.name(); - - test(`should match help message for command "${cmd}"`, async () => { - const { stdout } = await execCli(`${cmd} --help`); +test("should match all root commands", async () => { + const results = await Promise.all( + rootCommands.map(async (cmd) => { + const { stdout } = await execCli(cmd); + return { cmd, output: stdout }; + }), + ); + + for (const { cmd, output } of results) { + expect(output).toMatchSnapshot(`root-command-${cmd}`); + } +}); - expect(stdout).toMatchSnapshot(); - }); -} +test("should match help messages for all commands", async () => { + const results = await Promise.all( + program.commands.map(async (command) => { + const cmd = command.name(); + const { stdout } = await execCli(`${cmd} --help`); + return { cmd, output: stdout }; + }), + ); + + for (const { cmd, output } of results) { + expect(output).toMatchSnapshot(`help-command-${cmd}`); + } +});