Skip to content

vanya build

Usage

Terminal window
vanya build [OPTIONS] <FILES>... -o <OUTPUT_DIR>

Description

Transpiles vanya files to the target language specified by the plugin. Generates:

  • Test files in the target language
  • Source maps (.vanyamap) for debugging

Arguments

ArgumentDescription
<FILES>One or more .vanya files to build

Options

OptionDescription
-o, --output <DIR>Output directory (required)
--config <PATH>Path to config file
--format <FORMAT>Output format: raw (default), pytest-function

Output Formats

FormatDescriptionUse Case
rawPlain Python code with sync_playwright() wrapperCustom test runners, scripts
pytest-functionWrapped in def test_...() with proper namingpytest integration (recommended for most users)

For browser tests, use --format pytest-function to generate tests that pytest can discover and run.

Exit codes

CodeMeaning
0Build successful
1Build failed (validation or generation error)

Output structure

out/
├── test_login.py # Generated test
├── test_login.py.vanyamap # Source map
├── test_checkout.py
└── test_checkout.py.vanyamap

Examples

Terminal window
# Build to out/ directory (raw format)
vanya build tests/*.vanya -o out/
# Build for pytest (recommended for browser tests)
vanya build tests/*.vanya -o out/ --format pytest-function
# Build with custom config
vanya build --config ./prod.toml tests/*.vanya -o out/ --format pytest-function

Source maps

Source maps allow tools to map generated code back to the original vanya source. The format is JSON:

{
"source": "login.vanya",
"lines": [
null,
null,
{ "start": 100, "end": 150 },
{ "start": 100, "end": 150 }
]
}

Each index in the lines array corresponds to a generated line number (0-indexed). The value is either null (for generated preamble code with no source) or a span object with start and end byte offsets into the original .vanya file.