From 84a157265a66c1521ddc5da40bcf3a5314381c85 Mon Sep 17 00:00:00 2001 From: spideystreet Date: Wed, 11 Mar 2026 16:05:36 +0100 Subject: [PATCH] test(integration): add integration test setup pointing to local API - Create tests/integration/ with setup helper and smoke tests - Exclude integration tests from regular vitest runs - Add test:integration script for separate execution - Smoke tests verify /categories, /domains, /techstacks endpoints --- package.json | 1 + tests/integration/setup.ts | 8 ++++++++ tests/integration/smoke.test.ts | 27 +++++++++++++++++++++++++++ vitest.config.ts | 1 + 4 files changed, 37 insertions(+) create mode 100644 tests/integration/setup.ts create mode 100644 tests/integration/smoke.test.ts diff --git a/package.json b/package.json index 8783116..6b7c1d7 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "dev": "tsc --watch", "start": "node dist/index.js", "test": "vitest run", + "test:integration": "vitest run tests/integration/", "test:watch": "vitest", "lint": "tsc --noEmit", "prepublishOnly": "npm run build" diff --git a/tests/integration/setup.ts b/tests/integration/setup.ts new file mode 100644 index 0000000..68fe50b --- /dev/null +++ b/tests/integration/setup.ts @@ -0,0 +1,8 @@ +import { OSTClient } from "../../src/client.js"; + +const INTEGRATION_API_URL = + process.env.OST_API_URL || "http://localhost:8000"; + +export function createIntegrationClient(): OSTClient { + return new OSTClient(INTEGRATION_API_URL); +} diff --git a/tests/integration/smoke.test.ts b/tests/integration/smoke.test.ts new file mode 100644 index 0000000..64db347 --- /dev/null +++ b/tests/integration/smoke.test.ts @@ -0,0 +1,27 @@ +import { describe, it, expect } from "vitest"; +import { createIntegrationClient } from "./setup.js"; + +const client = createIntegrationClient(); + +describe("Integration smoke tests", () => { + it("lists categories from the local API", async () => { + const categories = await client.listCategories(); + + expect(Array.isArray(categories)).toBe(true); + expect(categories.length).toBeGreaterThan(0); + }); + + it("lists domains from the local API", async () => { + const domains = await client.listDomains(); + + expect(Array.isArray(domains)).toBe(true); + expect(domains.length).toBeGreaterThan(0); + }); + + it("lists tech stacks from the local API", async () => { + const techStacks = await client.listTechStacks(); + + expect(Array.isArray(techStacks)).toBe(true); + expect(techStacks.length).toBeGreaterThan(0); + }); +}); diff --git a/vitest.config.ts b/vitest.config.ts index 3f824fb..43a75db 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -4,5 +4,6 @@ export default defineConfig({ test: { globals: true, environment: "node", + exclude: ["tests/integration/**", "node_modules/**"], }, });