Installation
Installation
Section titled “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)
Installing the CLI
Section titled “Installing the CLI”go install github.com/rlch/scaf/cmd/scaf@latestRequires Go 1.21 or later.
git clone https://github.com/rlch/scaf.gitcd scafgo install ./cmd/scafVerify the installation:
scaf --versionInstalling the LSP
Section titled “Installing the LSP”The language server provides diagnostics and hover information in supported editors.
go install github.com/rlch/scaf/cmd/scaf-lsp@latestConfiguration
Section titled “Configuration”-
Create a configuration file
In your project root, create
.scaf.yaml:neo4j:uri: bolt://localhost:7687username: neo4jpassword: password -
Choose your database
Currently supported:
neo4j— Neo4j with Cypher queries
Coming soon:
postgres/mysql/sqlite— SQL databases
-
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
Multiple Files
Section titled “Multiple Files”Organize your test files however you like — scaf discovers all .scaf files:
# Run all tests in a directoryscaf test queries/
# Run specific filesscaf test queries/users.scaf queries/posts.scafProject Structure
Section titled “Project Structure”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 testsEditor Setup
Section titled “Editor Setup”For the best experience, set up syntax highlighting and LSP support:
- 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",}- Install the Neovim plugin:
{ "rlch/scaf.nvim", dependencies = { "nvim-treesitter/nvim-treesitter" }, config = function() require("scaf").setup({}) end,}- Run
:TSInstall scaf
See Editor Integration for full details.
Verifying Your Setup
Section titled “Verifying Your Setup”Create a simple test file to verify everything works:
fn Ping `RETURN 1 as value`
Ping { test "database responds" { value: 1 }}Run the test:
scaf test test.scafYou should see output like:
.1 passed, 0 failed, 0 skipped (0.02s)Next Steps
Section titled “Next Steps”Now that scaf is installed, learn how to write your first real test:
- Quick Start — Write comprehensive tests
- DSL Overview — Understand the full syntax