PostMortem VSCode Extension
Generate Mocha/Supertest tests from Postman collections directly in VSCode.
Features
- 🔄 Convert Postman Collections - Transform your Postman collections into automated Mocha tests
- 📁 Maintain Structure - Preserve your Postman folder organization in generated tests
- 🧪 Modern Testing - Generate tests with Mocha, Chai, and Supertest
- 🌍 Environment Support - Handle Postman environment variables
- ⚙️ Configurable Output - Choose between simple tests or full project generation
- 🎯 Context Menu Integration - Right-click JSON files to generate tests
- 🚀 Progress Tracking - Visual progress indicators during generation
Installation
- Install from VSCode Marketplace (coming soon)
- Or install from VSIX file
Usage
Method 1: Command Palette
- Open Command Palette (
Ctrl+Shift+P
/ Cmd+Shift+P
)
- Run
PostMortem: Generate Tests from Postman Collection
- Select your Postman collection JSON file
- Optionally select environment file
- Choose output directory
- Tests will be generated!
- Right-click any
.json
file in Explorer
- Select
Generate Tests from Collection File
- Follow the prompts
Configuration
Configure the extension behavior in VSCode settings:
{
"postmortem.outputDirectory": "./tests",
"postmortem.maintainFolderStructure": true,
"postmortem.generateFullProject": false,
"postmortem.createSetupFile": true
}
Settings
postmortem.outputDirectory
- Default output directory for generated tests
postmortem.maintainFolderStructure
- Preserve Postman collection folder structure
postmortem.generateFullProject
- Generate complete test framework with enhanced features
postmortem.createSetupFile
- Create setup.ts file for test configuration
Example
Input: Postman Collection
{
"info": { "name": "My API Tests" },
"item": [{
"name": "Users",
"item": [{
"name": "Get User",
"request": {
"method": "GET",
"url": "{{baseUrl}}/users/1"
},
"event": [{
"listen": "test",
"script": {
"exec": ["pm.test('Status is 200', () => pm.response.to.have.status(200));"]
}
}]
}]
}]
}
Output: Generated Test
import { request, expect } from './setup';
describe('Users - Get User', function() {
it('should respond with correct data', async function() {
const response = await request.get('/users/1');
expect(response.status).to.equal(200);
});
});
Features by Mode
Simple Mode (Default)
- Generates individual test files
- Basic setup.ts file
- Uses Supertest for HTTP requests
- Minimal project structure
Full Project Mode
- Complete test framework
- Enhanced API client with helpers
- TypeScript configuration
- Package.json with dependencies
- Comprehensive test utilities
- Better error handling and logging
Requirements
- VSCode 1.85.0 or higher
- Node.js 18+ (for running generated tests)
Commands
Command |
Description |
postmortem.generateFromCollection |
Generate tests from selected Postman collection |
postmortem.generateFromFile |
Generate tests from specific JSON file (context menu) |
Contributing
- Clone the repository
- Run
npm install
- Open in VSCode
- Press
F5
to start debugging
License
MIT
Credits
Built on top of the PostMortem CLI tool.