Testing Guide¶
IntelliPen includes a comprehensive end-to-end testing infrastructure to ensure reliability and quality across all features.
Quick Start¶
# 1. Install dependencies
npm install
# 2. Install Chrome for Testing 138+
npm run test:install-chrome
# 3. Build the extension
npm run build
# 4. Run tests (with visible browser)
npm test
# OR run tests in headless mode (no visible windows)
npm run test:headless
Test Commands¶
| Command | Description |
|---|---|
npm test | Run all tests with visible browser |
npm run test:headless | Run all tests in headless mode (no windows) |
npm run test:e2e:verbose | Run with detailed output |
npm run test:e2e:watch | Run in watch mode for development |
npm run test:install-chrome | Install Chrome for Testing 138+ |
HEADLESS=true npm test -- <file> | Run specific test file in headless mode |
Test Suites¶
IntelliPen includes 7 comprehensive test suites covering all major features:
Basic Tests (basic.test.js)¶
Tests fundamental browser functionality:
- Browser launch and initialization
- Page creation and navigation
- Extension loading verification
AI APIs Tests (ai-apis.test.js)¶
Tests Chrome built-in AI APIs integration:
- API availability detection for all 7 APIs
- AIAPIManager initialization
- Individual API status checks (Prompt, Proofreader, Writer, Rewriter, Summarizer, Translator, Language Detector)
- Graceful handling of unavailable APIs
Editor Tests (editor.test.js)¶
Tests the IntelliPen Editor features:
- Editor screen loading and initialization
- Text input and editing functionality
- Word and character counting
- Grammar check button presence
- Tone adjustment controls (formal, casual, professional, friendly)
- Writing improvement features
- Document management (new, save, open)
Translator Tests (translator.test.js)¶
Tests translation functionality:
- Translator screen loading
- Source and target language selectors
- Text input and output areas
- Translation controls and buttons
- Language swap functionality
- Character counter
- Text-to-speech controls
Meeting Tests (meeting.test.js)¶
Tests meeting recording and analysis:
- Meeting dashboard loading
- Device selection (microphone and speaker)
- Language selection for speech recognition
- Recording controls (start, stop, pause)
- Live transcript display
- AI analysis features (summaries, action items, decisions)
- Export functionality
Popup Tests (popup.test.js)¶
Tests extension popup interface:
- Popup page loading
- Extension branding and logo
- API status indicators for all 7 APIs
- Quick action buttons
- Sidepanel opening functionality
Service Worker Tests (service-worker.test.js)¶
Tests extension background functionality:
- Extension loading and initialization
- Chrome APIs availability (storage, runtime, tabs)
- Service worker registration
- Message passing infrastructure
Testing Infrastructure¶
Technology Stack¶
- Jest 29.7.0: Test framework with 60-second timeout support
- Puppeteer Core: Browser automation for end-to-end testing
- @puppeteer/browsers: Chrome for Testing installer
- Chrome for Testing 138+: Dedicated Chrome build for automated testing
Test Configuration¶
Jest Configuration (jest.config.js):
{
testEnvironment: 'node',
testMatch: ['**/tests/e2e/**/*.test.js'],
testTimeout: 60000, // 60 seconds for AI operations
setupFilesAfterEnv: ['<rootDir>/tests/e2e/setup.js'],
maxWorkers: 1 // Run serially to avoid browser conflicts
}
Test Setup (tests/e2e/setup.js):
- Launches Chrome with extension loaded
- Detects extension ID automatically
- Provides helper functions for tests
- Handles browser lifecycle management
Headless vs Headed Mode¶
Headed Mode (Default):
- Visible browser windows
- Useful for debugging and test development
- Slower execution but easier to troubleshoot
Headless Mode:
- No visible browser windows
- Faster execution
- CI/CD friendly
- Lower resource usage
Writing New Tests¶
Basic Test Structure¶
describe('Feature Name', () => {
let browser, extensionId, page;
beforeAll(async () => {
({ browser, extensionId } = await global.setupBrowser());
});
afterAll(async () => {
await global.teardownBrowser();
});
beforeEach(async () => {
page = await browser.newPage();
await page.goto(global.getExtensionPage('sidepanel/index.html'));
});
afterEach(async () => {
if (page) {
await page.close();
}
});
test('should do something', async () => {
const element = await page.$('#some-element');
expect(element).toBeTruthy();
});
});
Helper Functions¶
global.setupBrowser()- Launches Chrome with extension loadedglobal.teardownBrowser()- Closes browser and cleans upglobal.getExtensionPage(path)- Gets full extension URL for a page
Best Practices¶
- Always close pages in
afterEachto prevent memory leaks - Use specific selectors (IDs, data attributes) for reliability
- Add timeouts for elements that load asynchronously
- Test user flows not just element presence
- Handle async operations with proper await statements
- Mock AI APIs if testing without full model download
- Use descriptive test names that explain what's being tested
System Requirements¶
For Running Tests¶
- Node.js: 16+
- Chrome for Testing: 138+
- Disk Space: ~500 MB for Chrome + extension
- Operating System: Windows 10+, macOS 13+, Linux, or ChromeOS
For AI API Testing¶
- Storage: 22 GB+ free space (for Gemini Nano model)
- GPU: 4GB+ VRAM
- Network: Unmetered connection for initial model download
Note
Tests check for AI API availability but don't require full functionality. They will pass even if APIs are unavailable due to hardware limitations.
Continuous Integration¶
IntelliPen uses GitHub Actions for automated testing on every push and pull request.
GitHub Actions Workflow¶
name: Tests
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18'
- run: npm install
- run: npm run test:install-chrome
- run: npm run build
- run: npm run test:headless # Use headless mode in CI
Local CI Testing¶
Test the CI workflow locally before pushing:
This script:
- Cleans previous builds
- Installs dependencies
- Installs Chrome for Testing
- Builds the extension
- Runs tests in headless mode
Troubleshooting¶
Tests Won't Start¶
Error: "Extension not built"
Error: "Chrome for Testing 138+ not found"
Tests Timeout¶
-
Increase timeout in
jest.config.js: -
Check extension build:
-
Verify Chrome installation:
Extension Won't Load¶
- Check
manifest.jsonis valid - Verify all required files are in
dist/ - Look for build errors:
AI APIs Not Available¶
This is expected if:
- System doesn't meet hardware requirements (4GB+ VRAM, 22GB storage)
- Gemini Nano model not downloaded
- Chrome version < 138
- Running in headless mode (some APIs may not work)
Tip
Tests check for API availability but don't require full functionality. They will pass with warnings if APIs are unavailable.
Performance Tips¶
- Run tests serially (already configured with
maxWorkers: 1) - Reuse browser instances when possible
- Skip AI model downloads in CI environments
- Use headless mode for faster execution
- Use headed mode only when debugging
Test Coverage¶
Current test coverage includes:
- ✅ Extension loading and initialization
- ✅ All 7 Chrome AI APIs availability detection
- ✅ Editor features (grammar, writing, tone adjustment)
- ✅ Translation features (25+ languages, auto-detection)
- ✅ Meeting recording and analysis
- ✅ Popup menu and API status indicators
- ✅ Service worker and Chrome APIs
- ✅ UI components and navigation
Additional Resources¶
Support¶
For testing issues or questions:
- Check the Troubleshooting section
- Review test output with
npm run test:e2e:verbose - Check TESTING.md in the root directory
- Open an issue on GitHub with test logs
Next Steps:
- Contributing Guide - Learn how to contribute to IntelliPen
- Architecture - Understand the extension architecture
- API Reference - Explore the API documentation