# How to Test Pentagi Code Locally: Go Backend and React Frontend Guide

> Test Pentagi code locally with unit tests for Go backend and React frontend. Learn how to run Docker for integration tests. Your essential guide for local development and testing.

- Repository: [VXControl/pentagi](https://github.com/vxcontrol/pentagi)
- Tags: how-to-guide
- Published: 2026-03-21

---

**You can test Pentagi locally by running `go test ./...` in the `backend` directory for Go unit tests and `npm run test` in the `frontend` directory for React component tests, with Docker required for integration tests that spawn containers.**

Pentagi is an autonomous penetration-testing platform built by vxcontrol that combines a Go backend with a React TypeScript frontend. Testing your changes locally before submitting ensures that the REST/GraphQL APIs, agent orchestration, LLM provider integrations, and UI components function correctly across the entire stack.

## Prerequisites

Before testing Pentagi locally, install the following dependencies:

- **Docker and Docker Compose** (or Podman) to run Postgres, Neo4j, Grafana, and sandboxed tool containers.
- **Go 1.22+** to compile the backend and run `go test`.
- **Node.js ≥20** and **npm** to install frontend dependencies and run Vitest.
- **Git** to clone `https://github.com/vxcontrol/pentagi.git`.
- **Make** (optional) for scripted build commands.

## Clone the Repository

```bash
git clone https://github.com/vxcontrol/pentagi.git
cd pentagi

```

All subsequent paths are relative to this root directory.

## Backend Testing (Go)

The backend test suite includes approximately 200+ tests across packages for tools, providers, authentication, and task queues.

### Install Go Dependencies

```bash
cd backend
go mod download

```

### Run the Complete Test Suite

Execute all tests recursively from the backend root:

```bash
go test ./...

```

This command compiles and runs every `*_test.go` file, including integration tests in `backend/pkg/tools` and `backend/pkg/csum` that temporarily spawn Docker containers.

### Test Specific Packages

Filter tests to specific domains to save time during iterative development:

```bash
go test ./pkg/tools                    # Terminal and browser tool tests

go test ./pkg/providers/openai         # OpenAI provider logic

go test ./pkg/queue                    # Async task queue behavior

go test ./pkg/server/auth              # API token validation

```

### Critical Backend Test Files

The following files validate core functionality according to the Pentagi source code:

- **[`backend/pkg/tools/terminal_test.go`](https://github.com/vxcontrol/pentagi/blob/main/backend/pkg/tools/terminal_test.go)**: Tests CLI wrapper, command execution, and output capture logic.
- **[`backend/pkg/tools/browser_test.go`](https://github.com/vxcontrol/pentagi/blob/main/backend/pkg/tools/browser_test.go)**: Validates scraper-browser integration.
- **[`backend/pkg/providers/openai/openai_test.go`](https://github.com/vxcontrol/pentagi/blob/main/backend/pkg/providers/openai/openai_test.go)**: Covers request signing, model selection, and token handling.
- **[`backend/pkg/providers/ollama/ollama_test.go`](https://github.com/vxcontrol/pentagi/blob/main/backend/pkg/providers/ollama/ollama_test.go)**: Tests local Ollama inference and error handling paths.
- **[`backend/pkg/server/auth/api_token_test.go`](https://github.com/vxcontrol/pentagi/blob/main/backend/pkg/server/auth/api_token_test.go)**: Validates API token generation, validation, and revocation.
- **[`backend/pkg/queue/queue_test.go`](https://github.com/vxcontrol/pentagi/blob/main/backend/pkg/queue/queue_test.go)**: Verifies async task retries and queue behavior.
- **[`backend/pkg/csum/chain_summary_e2e_test.go`](https://github.com/vxcontrol/pentagi/blob/main/backend/pkg/csum/chain_summary_e2e_test.go)**: End-to-end chain summarization pipeline.
- **[`backend/cmd/installer/installer_test.go`](https://github.com/vxcontrol/pentagi/blob/main/backend/cmd/installer/installer_test.go)**: Interactive installer wizard logic.

### Debug Failing Tests

Isolate a specific test with verbose logging:

```bash
go test ./pkg/tools -run TestTerminalExec -v

```

For interactive debugging, use Delve:

```bash
dlv test ./pkg/tools -- -test.run TestTerminalExec

```

## Frontend Testing (React + TypeScript)

The React frontend uses Vitest for component and hook validation.

### Install Node Modules

```bash
cd frontend
npm ci

```

### Execute Frontend Tests

Run all TypeScript and TSX tests:

```bash
npm run test

```

Target a specific component:

```bash
npm run test -- src/pages/flows/FlowList.test.tsx

```

### Key Frontend Test Files

- **[`frontend/src/pages/flows/FlowList.test.tsx`](https://github.com/vxcontrol/pentagi/blob/main/frontend/src/pages/flows/FlowList.test.tsx)**: Validates flow list UI rendering and GraphQL query handling.
- **[`frontend/src/components/ui/Button.test.tsx`](https://github.com/vxcontrol/pentagi/blob/main/frontend/src/components/ui/Button.test.tsx)**: Tests reusable button component callbacks.
- **[`frontend/src/hooks/useFlow.test.ts`](https://github.com/vxcontrol/pentagi/blob/main/frontend/src/hooks/useFlow.test.ts)**: Validates custom hook logic for flow CRUD operations.
- **[`frontend/src/lib/apolloClient.test.ts`](https://github.com/vxcontrol/pentagi/blob/main/frontend/src/lib/apolloClient.test.ts)**: Tests Apollo client configuration and error handling.

## Validate Helper Binaries

Pentagi includes CLI utilities `ftester`, `ctester`, and `etester` for isolated tool validation.

Build the binaries:

```bash
cd backend/cmd
go build -o ../bin/ftester ./ftester
go build -o ../bin/ctester ./ctester

```

Run the function tester against a provider configuration:

```bash
../bin/ftester -config examples/configs/openrouter.provider.yml -flow "Test openrouter provider"

```

Validate container sandboxing:

```bash
../bin/ctester -image vxcontrol/nmap -cmd "nmap -sV 127.0.0.1"

```

## End-to-End Validation (Optional)

To verify the complete system including API, agents, and tools:

```bash
docker compose up -d

```

Then trigger a flow via the GraphQL endpoint at `https://localhost:8443/api/v1/graphql` or monitor execution logs:

```bash
docker logs -f pentagi

```

## Pre-Commit Validation Checklist

Align your local checks with the CI pipeline defined in [`.github/workflows/ci.yml`](https://github.com/vxcontrol/pentagi/blob/main/.github/workflows/ci.yml):

```bash

# Backend validation

go test ./...
go vet ./...
golangci-lint run  # if installed

# Frontend validation

npm run lint
npm run test

# Helper binary smoke test

go build ./cmd/ftester
../bin/ftester -config examples/configs/openrouter.provider.yml -flow "CI sanity check"

```

## Summary

- **Backend**: Run `go test ./...` from the `backend` directory to execute 200+ unit and integration tests spanning `backend/pkg/tools`, `backend/pkg/providers`, and `backend/pkg/queue`.
- **Frontend**: Execute `npm run test` in the `frontend` directory to run Vitest against React components and GraphQL clients.
- **Helpers**: Build and run `ftester` and `ctester` from `backend/cmd` to validate provider configurations and container sandboxes.
- **Integration**: Use Docker Compose to spin up the full stack for end-to-end flow execution tests.
- **Debugging**: Use `go test -run TestName -v` for verbose Go output and `dlv test` for interactive debugging.

## Frequently Asked Questions

### Why do my Go tests fail with Docker socket errors?

The test suite in `backend/pkg/tools` and `backend/pkg/csum` spawns containers for integration testing. Ensure your user has permissions to access `/var/run/docker.sock` by adding your account to the `docker` group, or run the tests with appropriate privileges.

### How do I debug a specific failing test in the backend?

Use the `-run` flag to filter by test name and `-v` for verbose output: `go test ./pkg/tools -run TestTerminalExec -v`. For step-through debugging, launch Delve with `dlv test ./pkg/tools -- -test.run TestTerminalExec`.

### What should I do if frontend tests fail due to missing GraphQL schemas?

The React tests depend on the GraphQL schema generated by the backend. Run the installer once or manually copy the schema file: `cp backend/pkg/graph/schema.graphqls frontend/src/graphql/schema.graphqls`, then rerun `npm run test`.

### How do I test a new LLM provider implementation locally?

Create a `*_test.go` file in your new provider directory under `backend/pkg/providers/<your-provider>/`, following the pattern established in [`backend/pkg/providers/openai/openai_test.go`](https://github.com/vxcontrol/pentagi/blob/main/backend/pkg/providers/openai/openai_test.go). Run `go test ./backend/pkg/providers/<your-provider>` to validate request signing, model selection, and error handling.