Skip to content

API Testing in VS Code: Tests & Assertions

What is API Testing in VS Code?

API testing in VS Code allows developers to send HTTP requests, validate responses, and automate API tests directly inside the editor without tools like Postman.

Postmate Client enables this with built-in tabular tests and JavaScript assertions.

Postmate Client lets you validate and automate API responses directly inside VS Code — as a fast, private Postman alternative.

No cloud sync. No login. No configuration.

Postmate Client supports two powerful ways to test APIs:

  • Tabular Tests (No-Code) → Quick validations using a simple UI
  • Script Assertions (JavaScript) → Advanced testing using Postman-style pm APIs

Tabular Tests (No-Code API Testing)

Quickly validate API responses without writing code.

Perfect for:

  • Status code checks
  • JSON field validation
  • Response time assertions
  • Environment variable extraction

How to Create a Test

  1. Open any request in Postmate Client
  2. Go to Post-request → Test
  3. Add rows — each row = one test

Test Table Columns

ColumnPurpose
Test TypeSelect what to validate (status, body, env variable, etc.)
ActionOperation (equals, contains, less than, etc.)
Expected Value / VariableExpected result or variable name
DescriptionLabel shown in test results

Tabular Test Interface

Supported Test Types

Validate JSON Response Body

Use In The Response Body to validate any JSON field.

  • Supports: equals, contains, exists, etc.
  • Works with deeply nested JSON

Smart JSONPath Autocomplete

Run your request once → Postmate Client indexes the response →
Start typing $. and get instant suggestions for all fields.

Automatic JSON path suggestions

Validate HTTP Status Code

Use Response Code to assert API status (200, 201, 400, etc.)


Validate Response Time

Ensure APIs meet performance expectations.

Example:

  • Response time < 500ms

Extract & Save Environment Variables

Capture values from responses and reuse them in future requests.

Steps:

  • Select Set Env Variable
  • Enter JSON path (e.g. $.token)
  • Provide variable name

👉 This is commonly used in request chaining workflows (e.g., passing auth tokens between API calls).

JavaScript API Testing (Script-Based Assertions)

Write automated API tests using JavaScript directly inside VS Code with Postmate Client’s built-in scripting engine. For complex testing scenarios, use JavaScript assertions with a Postman-compatible pm API.

Perfect for:

  • Complex logic
  • Conditional validation
  • Schema validation
  • Migration from Postman

How to Write Script Tests

  1. Open request
  2. Go to Post-request → Script
  3. Start typing — get instant IntelliSense

IntelliSense suggestions in Postmate Client

RESPONSE Object (Built-in API)

PropertyDescription
RESPONSE.bodyParsed JSON response
RESPONSE.headersResponse headers
RESPONSE.statusHTTP status code
RESPONSE.responseTimeResponse time in ms

Example API Test Assertions

js
// Status code validation
pm.test('Status is 200', () => {
  pm.expect(RESPONSE.status).to.equal(200);
});

// Validate JSON field
pm.test('School name is correct', () => {
  pm.expect(RESPONSE.body.school.schoolName).to.equal('ABC Learning Academy');
});

// Performance test
pm.test('Response is under 500ms', () => {
  pm.expect(RESPONSE.responseTime).to.be.below(500);
});

// Contains check
pm.test('User type contains Owner', () => {
  pm.expect(RESPONSE.body.userType).to.include('Owner');
});

Built-in Code Snippets

Click </> Snippets to insert ready-made test templates:

  • Validate status code
  • Validate JSON field
  • Save value to variable
  • JSON schema validation

JSON Schema Validation (Like Postman — but Easier)

Validate full API response structure using JSON Schema:

js
const schema = {
    type: 'object',
    required: ['schoolName', 'isAutoInvoice', 'grades'],
    properties: {
        schoolName: { type: 'string' },
        isAutoInvoice: { type: 'boolean' },
        invoiceDate: { type: 'number' },
        grades: { type: 'array', items: { type: 'string' } }
    }
};

pm.schemaTest('Schema is valid', schema, RESPONSE.body);

→ Learn more about Postmate Client pm Library for full scripting capabilities.

One-Click Schema Generator (No Online Tools Needed)

Unlike Postman, you don’t need external tools.

Generate schema instantly:

  • Run request
  • Click Generate Schema
  • Paste into script

IntelliSense suggestions in Postmate Client


View Test Results

After sending a request, switch to the Results tab on the right panel.

Each test shows:

  • ✅ Pass / ❌ Fail status
  • Combined results (tabular + script)
  • Clear failure messages

For full run summaries and shareable outputs, check API Test Reports (HTML & JSON).


Tabular vs Script Assertions

Tabular TestsScript Assertions
SetupNo code requiredJavaScript
Best forStatus codes, field checks, saving env variablesComplex logic, schema validation, chaining
AutocompleteJSON path suggestions from last responseFull IntelliSense with dot-notation
Snippets✅ Built-in snippet library
Postman migrationpm library compatible

Why Use Postmate Client for API Testing?

  • ⚡ Lightweight VS Code extension
  • 🔒 100% local (no cloud sync)
  • 🚫 No login required
  • 🔁 Built-in request chaining
  • ▶️ Run tests with Collection Runner
  • ⚙️ Automate via CLI
  • 🧠 Smart autocomplete + IntelliSense

Next Steps

Continue exploring Postmate Client:

Missing a Feature?

Have an idea? Open a request on GitHub

Frequently Asked Questions

Can I replace Postman with Postmate Client?

Yes. Postmate Client provides request testing, assertions, scripting, environments, and collection runner features directly inside VS Code.

Does Postmate Client support automated API testing?

Yes. You can write tests using tabular UI or JavaScript and run them via CLI or collection runner.

Can I run API tests without Postman?

Yes. Postmate Client allows you to run and automate API tests directly inside VS Code without needing Postman or any external tools.

Released under the Postmate Client Proprietary License.