-
-
Notifications
You must be signed in to change notification settings - Fork 1
Testing
Diego Alfonso edited this page Jan 26, 2026
·
2 revisions
PrivUtil maintains 80%+ test coverage across backend and frontend.
make testThis runs both backend and frontend tests.
make test-backend
# or
go test -tags=manual -cover ./...go test -tags=manual -coverprofile=coverage.out ./...
go tool cover -html=coverage.out -o coverage.html
open coverage.htmlinternal/api/
└── grpc_server_test.go # All backend tests
Use table-driven tests:
func TestMyFunction(t *testing.T) {
s := NewServer()
ctx := context.Background()
tests := []struct {
name string
input string
want string
wantError bool
}{
{"valid", "hello", "HELLO", false},
{"empty", "", "", true},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
resp, err := s.MyFunction(ctx, &pb.MyRequest{Input: tt.input})
if err != nil {
t.Fatalf("error = %v", err)
}
if tt.wantError && resp.Error == "" {
t.Error("expected error")
}
if !tt.wantError && resp.Output != tt.want {
t.Errorf("got %v, want %v", resp.Output, tt.want)
}
})
}
}make test-frontend
# or
cd web && npm testcd web && npm run test:watchcd web && npm run test:coverage
# Opens: web/coverage/index.htmlweb/src/test/
├── setup.ts # Test setup (jest-dom)
├── Dashboard.test.tsx # Dashboard component tests
├── ThemeToggle.test.tsx
├── nav.test.ts
└── utils.test.ts
import { describe, it, expect } from "vitest";
import { render, screen, fireEvent } from "@testing-library/react";
import { BrowserRouter } from "react-router-dom";
import { MyComponent } from "../components/MyComponent";
describe("MyComponent", () => {
const renderComponent = () => {
return render(
<BrowserRouter>
<MyComponent />
</BrowserRouter>,
);
};
it("renders title", () => {
renderComponent();
expect(screen.getByText("My Title")).toBeInTheDocument();
});
it("handles user input", () => {
renderComponent();
const input = screen.getByPlaceholderText("Enter...");
fireEvent.change(input, { target: { value: "test" } });
expect(input).toHaveValue("test");
});
});| Area | Target | Current |
|---|---|---|
| Backend (internal/api) | 80% | 82.3% |
| Frontend | 80% | N/A (excludes proto) |
Tests run automatically on:
- Pull requests
- Push to main branch
See .github/workflows/test.yml for configuration.
Getting Started
User Guide
Development
Operations
Community