Skip to content

Commit 8040606

Browse files
Copilotkobenguyent
andcommitted
Enable HTML reporter by default in init and update README
Co-authored-by: kobenguyent <[email protected]>
1 parent 29262b1 commit 8040606

File tree

3 files changed

+38
-174
lines changed

3 files changed

+38
-174
lines changed

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ You don't need to worry about asynchronous nature of NodeJS or about various API
6565
- </> Smart locators: use names, labels, matching text, CSS or XPath to locate elements.
6666
- 🌐 Interactive debugging shell: pause test at any point and try different commands in a browser.
6767
-**Parallel testing** with dynamic test pooling for optimal load balancing and performance.
68+
- 📊 **Built-in HTML Reporter** with interactive dashboard, step-by-step execution details, and comprehensive test analytics.
6869
- Easily create tests, pageobjects, stepobjects with CLI generators.
6970

7071
## Installation
@@ -234,6 +235,21 @@ Scenario('test title', () => {
234235
})
235236
```
236237

238+
## HTML Reporter
239+
240+
CodeceptJS includes a powerful built-in HTML Reporter that generates comprehensive, interactive test reports with detailed information about your test runs. The HTML reporter is **enabled by default** for all new projects and provides:
241+
242+
- **Interactive Dashboard**: Visual statistics, pie charts, and expandable test details
243+
- **Step-by-Step Execution**: Shows individual test steps with timing and status indicators
244+
- **BDD/Gherkin Support**: Full support for feature files with proper scenario formatting
245+
- **System Information**: Comprehensive environment details including browser versions
246+
- **Advanced Filtering**: Real-time filtering by status, tags, features, and test types
247+
- **History Tracking**: Multi-run history with trend visualization
248+
- **Error Details**: Clean formatting of error messages and stack traces
249+
- **Artifacts Support**: Display screenshots and other test artifacts
250+
251+
The HTML reporter generates self-contained reports that can be easily shared with your team. Learn more about configuration and features in the [HTML Reporter documentation](https://codecept.io/plugins/#htmlreporter).
252+
237253
## PageObjects
238254

239255
CodeceptJS provides the most simple way to create and use page objects in your test.

docs/plugins.md

Lines changed: 17 additions & 174 deletions
Original file line numberDiff line numberDiff line change
@@ -720,191 +720,34 @@ HTML Reporter Plugin for CodeceptJS
720720
721721
Generates comprehensive HTML reports showing:
722722
723-
- **Interactive Test Results**: Click-to-expand test details with comprehensive information
724-
- **Step-by-Step Details**: Shows individual test steps with proper method names (e.g., `I.seeFile()`, `I.amInPath()`), status indicators, and timing
725-
- **BDD/Gherkin Support**: Full support for Gherkin feature files with proper scenario formatting, step keywords, and feature information
726-
- **Test Statistics**: Visual cards displaying totals, passed, failed, and pending test counts with interactive pie chart
727-
- **Error Information**: Clean, formatted error messages for failed tests with ANSI color code stripping
728-
- **Artifacts Support**: Display screenshots and other test artifacts with modal viewing capability
729-
- **Responsive Design**: Mobile-friendly layout that works across all screen sizes
730-
- **Professional Styling**: Modern, clean interface with color-coded status indicators
731-
- **Enhanced Features**:
732-
- **Metadata Display**: Shows test metadata, options, and custom properties
733-
- **Tags Support**: Display and filter by test tags (@smoke, @critical, etc.)
734-
- **Retry Tracking**: Shows retry attempts and final test status
735-
- **Test Notes**: Display test notes and comments
736-
- **Interactive Filters**: Filter tests by status, feature, tags, retry status, and test type (BDD vs Regular)
737-
- **Test History**: Track test results across multiple runs with visual charts
738-
- **Stats Export**: Export test statistics in JSON format for integration with external tools (Grafana, etc.)
739-
- **Worker Support**: Compatible with run-workers and run-multiple commands
723+
- Test statistics
724+
- Feature/Scenario details
725+
- Individual step results
726+
- Test artifacts (screenshots, etc.)
740727
741728
## Configuration
742729
743730
```js
744731
"plugins": {
745732
"htmlReporter": {
746733
"enabled": true,
747-
"output": "./output", // Directory for the report
748-
"reportFileName": "report.html", // Name of the HTML file
749-
"includeArtifacts": true, // Include screenshots/artifacts
750-
"showSteps": true, // Show individual test steps
751-
"showSkipped": true, // Show skipped tests
752-
"showMetadata": true, // Show test metadata and options
753-
"showTags": true, // Show test tags
754-
"showRetries": true, // Show retry information
755-
"exportStats": false, // Export stats to JSON file
756-
"exportStatsPath": "./stats.json", // Path for stats export
757-
"keepHistory": false, // Track test history
758-
"historyPath": "./test-history.json", // Path for history file
759-
"maxHistoryEntries": 50 // Max history entries to keep
734+
"output": "./output",
735+
"reportFileName": "report.html",
736+
"includeArtifacts": true,
737+
"showSteps": true,
738+
"showSkipped": true,
739+
"showMetadata": true,
740+
"showTags": true,
741+
"showRetries": true,
742+
"exportStats": false,
743+
"exportStatsPath": "./stats.json",
744+
"keepHistory": false,
745+
"historyPath": "./test-history.json",
746+
"maxHistoryEntries": 50
760747
}
761748
}
762749
```
763750
764-
### Usage
765-
766-
Run tests normally and the HTML report will be automatically generated:
767-
768-
```bash
769-
npx codeceptjs run
770-
```
771-
772-
The generated HTML report includes:
773-
774-
- **Filter Controls**: Interactive filtering by status, feature, tags, and retry status
775-
- **Test History Chart**: Visual representation of test results over time (when history is enabled)
776-
- **Detailed Test Information**: Expandable sections showing steps, hooks, metadata, and artifacts
777-
- **Export Integration**: JSON stats export for external analysis tools
778-
779-
### Screenshots
780-
781-
#### Main Dashboard
782-
783-
![HTML Reporter Main Dashboard](shared/html-reporter-main-dashboard.png)
784-
_Interactive dashboard with test statistics, pie chart visualization, and comprehensive filtering options_
785-
786-
#### Test Details View
787-
788-
![HTML Reporter Test Details](shared/html-reporter-test-details.png)
789-
_Expandable test details showing step-by-step execution with timing, status indicators, and comprehensive test information_
790-
791-
#### Advanced Filtering
792-
793-
![HTML Reporter Filtering](shared/html-reporter-filtering.png)
794-
_Real-time filtering capabilities allowing users to filter by status, features, tags, retry status, and test type_
795-
796-
#### BDD/Gherkin Support
797-
798-
![HTML Reporter BDD Details](shared/html-reporter-bdd-details.png)
799-
_Comprehensive BDD/Gherkin support with feature information, scenario formatting, proper step keywords (Given, When, Then, And), hooks, and visual indicators_
800-
801-
### Stats Export for Grafana Integration
802-
803-
Enable stats export to integrate with monitoring tools:
804-
805-
```js
806-
"htmlReporter": {
807-
"enabled": true,
808-
"exportStats": true,
809-
"exportStatsPath": "./test-stats.json"
810-
}
811-
```
812-
813-
The exported JSON contains structured data perfect for Grafana dashboards:
814-
815-
- Test execution metrics
816-
- Pass/fail rates over time
817-
- Individual test performance data
818-
- Retry statistics
819-
- Test metadata for grouping and filtering
820-
821-
### History Tracking
822-
823-
Track test trends across multiple runs:
824-
825-
```js
826-
"htmlReporter": {
827-
"enabled": true,
828-
"keepHistory": true,
829-
"historyPath": "./test-history.json",
830-
"maxHistoryEntries": 100
831-
}
832-
```
833-
834-
History tracking provides:
835-
836-
- Test result trends over time
837-
- Performance regression detection
838-
- Visual charts in the HTML report
839-
- JSON data for external analysis
840-
841-
### BDD/Gherkin Support
842-
843-
The HTML reporter provides comprehensive support for BDD/Gherkin feature files with enhanced formatting and visualization:
844-
845-
#### Key BDD Features
846-
847-
- **Automatic Detection**: Automatically detects BDD/Gherkin tests based on `.feature` files and Gherkin syntax
848-
- **Scenario Formatting**: Displays scenarios with proper "Scenario:" prefix and visual distinction from regular tests
849-
- **Feature Information**: Shows complete feature details including name, description, and file path
850-
- **Gherkin Steps**: Displays steps with proper keywords (Given, When, Then, And) in a BDD-friendly format
851-
- **BDD Badge**: Visual indicator distinguishing Gherkin tests from regular CodeceptJS tests
852-
- **Feature Tags**: Supports both feature-level and scenario-level tags with proper inheritance
853-
- **Test Type Filtering**: Filter reports to show only BDD tests, only regular tests, or both
854-
855-
#### BDD Configuration
856-
857-
No special configuration required - BDD support is automatically enabled when using Gherkin feature files:
858-
859-
```js
860-
// codecept.conf.js
861-
exports.config = {
862-
gherkin: {
863-
features: './features/*.feature',
864-
steps: './step_definitions/*.js',
865-
},
866-
plugins: {
867-
htmlReporter: {
868-
enabled: true,
869-
output: './output',
870-
reportFileName: 'report.html',
871-
},
872-
},
873-
}
874-
```
875-
876-
#### BDD Report Features
877-
878-
**Feature Display:**
879-
880-
- Feature name and description prominently displayed
881-
- Feature-level tags shown with purple styling
882-
- File path information for traceability
883-
- Language support for internationalized Gherkin
884-
885-
**Scenario Formatting:**
886-
887-
- Clear "Scenario:" prefix for test titles
888-
- "Feature:" prefix for feature grouping
889-
- Purple "Gherkin" badge for easy identification
890-
- Visual left border styling for BDD tests
891-
892-
**Step Visualization:**
893-
894-
- Proper Gherkin keywords: Given, When, Then, And
895-
- Step text displayed with original Gherkin formatting
896-
- Execution timing for each step
897-
- Status indicators (pass/fail) for individual steps
898-
- Support for data tables and docstrings in step comments
899-
900-
**Enhanced Filtering:**
901-
902-
- Test Type filter to show BDD-only or regular tests
903-
- All existing filters (tags, status, feature) work with BDD tests
904-
- Combined filtering for complex test selection
905-
906-
The BDD support seamlessly integrates with all existing HTML reporter features including retry tracking, history, stats export, and artifact display.
907-
908751
### Parameters
909752
910753
- `config` &#x20;

lib/command/init.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ const defaultConfig = {
1818
output: '',
1919
helpers: {},
2020
include: {},
21+
plugins: {
22+
htmlReporter: {
23+
enabled: true,
24+
},
25+
},
2126
}
2227

2328
const helpers = ['Playwright', 'WebDriver', 'Puppeteer', 'REST', 'GraphQL', 'Appium', 'TestCafe']

0 commit comments

Comments
 (0)