Skip to content

Installation

scaf consists of several components:

  • scaf CLI — The main command-line tool for running tests
  • scaf-lsp — Language server for editor diagnostics
  • tree-sitter-scaf — Grammar for syntax highlighting
  • scaf.nvim — Neovim plugin (optional)
Terminal window
go install github.com/rlch/scaf/cmd/scaf@latest

Requires Go 1.21 or later.

Verify the installation:

Terminal window
scaf --version

The language server provides diagnostics and hover information in supported editors.

Terminal window
go install github.com/rlch/scaf/cmd/scaf-lsp@latest
  1. Create a configuration file

    In your project root, create .scaf.yaml:

    neo4j:
    uri: bolt://localhost:7687
    username: neo4j
    password: password
  2. Choose your database

    Currently supported:

    • neo4j — Neo4j with Cypher queries

    Coming soon:

    • postgres / mysql / sqlite — SQL databases
  3. Set up your database connection

    Ensure your database is running and accessible. For Neo4j:

    Terminal window
    docker run -d \
    --name neo4j \
    -p 7474:7474 -p 7687:7687 \
    -e NEO4J_AUTH=neo4j/password \
    neo4j:5

Organize your test files however you like — scaf discovers all .scaf files:

Terminal window
# Run all tests in a directory
scaf test queries/
# Run specific files
scaf test queries/users.scaf queries/posts.scaf

A typical project structure:

myproject/
├── .scaf.yaml # Configuration
├── queries/
│ ├── users.scaf # User-related tests
│ ├── posts.scaf # Post-related tests
│ └── shared/
│ └── fixtures.scaf # Shared setup
└── integration/
└── flows.scaf # Integration tests

For the best experience, set up syntax highlighting and LSP support:

  1. Install the tree-sitter grammar:
local parser_config = require("nvim-treesitter.parsers").get_parser_configs()
parser_config.scaf = {
install_info = {
url = "https://github.com/rlch/tree-sitter-scaf",
files = { "src/parser.c" },
branch = "main",
},
filetype = "scaf",
}
  1. Install the Neovim plugin:
{
"rlch/scaf.nvim",
dependencies = { "nvim-treesitter/nvim-treesitter" },
config = function()
require("scaf").setup({})
end,
}
  1. Run :TSInstall scaf

See Editor Integration for full details.

Create a simple test file to verify everything works:

test.scaf
fn Ping `RETURN 1 as value`
Ping {
test "database responds" {
value: 1
}
}

Run the test:

Terminal window
scaf test test.scaf

You should see output like:

.
1 passed, 0 failed, 0 skipped (0.02s)

Now that scaf is installed, learn how to write your first real test: