Unit Testing, Integration Verification, and End-to-End Testing Guide
Reliability is a first-class citizen in TechScript WebForge. The ecosystem provides built-in test runners for unit testing language code, integration testing full-stack HTTP endpoints, and validating production build artifacts.
Tests are placed in the tests/ directory and follow the *_test.txs naming convention:
// tests/math_test.txs
test "addition works properly":
let result = 2 + 2
assert result == 4
test "string concatenation":
let greeting = "Hello, " + "WebForge"
assert greeting == "Hello, WebForge"
To run all project tests:
techscript testWebForge's compiler and runtime include a dedicated test suite (cli/tests/webforge_e2e_tests.rs) covering the 4 core workflows:
test_webforge_interactive_site: Validates compilation of declarative website declarations, buttons, input fields, and event listeners into a cohesive DOM tree.test_webforge_notes_sqlite_site: Verifies automated SQLite schema migration, table creation, and API route generation for persistent data storage.test_webforge_3d_webgl_scene: Validates Three.js 3D scene AST lowering, camera setup, lighting, and WebGL canvas mounting.test_webforge_production_build_generation: Validates thattechscript build web --releaseproduces validdist/index.html,dist/styles.css,dist/app.js, anddist/schema.sqlfiles.
Run the test suite using Cargo:
cargo test --test webforge_e2e_testsYou can write automated integration tests to probe running WebForge servers:
# Start server in test background mode
techscript dev --port 3001 &
# Execute curl verification
curl -f -X GET http://127.0.0.1:3001/api/notes || exit 1Example GitHub Actions workflow (.github/workflows/ci.yml):
name: CI
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Run Test Suite
run: cargo test --workspace
- name: Verify WebForge Production Build
run: cargo run -p techscript_cli -- build web --release