From 05706c959897f5a31a25a4950cfe50bf18c1fc6b Mon Sep 17 00:00:00 2001 From: Ahmed Magdy Date: Thu, 16 Apr 2026 15:41:42 +0200 Subject: [PATCH 1/4] fix: add .DS_Store to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index fab6258..9b628b4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ cache/ reports/ +.DS_Store # Created by https://www.toptal.com/developers/gitignore/api/node # Edit at https://www.toptal.com/developers/gitignore?templates=node From b1a604e2f6c586cae9ccf52c039a552e26868b46 Mon Sep 17 00:00:00 2001 From: Ahmed Magdy Date: Thu, 16 Apr 2026 15:41:55 +0200 Subject: [PATCH 2/4] fix: remove input property from meow configuration and add CLI tests for help and version flags --- cli.js | 1 - test/cli.test.js | 33 +++++++++++++++++++++++++++++++-- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/cli.js b/cli.js index 85c80f8..3602b78 100755 --- a/cli.js +++ b/cli.js @@ -194,7 +194,6 @@ const cli = meow(createHelpText(), { allowUnknownFlags: false, importMeta: import.meta, inferType: false, - input: [], flags: CLI_FLAGS, }) diff --git a/test/cli.test.js b/test/cli.test.js index 88444a5..3d7d6e5 100644 --- a/test/cli.test.js +++ b/test/cli.test.js @@ -1,3 +1,25 @@ +import {spawnSync} from 'node:child_process' +import {readFileSync} from 'node:fs' +import {fileURLToPath} from 'node:url' + +const cliPath = fileURLToPath(new URL('../cli.js', import.meta.url)) +const packageJson = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8')) + +/** + * Run the CLI in a child process so the entrypoint is exercised end to end. + * @param {string[]} args - CLI arguments + * @returns {import('node:child_process').SpawnSyncReturns} Child process result + */ +function runCli(args) { + return spawnSync(process.execPath, [cliPath, ...args], { + encoding: 'utf8', + env: { + ...process.env, + GITHUB_TOKEN: '', + }, + }) +} + describe('cli', () => { beforeEach(() => {}) @@ -7,13 +29,20 @@ describe('cli', () => { * Test CLI help functionality */ test('should display help information with --help flag', () => { - // TODO: Implement test logic + const result = runCli(['--help']) + + expect(result.status).toBe(0) + expect(result.stdout).toContain('Usage') + expect(result.stdout).toContain('action-reporting-cli') }) /** * Test CLI version functionality */ test('should display version information with --version flag', () => { - // TODO: Implement test logic + const result = runCli(['--version']) + + expect(result.status).toBe(0) + expect(result.stdout).toContain(packageJson.version) }) }) From ad0e384119036664992549c1c652c15c696a3cd0 Mon Sep 17 00:00:00 2001 From: Ahmed Magdy Date: Thu, 16 Apr 2026 15:51:32 +0200 Subject: [PATCH 3/4] Update test/cli.test.js Overriding DEBUG env var to 'false' Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Ahmed Magdy --- test/cli.test.js | 1 + 1 file changed, 1 insertion(+) diff --git a/test/cli.test.js b/test/cli.test.js index 3d7d6e5..18bc383 100644 --- a/test/cli.test.js +++ b/test/cli.test.js @@ -15,6 +15,7 @@ function runCli(args) { encoding: 'utf8', env: { ...process.env, + DEBUG: 'false', GITHUB_TOKEN: '', }, }) From 580240dccedaa44f3246d986f1989d9dea78245f Mon Sep 17 00:00:00 2001 From: Ahmed Magdy Date: Thu, 16 Apr 2026 15:52:42 +0200 Subject: [PATCH 4/4] Update test/cli.test.js --version test to filer out the last line before checking for the correct value Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Ahmed Magdy --- test/cli.test.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/cli.test.js b/test/cli.test.js index 18bc383..655b9d6 100644 --- a/test/cli.test.js +++ b/test/cli.test.js @@ -42,8 +42,10 @@ describe('cli', () => { */ test('should display version information with --version flag', () => { const result = runCli(['--version']) + const outputLines = result.stdout.trim().split('\n') + const lastLine = outputLines[outputLines.length - 1] expect(result.status).toBe(0) - expect(result.stdout).toContain(packageJson.version) + expect(lastLine).toBe(packageJson.version) }) })