diff --git a/.changeset/silver-peaches-lie.md b/.changeset/silver-peaches-lie.md new file mode 100644 index 00000000..e6867eca --- /dev/null +++ b/.changeset/silver-peaches-lie.md @@ -0,0 +1,5 @@ +--- +"@moonwall/cli": patch +--- + +Force exit on failure diff --git a/packages/cli/src/cmds/entrypoint.ts b/packages/cli/src/cmds/entrypoint.ts index 91373ee6..df898a72 100755 --- a/packages/cli/src/cmds/entrypoint.ts +++ b/packages/cli/src/cmds/entrypoint.ts @@ -104,9 +104,13 @@ yargs(hideBin(process.argv)) async (args) => { if (args.envName) { process.env.MOON_RUN_SCRIPTS = "true"; - (await testCmd(args.envName.toString(), { testNamePattern: args.GrepTest })) - ? process.exit(0) - : process.exit(1); + if (await testCmd(args.envName.toString(), { testNamePattern: args.GrepTest })) { + console.log("✅ All tests passed"); + process.exit(0); + } else { + console.log("❌ Some tests failed"); + process.kill(process.pid, "SIGTERM"); + } } else { console.log("❌ No environment specified"); console.log(`👉 Run 'pnpm moonwall --help' for more information`); diff --git a/packages/cli/src/cmds/runTests.ts b/packages/cli/src/cmds/runTests.ts index a5ff5d55..166b4bb6 100644 --- a/packages/cli/src/cmds/runTests.ts +++ b/packages/cli/src/cmds/runTests.ts @@ -36,7 +36,6 @@ export async function testCmd(envName: string, additionalArgs?: object): Promise const failed = vitest!.state.getFiles().filter((file) => file.result!.state === "fail"); if (failed.length > 0) { - process.stderr.write("Tests failed\n"); return false; } else { return true;