Lewati ke isi

Pengujian

Pengujian Backend

cd packages/backend
pytest tests/ -v
pytest tests/ --cov=. --cov-report=html  # dengan cakupan

Pengujian berada di packages/backend/tests/. CI menegakkan cakupan ≥80%.

Pengujian CLI

cd packages/cli
npm test

Pengujian SDK

cd packages/sdk
npm test

End-to-End

Untuk pengujian integrasi penuh, mulai tumpukan dengan Docker:

docker compose up -d
cd packages/backend && pytest tests/integration/ -v

Python

Ikuti pola yang ada di packages/backend/tests/. Gunakan fixture pytest:

import pytest
from app import create_app

@pytest.fixture
def client():
    app = create_app({"TESTING": True})
    with app.test_client() as client:
        yield client

def test_health(client):
    response = client.get("/health")
    assert response.status_code == 200

TypeScript

Gunakan Vitest atau Jest:

import { describe, it, expect } from "vitest";
import { myFunction } from "../src/myModule.js";

describe("myFunction", () => {
  it("returns expected value", () => {
    expect(myFunction("input")).toBe("expected");
  });
});