This directory contains end-to-end (E2E) tests for LobeChat using Cucumber (BDD) and Playwright.
e2e/
βββ src/ # Source files
β βββ features/ # Gherkin feature files
β β βββ discover/ # Discover page tests
β βββ steps/ # Step definitions
β β βββ common/ # Reusable step definitions
β β βββ discover/ # Discover-specific steps
β βββ support/ # Test support files
β βββ world.ts # Custom World context
βββ reports/ # Test reports (generated)
βββ cucumber.config.js # Cucumber configuration
βββ tsconfig.json # TypeScript configuration
βββ package.json # Dependencies and scripts
## Prerequisites
- Node.js 20, 22, or >=24
- Dev server running on `http://localhost:3010` (or set `BASE_URL` env var)
## Installation
Install dependencies:
```bash
cd e2e
pnpm install
Install Playwright browsers:
npx playwright install chromiumRun all tests:
npm testRun tests in headed mode (see browser):
npm run test:headedRun only smoke tests:
npm run test:smokeRun discover tests:
npm run test:discoverBASE_URL: Base URL for the application (default:http://localhost:3010)PORT: Port number (default:3010)HEADLESS: Run browser in headless mode (default:true, set tofalseto see browser)
Example:
HEADLESS=false BASE_URL=http://localhost:3000 npm run test:smokeFeature files are written in Gherkin syntax and placed in the src/features/ directory:
@community @smoke
Feature: Community Smoke Tests
Critical path tests to ensure the community module is functional
@COMMUNITY-SMOKE-001 @P0
Scenario: Load community assistant list page
Given I navigate to "/community/agent"
Then the page should load without errors
And I should see the page body
And I should see the search bar
And I should see assistant cardsStep definitions are TypeScript files in the src/steps/ directory that implement the steps from feature files:
import { Given, Then } from '@cucumber/cucumber';
import { expect } from '@playwright/test';
import { CustomWorld } from '../../support/world';
Given('I navigate to {string}', async function (this: CustomWorld, path: string) {
await this.page.goto(path);
await this.page.waitForLoadState('domcontentloaded');
});After running tests, HTML and JSON reports are generated in the reports/ directory:
reports/cucumber-report.html- Human-readable HTML reportreports/cucumber-report.json- Machine-readable JSON report
If you see errors about missing browser executables:
npx playwright install chromiumMake sure the dev server is running on the expected port (3010 by default), or set PORT or BASE_URL environment variable.
Increase timeout in cucumber.config.js or src/steps/hooks.ts:
setDefaultTimeout(120000); // 2 minutes