diff --git a/src/debugtopus/index.ts b/src/debugtopus/index.ts index 0c19c78..29ffe8a 100644 --- a/src/debugtopus/index.ts +++ b/src/debugtopus/index.ts @@ -8,6 +8,7 @@ import { Readable } from "stream"; import { ReadableStream } from "stream/web"; import { promisify } from "util"; +import ora from "ora"; import { Open } from "unzipper"; import { OCTOMIND_FOLDER_NAME } from "../constants"; @@ -292,6 +293,8 @@ export const executeLocalTestCases = async ( ); } + const throbber = ora("Generating code").start(); + let testCases = readTestCasesFromDir(octomindRoot); if (options.testCaseId) { testCases = getFilteredTestCaseWithDependencies( @@ -345,6 +348,8 @@ export const executeLocalTestCases = async ( writeFileSync(dirs.configFilePath, config); + throbber.succeed("Code generated"); + await runTests({ ...dirs, runMode: options.headless ? "headless" : "ui" }); }; diff --git a/src/tools/test-targets.ts b/src/tools/test-targets.ts index 62733d4..12fe8a1 100644 --- a/src/tools/test-targets.ts +++ b/src/tools/test-targets.ts @@ -1,11 +1,13 @@ import path from "path"; +import ora from "ora"; + import { OCTOMIND_FOLDER_NAME } from "../constants"; import { findOctomindFolder } from "../helpers"; import { getUrl } from "../url"; import { client, handleError, ListOptions, logJson } from "./client"; import { push } from "./sync/push"; -import { writeYaml } from "./sync/yaml"; +import { readTestCasesFromDir, writeYaml } from "./sync/yaml"; export const getTestTargets = async () => { const { data, error } = await client.GET("/apiKey/v3/test-targets"); @@ -87,6 +89,7 @@ export const pushTestTarget = async ( `No ${OCTOMIND_FOLDER_NAME} folder found, please pull first.`, ); } + const throbber = ora("Pushing test cases").start(); const data = await push({ ...options, @@ -99,4 +102,6 @@ export const pushTestTarget = async ( if (options.json) { logJson(data); } + + throbber.succeed("Test cases pushed successfully"); }; diff --git a/tests/setup.ts b/tests/setup.ts new file mode 100644 index 0000000..cd22023 --- /dev/null +++ b/tests/setup.ts @@ -0,0 +1,15 @@ +import { beforeEach, vi } from "vitest"; + +vi.mock("ora", () => ({ + default: vi.fn(() => ({ + start: vi.fn().mockReturnThis(), + succeed: vi.fn(), + fail: vi.fn(), + })), +})); + +beforeEach(() => { + console.log = vi.fn(); + console.warn = vi.fn(); + console.error = vi.fn(); +}); diff --git a/vitest.config.ts b/vitest.config.ts index d3ba980..5458813 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -8,5 +8,6 @@ export default defineConfig({ globals: true, environment: 'node', include: ["tests/**/*.spec.ts"], + setupFiles: ["./tests/setup.ts"], }, })