MockAuth is designed with developers in mind. This document showcases the enhanced developer experience features that make authentication testing and development a breeze.
Get up and running in seconds, not minutes.
# One command to rule them all
npx mockauth init --quick-start
# Or even simpler
npx mockauth start --auto-configSmart defaults that work out of the box, but are easily customizable.
// This just works!
const auth = new MockAuth({
port: 3001,
jwtSecret: 'dev-secret' // That's it!
});
// But you can customize everything
const auth = new MockAuth({
port: 3001,
jwtSecret: 'dev-secret',
users: [
{ email: 'admin@test.com', password: 'admin123', roles: ['admin'] },
{ email: 'user@test.com', password: 'user123', roles: ['user'] }
],
features: {
mfa: true,
passwordReset: true,
accountLockout: true
}
});No more guessing configuration options. Use our web-based builder.
# Launch the visual builder
npx mockauth builder
# Or with custom port
npx mockauth builder --port 3002Builder Features:
- 🎨 Drag-and-drop user management
- 🔧 Real-time configuration preview
- 📊 Visual role and permission mapping
- 🧪 Test scenarios builder
- 📤 Export configuration as code
Intelligent command-line interface with suggestions and help.
# Auto-completion setup
npx mockauth setup-completion
# Now you get smart suggestions
npx mockauth <TAB> # Shows all available commands
npx mockauth user <TAB> # Shows user-related commands
npx mockauth user create <TAB> # Shows create optionsSee changes instantly without restarting.
// Enable hot reload
const auth = new MockAuth({
port: 3001,
hotReload: true, // 🔥 Changes apply instantly
watchConfig: true // 👀 Watch config file changes
});
// Add users on the fly
auth.addUser({
email: 'newuser@test.com',
password: 'password123',
roles: ['user']
}); // ✨ Available immediately!Built-in debugging interface for real-time inspection.
# Start with debug console
npx mockauth start --debug
# Access at http://localhost:3001/debugDebug Console Features:
- 🔍 Real-time request/response inspection
- 👥 Live user session monitoring
- 🔐 Token validation and debugging
- 📊 Performance metrics dashboard
- 🧪 API testing playground
Automatically generate realistic test data.
// Auto-generate test users
const auth = new MockAuth({
port: 3001,
autoGenerateUsers: {
count: 50,
roles: ['admin', 'user', 'moderator'],
realisticData: true // Generate realistic names, emails, etc.
}
});
// Or generate specific scenarios
auth.generateTestScenario('ecommerce', {
users: 100,
roles: ['customer', 'seller', 'admin'],
permissions: ['buy', 'sell', 'manage']
});Pre-built integrations for popular frameworks.
# Generate React integration
npx mockauth generate --framework react --output ./src/auth
# Generate Vue integration
npx mockauth generate --framework vue --output ./src/auth
# Generate Angular integration
npx mockauth generate --framework angular --output ./src/authAuto-generated, interactive API docs.
# Generate API documentation
npx mockauth docs --format interactive
# Access at http://localhost:3001/docsFeatures:
- 🎮 Interactive API testing
- 📝 Auto-generated examples
- 🔍 Searchable endpoints
- 📊 Request/response schemas
// Jest integration
import { createMockAuth } from 'mockauth/testing';
describe('Auth Flow', () => {
let auth;
beforeEach(async () => {
// One line setup!
auth = await createMockAuth({
users: [{ email: 'test@example.com', password: 'test123' }]
});
});
afterEach(async () => {
await auth.cleanup(); // Auto-cleanup
});
test('should login user', async () => {
const result = await auth.login('test@example.com', 'test123');
expect(result.success).toBe(true);
});
});// cypress/support/mockauth.js
import 'mockauth/cypress';
// Now you can use:
cy.mockAuthLogin('admin@test.com', 'admin123');
cy.mockAuthLogout();
cy.mockAuthUser('admin'); // Predefined user// playwright.config.js
import { mockAuth } from 'mockauth/playwright';
export default {
use: {
...mockAuth({
baseUrl: 'http://localhost:3001',
users: [
{ email: 'admin@test.com', password: 'admin123', roles: ['admin'] }
]
})
}
};Monitor your auth system in real-time.
# Start with dashboard
npx mockauth start --dashboard
# Access at http://localhost:3001/dashboardDashboard Features:
- 📊 Live metrics and statistics
- 👥 Active user sessions
- 🔐 Token lifecycle visualization
- 🚨 Security alerts and warnings
- 📈 Performance monitoring
Manage users through an intuitive interface.
# Launch user management UI
npx mockauth users --ui
# Features:
# - Add/remove users with forms
# - Role and permission assignment
# - Bulk user operations
# - User activity timelineTest your APIs without leaving the browser.
# Launch API playground
npx mockauth playground
# Features:
# - Interactive API testing
# - Request/response inspection
# - Authentication flow testing
# - Performance benchmarking// Validate your config before starting
const auth = new MockAuth(config);
// Get detailed validation results
const validation = auth.validateConfig();
if (!validation.valid) {
console.log('Configuration issues:', validation.errors);
console.log('Suggestions:', validation.suggestions);
}// Automatically adapt to your environment
const auth = new MockAuth({
// Auto-detects: development, testing, staging
environment: 'auto', // 🧠 Smart detection
// Auto-configures based on environment
features: 'auto', // 🔧 Smart defaults
// Auto-scales based on usage
performance: 'auto' // ⚡ Smart optimization
});// Instead of cryptic errors, get helpful messages
try {
await auth.login('user@test.com', 'wrong-password');
} catch (error) {
// Error: "Login failed for user@test.com.
// This might be because: 1) Wrong password, 2) Account locked, 3) User doesn't exist.
// Try: auth.unlockUser('user@test.com') or auth.createUser({...})"
console.log(error.helpfulMessage);
console.log(error.suggestions);
}# Generate auth service for your framework
npx mockauth generate-service --framework react --output ./src/services/auth.js
# Generates:
# - Complete auth service
# - Type definitions
# - Usage examples
# - Test filesconst auth = new MockAuth({
port: 3001,
monitoring: {
enabled: true,
metrics: ['response-time', 'memory-usage', 'request-count'],
alerts: ['high-latency', 'memory-leak', 'error-rate']
}
});
// Access metrics
const metrics = auth.getMetrics();
console.log('Response time:', metrics.responseTime);
console.log('Memory usage:', metrics.memoryUsage);const auth = new MockAuth({
port: 3001,
caching: {
enabled: true,
strategies: ['user-sessions', 'token-validation', 'role-permissions'],
ttl: '5m' // Auto-expire cache
}
});# Comprehensive health check
npx mockauth health --detailed
# Output:
# ✅ Server: Running on port 3001
# ✅ Database: Connected (PostgreSQL)
# ✅ Memory: 45MB (Normal)
# ✅ Response Time: 12ms (Excellent)
# ✅ Active Sessions: 23
# ⚠️ Warning: High memory usage detected# 1. Quick start
npx mockauth init --quick-start
# 2. Configure visually
npx mockauth builder
# 3. Test your integration
npx mockauth test --integration
# 4. Deploy to staging
npx mockauth deploy --environment staging# Share configuration
npx mockauth export-config --format json > mockauth.config.json
# Import team configuration
npx mockauth import-config mockauth.config.json
# Version control integration
npx mockauth git-hooks --install# .github/workflows/test.yml
- name: Setup MockAuth
run: npx mockauth start --background
- name: Run Tests
run: npm test
- name: Generate Test Report
run: npx mockauth test-report --format htmlWith MockAuth, you get:
- ⚡ Instant Setup - From zero to running in under 30 seconds
- 🎨 Visual Tools - No more configuration guessing
- 🧪 Testing Made Easy - One-line test setup
- 🔍 Smart Debugging - Real-time insights and helpful errors
- 📊 Live Monitoring - See what's happening in real-time
- 🚀 Performance First - Built-in optimization and monitoring
- 🤝 Team Ready - Share configurations and collaborate easily
Ready to experience the best DX in authentication testing?
# Start your journey
npx mockauth init --quick-startMockAuth: Built by developers, for developers. Because authentication testing shouldn't be painful.