From 58db8e5160eb1f33696a2a45143da53ce4c14850 Mon Sep 17 00:00:00 2001 From: Alin Eugen Deac Date: Sat, 2 Nov 2024 11:17:10 +0100 Subject: [PATCH] Add test for invoking via npx Also, this replaces the previous tmp.test.js --- tests/cli/packages/cli/bin/npx.test.js | 26 ++++++++++++++++++++++++++ tests/cli/tmp.test.js | 23 ----------------------- 2 files changed, 26 insertions(+), 23 deletions(-) create mode 100644 tests/cli/packages/cli/bin/npx.test.js delete mode 100644 tests/cli/tmp.test.js diff --git a/tests/cli/packages/cli/bin/npx.test.js b/tests/cli/packages/cli/bin/npx.test.js new file mode 100644 index 00000000..1ccfa077 --- /dev/null +++ b/tests/cli/packages/cli/bin/npx.test.js @@ -0,0 +1,26 @@ +import { describe, it } from 'node:test'; +import * as assert from "node:assert"; +import { exec } from "node:child_process" + +describe('@aedart/cli', () => { + + describe('bin', () => { + + describe('npx', () => { + + it('can invoke cli application via npx', async () => { + return exec('npx ion', (error, stdout, stderr) => { + // console.log('stdout', stdout); + // console.error('stderr', stderr); + // console.log('code', error.code); + + assert.ok(error === null, `Error encountered from Cli Application: ${error?.message}`); + assert.ok(stdout.length !== 0, 'Cli application failed to output default "help"'); + }).on('exit', (code) => { + const expected = 0; + assert.equal(code, expected, `Expected exist code ${expected}, but received: ${code} from cli application`); + }); + }); + }); + }); +}); \ No newline at end of file diff --git a/tests/cli/tmp.test.js b/tests/cli/tmp.test.js deleted file mode 100644 index c3a7e0da..00000000 --- a/tests/cli/tmp.test.js +++ /dev/null @@ -1,23 +0,0 @@ -import { describe, it } from 'node:test'; -import * as assert from "node:assert"; -import { exec } from "node:child_process" - -/** - * TODO: Testing nodejs - dummy file to be removed again! - */ -describe('TODO', () => { - - it('should work', () => { - assert.ok(true); - }); - - // it('can invoke cli application via npx', async () => { - // return exec('npx ion', (error, stdout,stderr) => { - // // console.log('stdout', stdout); - // // console.error('stderr', stderr); - // // console.log('code', error.code); - // - // assert.equal(error.code, 1, `Incorrect exit code: (${error.code})`); - // }); - // }); -}); \ No newline at end of file