All projects

resty-vscode

Run Resty API tests directly from VSCode with markdown-based test files.

Run Resty API tests directly from VSCode with beautiful markdown-formatted results.

Requirements

Features

โœจ Smart Test Detection - Automatically detects YAML test blocks in .resty and .rest files ๐Ÿš€ Run Single Test - Execute the test block under your cursor with Ctrl+Alt+R ๐Ÿ“ Run All Tests - Execute all tests in the current file with Ctrl+Shift+Alt+R ๐ŸŽฏ Dynamic Context Display - Shows current test name in status bar ๐Ÿ“‹ Side-by-Side Results - Opens results in a new tab with proper syntax highlighting ๐Ÿ”— Clickable Error Links - Click errors to jump directly to the source line โš™๏ธ Configurable - Customize executable path, output format, and behavior

Installation

  1. Install the Resty CLI tool
  2. Install this extension from the VSCode marketplace
  3. Configure the Resty executable path if needed

Usage

Quick Start

  1. Open a .resty or .rest file
  2. Place your cursor inside a YAML test block
  3. Press Ctrl+Alt+R to run the current test
  4. Press Ctrl+Shift+Alt+R to run all tests in the file

Dynamic Context Display

The status bar shows your current location:

Commands

Context Menu

Right-click in .resty/.rest files to access Resty commands.

Configuration

Setting Description Default
resty.executablePath Path to Resty executable resty
resty.defaultOutputFormat Output format (markdown, json, xml, html) markdown
resty.showOutputOnRun Show output automatically true
resty.autoCloseOldResults Close previous result tabs false
resty.tempFileCleanup Clean up temporary files true

Requirements

Supported File Types

Both use the same format: Markdown with embedded YAML test blocks.

Output Formats

Results are displayed with appropriate syntax highlighting:

Test Dependencies

The requires Property

You can specify test dependencies using the requires property. When running a single test, all required dependencies will be executed first in the correct order:

test: get_user_profile
requires: [login_test, setup_user]  # These tests run first
get: https://api.example.com/profile
authorization: Bearer $auth_token

The requires property accepts:

Variables and Include Blocks

Use variables: or include: blocks to define shared variables that all tests in the file can access:

# This block runs automatically before any test
variables:
  base_url: https://api.example.com
  admin_user: admin@example.com
# Include external files or configurations
include:
  - common_variables.yaml
  - auth_config.yaml

Key Features:

Example Test File

# API Test Suite

## Shared Configuration

```yaml
variables:
  base_url: https://api.example.com
  admin_email: admin@example.com
  test_user_id: 12345
``    <-- only using two backticks here to avoid ending the example markdown block

## Authentication Setup

```yaml
test: login
post: $base_url/auth
body: |
  {
    "username": "admin",
    "password": "secret"
  }
success:
  auth_token: $.access_token
  user_id: $.user.id
``    <-- only using two backticks here to avoid ending the example markdown block

## User Management

```yaml
test: create_test_user
requires: login  # Needs auth token from login test
post: $base_url/users
authorization: Bearer $auth_token
body: |
  {
    "email": "test@example.com",
    "name": "Test User"
  }
success:
  created_user_id: $.user.id
``    <-- only using two backticks here to avoid ending the example markdown block

## Profile Operations

```yaml
test: get_user_profile
requires: [login, create_test_user]  # Needs both auth and user creation
get: $base_url/users/$created_user_id
authorization: Bearer $auth_token
expect:
  status: 200
  body:
    email: test@example.com
``    <-- only using two backticks here to avoid ending the example markdown block

## Cleanup

```yaml
test: delete_test_user
requires: [login, create_test_user]  # Cleanup depends on both
delete: $base_url/users/$created_user_id
authorization: Bearer $auth_token
expect:
  status: 204
``    <-- only using two backticks here to avoid ending the example markdown block

Dependency Behavior

Running Individual Tests

When you run a single test (Ctrl+Alt+R):

  1. The extension delegates dependency resolution to the Resty CLI
  2. The CLI automatically includes all required dependencies
  3. Variables are preserved between all blocks, so auth tokens flow correctly
  4. Clear error messages are shown for missing or circular dependencies

Running All Tests

When you run all tests (Ctrl+Shift+Alt+R):

Error Handling

Execution Examples

File contains:

variables: { base_url: ... }
test: login
test: create_user (requires: login)
test: get_profile (requires: [login, create_user])
test: cleanup (requires: create_user)

Running get_profile individually executes:

  1. variables block
  2. login test
  3. create_user test
  4. get_profile test (target)

Running all tests executes:

  1. variables block
  2. login test
  3. create_user test
  4. get_profile test
  5. cleanup test

Troubleshooting

"Resty executable not found"

"Cursor is not in a YAML code block"

Results not showing

"Missing dependency" errors

"Circular dependency detected"

Dependencies not running

Contributing

Found a bug or have a feature request? Please open an issue on the GitHub repository.

License

MIT License - see the LICENSE file for details.


Enjoy testing your APIs with Resty! ๐Ÿš€