E2E Testing Reinvented with AI - A powerful TypeScript browser automation framework using AI-powered testing with LangChain, OpenAI GPT-4o, and Playwright
npm install endorphin-ai
Write tests in plain English. Let AI generate, validate, and fix them
automatically.
๐ https://endorphinai.dev
A powerful, modular browser automation framework using AI-powered testing with
LangChain, OpenAI GPT-4o, and Playwright. Provides intelligent browser
automation with automatic element detection, visual validation, and
comprehensive test management.
๐ฏ See Endorphin AI in Action - Complete Walkthrough
โจ Watch how AI writes and executes your tests
๐ See intelligent element detection in real-time
๐ Explore beautiful HTML reports with screenshots
โก From setup to test execution in 10 minutes
๐ Visit our website for more examples and tutorials
---
---
Get started in under 30 seconds:
``bash`โก Quick setup (recommended)
npx create-endorphin-ai@latest my-ai-tests
cd my-ai-tests
Or manual setup:
`bash1. Create your project
mkdir my-ai-tests && cd my-ai-tests
What you get:
- โ
Sample test ready to run
- โ
Configuration files
- โ
Project structure
- โ
Environment setup
$3
`bash
Edit the .env file that was created
echo "OPENAI_API_KEY=your-openai-api-key-here" > .env
`_Get your API key from OpenAI Platform_
$3
`bash
Run the sample health check test
npx endorphin-ai run test HEALTH-001Generate a beautiful HTML report
npx endorphin-ai generate report && npx endorphin-ai open report
`๐ That's it! You now have:
- A working AI-powered test
- Interactive HTML reports with screenshots
- Complete project structure for scaling
$3
https://github.com/user-attachments/assets/166b27d5-5da8-4aab-baaa-6924435f07a9
$3
If
npx endorphin-ai doesn't work, try these guaranteed solutions:`bash
Option 1: Use npm scripts (always works)
npm run endorphin:init # Initialize project
npm run endorphin:version # Check version
npm run endorphin:help # Get helpOption 2: Clear npx cache and retry
npx --clear-cache
npx endorphin-ai initOption 3: Use direct path
./node_modules/.bin/endorphin-ai initOption 4: Global installation
npm install -g endorphin-ai
endorphin-ai init
`Why this happens: This is a known npm/npx issue with local binary
resolution, not a problem with Endorphin AI. The npm scripts above always work
regardless of npx behavior.
Alternative npm scripts in package.json:
`json
{
"scripts": {
"endorphin:init": "./node_modules/.bin/endorphin init",
"endorphin:version": "./node_modules/.bin/endorphin --version",
"endorphin:help": "./node_modules/.bin/endorphin --help"
}
}
`$3
If you prefer manual setup:
1. Create your project directory:
`bash
mkdir my-test-project && cd my-test-project
`2. Initialize with ES modules:
`bash
npm init -y
npm pkg set type="module"
`3. Install Endorphin AI:
`bash
npm install endorphin-ai
`4. Set up your
.env file with your OpenAI API key:
`env
OPENAI_API_KEY=your_api_key_here
`5. Create tests directory:
`bash
mkdir tests
`6. Create your first test file
tests/login-test.ts:
`typescript
import type { TestCase } from 'endorphin-ai'; export const QE001: TestCase = {
id: 'QE-001',
name: 'Basic Login Test',
description: 'Test the login functionality with valid credentials',
priority: 'High',
tags: ['authentication', 'login', 'smoke'],
site: 'https://qafromla.herokuapp.com/',
data: async () => {
return {
originalEmail: 'papapin888@gmail.com',
originalPassword: 'lalalend',
};
},
task:
Navigate to https://qafromla.herokuapp.com/. ,
};
`7. Add scripts to your
package.json:
`json
{
"scripts": {
"test": "endorphin-ai run test all",
"test:smoke": "endorphin-ai run test --tag smoke",
"test:auth": "endorphin-ai run test --tag authentication",
"test:single": "endorphin-ai run test",
"test:record": "endorphin-ai run test-recorder",
"endorphin:init": "./node_modules/.bin/endorphin-ai init",
"endorphin:version": "./node_modules/.bin/endorphin --version"
}
}
`๐ฏ Core Features
$3
- Write tests in plain English - No complex selectors needed
- Intelligent element detection - AI finds buttons, forms, and content
automatically
- Self-healing tests - Adapts to UI changes without breaking
- Smart error recovery - Automatically retries failed actions with different
strategies
$3
- Interactive HTML reports with screenshots and step-by-step execution
- Cost & token tracking - Monitor AI usage and optimize expenses
- AI decision history - See exactly how AI analyzes and executes tests
- Real-time filtering and search to quickly find issues
- Visual debugging with click-to-zoom screenshots
- Export capabilities for sharing with your team
$3
https://github.com/user-attachments/assets/83a900c6-9279-496d-bc12-f16fb98cf6dc
$3
- Zero configuration - Works out of the box
- TypeScript support with full type definitions
- Smart test structure - Dynamic setup, data generation, and task functions
- Built-in tools system - 12 comprehensive automation tools included
- VS Code debugging - Professional debugging with debug object access
- Multiple browsers - Chrome, Firefox, Safari support
- Sequential execution for reliable test runs
$3
- Test Recorder - Create tests by clicking through your app
- Live debugging - See exactly what the AI is doing
- Custom test creation with guided prompts
- Session replay to understand test failures
---
๐ Staying Updated
$3
`bash
Check your current version
npx endorphin-ai --versionUpdate to the latest version
npm update endorphin-aiGet help and see new features
npx endorphin-ai --help
`$3
- โ
Smart Test Structure - New async
setup(), data(), and task()
functions for dynamic test preparation
- โ
Enhanced HTML Reports - Interactive reports with cost tracking and AI
decision history
- โ
Cost & Token Tracking - Monitor AI usage costs per test and per step
- โ
AI Decision History - See exactly how AI analyzes and executes tests
- โ
Built-in Tools System - 12 comprehensive browser automation tools (no
custom tools needed)
- โ
Professional Debugging - VS Code integration with debug object access
- โ
CI/CD Ready - Ready-to-use GitHub Actions workflows included๐ Project Initialization
$3
`bash
Quick setup for new projects
mkdir my-test-project && cd my-test-project
npx endorphin-ai init
`The
init command creates:- โ
tests/ directory with sample TypeScript test
- โ
test-results/ for test outputs
- โ
test-recorder/ for recorded tests
- โ
.env file with API key placeholder
- โ
endorphin.config.ts with optimized TypeScript settings- โ
tsconfig.json for TypeScript compilation
- โ
.gitignore with Endorphin-specific patterns
- โ
README-ENDORPHIN.md quick start guide$3
For existing Endorphin projects, the
init command is optional and safe:- โ
Never overwrites existing configuration files
- โ
Only creates missing directories
- โ
Adds helpful template files if needed
`bash
Safe to run in existing projects
npx endorphin-ai init
`$3
#### โน๏ธ Version & Help
`bash
Check current version
npx endorphin-ai --versionGet help and see all commands
npx endorphin-ai --helpUpdate to latest version
npm update endorphin-ai
`#### ๐ฏ Initialize New Project
`bash
Create a new Endorphin AI project with all necessary files
npx endorphin-ai initWhat gets created:
โโโ tests/sample-test.ts # Ready-to-run TypeScript test
โโโ .env # API key configuration
โโโ endorphin.config.ts # Framework settings (TypeScript)
โโโ tsconfig.json # TypeScript configuration
โโโ .gitignore # Endorphin-specific ignores
โโโ README-ENDORPHIN.md # Quick start guide
`#### ๐งช Run Specific Test
`bash
Using npm scripts (recommended)
npm run test:single QE-001Using npx
npx endorphin run test QE-001Global installation
endorphin run test QE-001
`#### ๐ท๏ธ Run Tests by Category
`bash
Using npm scripts
npm run test:smoke
npm run test:authUsing npx/global
npx endorphin run test --tag authentication
npx endorphin run test --priority High
`#### ๐ฏ Run All Tests
`bash
Using npm scripts
npm testUsing npx/global
npx endorphin run test all
`#### ๐ฌ Test Recorder Mode
`bash
Using npm scripts
npm run test:recordUsing npx/global
npx endorphin run test-recorder
`๐ HTML Reports & Analytics
Endorphin AI generates beautiful, interactive HTML reports that provide
comprehensive insights into your test execution results.
$3
`bash
Generate a full interactive HTML report
npx endorphin generate reportGenerate a lightweight summary report
npx endorphin generate report --summaryOpen the latest report in your browser
npx endorphin open reportOpen a specific report file
npx endorphin open report report-2025-06-22.html
`$3
#### ๐ Interactive Dashboard
- Real-time Statistics: Success rates, test counts, execution trends
- Visual Progress Bars: Easy-to-understand success rate indicators
- Summary Cards: Quick overview of test health
#### ๐ Advanced Search & Filtering
- Real-time Search: Find tests by name or ID instantly
- Status Filtering: Filter by passed/failed tests with one click
- Smart Results: Shows "5 of 25 tests matching 'login' with status 'failed'"
- Keyboard Shortcuts:
Ctrl+F to search, Ctrl+3 for failed tests only#### ๐ฏ Detailed Test Analysis
- Step-by-Step Timeline: See exactly what happened during test execution
- Screenshot Galleries: Visual debugging with click-to-zoom screenshots
- Interactive Modals: Deep dive into test execution details
- Tool Call Tracking: See which browser actions were performed
#### โจ๏ธ Productivity Features
- Export to JSON: Data-driven analysis and custom reporting
- Print Support: Documentation-ready printed reports
- Responsive Design: Works on desktop, tablet, and mobile
- Performance Optimized: Fast loading even with large test suites
$3
For detailed usage instructions, advanced features, and best practices, see the
HTML Reporter User Guide.
๐๏ธ Framework Architecture
Endorphin AI is built with a modular, extensible architecture designed for
reliability and maintainability.
๐
View detailed Framework Architecture documentation
$3
- Core Framework: Main test execution engine and session management
- Browser Tools: Intelligent automation tools powered by AI
- Configuration System: Flexible, hierarchical configuration management
- Test Discovery: Automatic test file detection and loading
- Interactive Tools: Real-time test creation and debugging
โ๏ธ Configuration
$3
Endorphin AI works out of the box with sensible defaults, but you can customize
it by creating an
endorphin.config.ts file in your project root:`typescript
// endorphin.config.ts
import type { FrameworkConfig } from 'endorphin-ai';const config: FrameworkConfig = {
// Global test settings
defaultTimeout: 30000,
headless: false,
viewport: { width: 1280, height: 720 },
// Default test data
testData: {
baseUrl: 'https://staging.example.com',
adminEmail: 'admin@example.com',
},
// Result settings
screenshots: true,
recordVideo: false,
};
export default config;
`$3
You can override configuration with CLI flags:
`bash
Using npm scripts with -- to pass flags
npm test -- --browser firefox
npm run test:single QE-001 -- --no-headlessUsing npx/global
npx endorphin run test all --browser firefox
npx endorphin run test QE-001 --no-headless
npx endorphin run test all --viewport 1920x1080
npx endorphin run test all
npx endorphin run test all --model gpt-4
npx endorphin run test all --env staging
`๐ Test Categories
You can organize your tests using tags and priorities:
$3
-
authentication - Login, logout, registration tests
- smoke - Critical path tests that must pass
- navigation - Menu, links, page routing tests
- forms - Form filling and validation tests
- checkout - E-commerce purchase flow tests
- search - Search functionality tests
- responsive - Mobile/tablet/desktop tests$3
-
High - Critical functionality, run on every build
- Medium - Important features, run daily
- Low - Nice-to-have features, run weekly$3
`typescript
// tests/auth-tests.ts
import type { TestCase } from 'endorphin-ai';export const LOGIN_TEST: TestCase = {
id: 'AUTH-001',
name: 'User Login Test',
description: 'Test user authentication flow',
tags: ['authentication', 'smoke'],
priority: 'High',
site: 'https://example.com',
task: 'Navigate to login page and authenticate user...',
};
export const LOGOUT_TEST: TestCase = {
id: 'AUTH-002',
name: 'User Logout Test',
description: 'Test user logout functionality',
tags: ['authentication'],
priority: 'Medium',
site: 'https://example.com',
task: 'Log out the authenticated user...',
};
`๐ง Smart Test Structure (v0.9.0)
Endorphin AI v0.9.0 introduces a powerful new test structure with async
functions for dynamic test preparation.
$3
`typescript
import type { TestCase } from 'endorphin-ai';export const SMART_TEST: TestCase = {
id: 'LOGIN-001',
name: 'User Login Test',
description: 'Test login with generated credentials',
priority: 'High',
tags: ['auth', 'smoke'],
// Generate test data dynamically
data: async () => {
const timestamp = Date.now();
return {
email:
testuser${timestamp}@example.com,
password: 'SecurePassword123!',
firstName: 'Test',
lastName: 'User',
};
}, // Set up test environment
setup: async () => {
return {
baseUrl: process.env.TEST_URL || 'https://example.com',
startTime: new Date().toISOString(),
};
},
// Main test instructions using generated data
task: async (data, setupData) => {
return
;
},
};
`$3
- Dynamic Data Generation - Create unique test data for each run
- Environment Setup - Prepare test environment before execution
- Type Safety - Full TypeScript support for all functions
- Backward Compatibility - Old test format still works perfectly
๐ Project Structure
Your project should look like this:
`
my-test-project/
โโโ .env # OpenAI API key
โโโ tests/ # Your test files (TypeScript)
โ โโโ login-test.ts # Authentication tests
โ โโโ checkout-test.ts # E-commerce tests
โ โโโ navigation-test.ts # UI/Navigation tests
โโโ endorphin.config.ts # Optional configuration (TypeScript)
โโโ tsconfig.json # TypeScript configuration
โโโ package.json # Project config
`๐ Test File Format
Each test file should export test objects with TypeScript types:
`typescript
import type { TestCase } from 'endorphin-ai';export const QE001: TestCase = {
id: 'QE-001', // Unique test identifier
name: 'Basic Login Test', // Human readable name
description: 'Test login functionality with valid credentials',
priority: 'High', // High, Medium, Low
tags: ['authentication', 'login', 'smoke'], // Categories
site: 'https://example.com/', // Target website
data: async () => {
return {
email: 'test@example.com',
password: 'password123',
};
},
task:
Your test instructions in plain English...,
};// Multiple tests per file with full type safety
export const QE002: TestCase = {
id: 'QE-002',
name: 'Registration Test',
description: 'Test user registration flow',
priority: 'Medium',
tags: ['authentication', 'registration'],
site: 'https://example.com/',
task: 'Test new user registration process...',
};
`$3
- โ
Full type safety for test configuration
- โ
IntelliSense support in your IDE
- โ
Compile-time error checking
- โ
Auto-completion for test properties
- โ
Refactoring support across your test suite
๐ Test Results
Each test execution creates:
- ๐ Session Directory:
test-result/[test-id]_[timestamp]/
- ๐ Session Data: test-session.json with complete execution details
- ๐ Summary: summary.json with test outcomes
- ๐ธ Screenshots: Automatic visual documentation
- ๐ Step Logs: Detailed execution tracking$3
`
๐ฏ Running: QE-001 - Basic Login Test
๐ธ Screenshot taken: step-1-navigation.png
โ
Login successful - test completed!
๐ Result: PASSED
`๐ฎ Interactive Features
$3
`bash
Using npm scripts
npm run test:recordUsing npx/global
npx endorphin run test-recorder
`Create tests on-the-fly with guided prompts:
- Custom navigation tasks
- Form filling scenarios
- Login test automation
- Content verification
---
๐ Why Choose Endorphin AI?
$3
| Traditional Testing | Endorphin AI |
| ------------------------- | ------------------------------------ |
| โ Brittle CSS selectors | โ
AI finds elements intelligently |
| โ Breaks with UI changes | โ
Self-healing tests |
| โ Complex setup | โ
Zero configuration |
| โ Hard to maintain | โ
Plain English test descriptions |
| โ Basic reporting | โ
Interactive HTML reports |
| โ Manual debugging | โ
Visual debugging with screenshots |
$3
โ
Enterprise Scale: Used in production environments
โ
Cross-Platform: Windows, macOS, Linux support
โ
CI/CD Integration: GitHub Actions, Jenkins, CircleCI
โ
Security First: Automated vulnerability scanning
โ
Type Safe: Full TypeScript support
โ
Extensible: Modular architecture for custom needs
๐ Staying Updated
$3
`bash
Check current installed version
npx endorphin-ai --versionCheck latest available version on npm
npm view endorphin-ai versionCheck for outdated packages
npm outdated endorphin-ai
`$3
`bash
Update to the latest version
npm update endorphin-aiOr force install latest
npm install endorphin-ai@latestVerify the update
npx endorphin-ai --version
`$3
- v0.9.0 _(Latest)_: Smart test structure, enhanced HTML reports with cost
tracking, AI decision history, built-in tools system
- v0.8.0: Custom tools support with CLI management and templates
- v0.6.1: Fixed npx resolution issues, enhanced user experience
- v0.6.0: Enhanced CLI, security-first publishing, cross-platform CI/CD
- v0.5.0: Advanced HTML reporting with interactive features
- v0.4.0: TypeScript-first experience with full type definitions
- v0.3.0: Added
endorphin-ai init` command for instant project setupEndorphin AI maintains backward compatibility across versions:
- โ
All existing tests work without modification
- โ
Configuration files are automatically migrated
- โ
npm scripts continue to function normally
- โ
Semantic versioning ensures predictable updates
Update with confidence - your existing tests won't break!
---
- Quick Start Guide - Get up and running
quickly
- Test Writing Tips - Enterprise &
small app examples
- HTML Reporter Guide -
Interactive reporting with cost tracking
- VS Code Debugging Guide -
Professional debugging setup
- CI/CD Setup Guide - GitHub
Actions integration
- Framework Architecture -
Technical deep dive
Found a bug or have a feature idea?
Open an issue on GitHub.
- Check the documentation first
- Search
existing issues
- Create a
new issue with
details
---
Endorphin AI is licensed under the GNU Affero General Public License v3.0
(AGPLv3).
For Open Source Projects: Free to use under AGPLv3
For Commercial Projects: Commercial licenses available
๐ง Contact: iam@andrewnovykov.com for licensing
questions
---