Skip to content

Commit a4224c7

Browse files
Copilotkobenguyent
andcommitted
Fix HTML reporter path resolution and remove generated test file
Co-authored-by: kobenguyent <[email protected]>
1 parent 65648fb commit a4224c7

File tree

5 files changed

+39
-69
lines changed

5 files changed

+39
-69
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ examples/selenoid-example/output
1717
test/data/app/db
1818
test/data/sandbox/steps.d.ts
1919
test/data/sandbox/configs/custom-reporter-plugin/output/result.json
20+
test/data/sandbox/configs/html-reporter-plugin/output/report.html
2021
testpullfilecache*
2122
.DS_Store
2223
package-lock.json

docs/plugins.md

Lines changed: 30 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -587,67 +587,6 @@ Sample custom reporter for CodeceptJS.
587587
588588
- `config` &#x20;
589589
590-
## htmlReporter
591-
592-
Generates comprehensive HTML reports showing:
593-
594-
- Test statistics with interactive pie chart
595-
- Feature/Scenario details with collapsible sections
596-
- Individual step results with execution timing
597-
- Hook execution details (Before/After hooks)
598-
- Test artifacts (screenshots, etc.) with modal viewing
599-
- Clean, formatted error messages with ANSI color code stripping
600-
601-
The HTML reporter provides a modern, responsive interface that works across all screen sizes and can be easily shared with stakeholders.
602-
603-
#### Configuration
604-
605-
```js
606-
exports.config = {
607-
plugins: {
608-
htmlReporter: {
609-
enabled: true,
610-
output: './output', // Directory for the report
611-
reportFileName: 'report.html', // Name of the HTML file
612-
includeArtifacts: true, // Include screenshots/artifacts
613-
showSteps: true, // Show individual test steps
614-
showSkipped: true, // Show skipped tests
615-
},
616-
},
617-
}
618-
```
619-
620-
#### Features
621-
622-
- **Interactive Test Results**: Click-to-expand test details with comprehensive information
623-
- **Step-by-Step Details**: Shows individual test steps with proper method names (e.g., `I.seeFile()`, `I.amInPath()`), status indicators, and timing
624-
- **Test Statistics**: Visual cards displaying totals, passed, failed, and pending test counts with pie chart visualization
625-
- **Hook Information**: Displays Before/After hook execution details with timing and status
626-
- **Error Information**: Clean, formatted error messages for failed tests with ANSI color code stripping
627-
- **Artifacts Support**: Display screenshots and other test artifacts with modal viewing capability
628-
- **Responsive Design**: Mobile-friendly layout that works across all screen sizes
629-
- **Professional Styling**: Modern, clean interface with color-coded status indicators
630-
631-
#### Usage
632-
633-
Run tests normally and the HTML report will be automatically generated at the specified output location (default: `output/report.html`).
634-
635-
The generated HTML includes embedded CSS and JavaScript for a self-contained, interactive report that can be easily shared with stakeholders.
636-
637-
#### Example Report Features
638-
639-
- Click on any test to see detailed steps and timing information
640-
- Visual pie chart shows test distribution at a glance
641-
- Hook execution details show Before/After operations
642-
- Screenshots and artifacts display in modal overlays
643-
- Mobile-responsive design works on all devices
644-
645-
![HTML Reporter Example](./shared/html-reporter-screenshot.png)
646-
647-
### Parameters
648-
649-
- `config` **[Object][1]** Plugin configuration (optional, default `{}`)
650-
651590
## eachElement
652591
653592
Provides `eachElement` global function to iterate over found elements to perform actions on them.
@@ -775,6 +714,36 @@ More config options are available:
775714
776715
- `config` (optional, default `{}`)
777716
717+
## htmlReporter
718+
719+
HTML Reporter Plugin for CodeceptJS
720+
721+
Generates comprehensive HTML reports showing:
722+
723+
- Test statistics
724+
- Feature/Scenario details
725+
- Individual step results
726+
- Test artifacts (screenshots, etc.)
727+
728+
## Configuration
729+
730+
```js
731+
"plugins": {
732+
"htmlReporter": {
733+
"enabled": true,
734+
"output": "./output",
735+
"reportFileName": "report.html",
736+
"includeArtifacts": true,
737+
"showSteps": true,
738+
"showSkipped": true
739+
}
740+
}
741+
```
742+
743+
### Parameters
744+
745+
- `config` &#x20;
746+
778747
## pageInfo
779748
780749
Collects information from web page after each failed test and adds it to the test as an artifact.

lib/plugin/htmlReporter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ module.exports = function (config) {
5353
let currentTestHooks = []
5454

5555
// Initialize report directory
56-
const reportDir = path.resolve(options.output)
56+
const reportDir = options.output ? path.resolve(global.codecept_dir, options.output) : path.resolve(global.output_dir || './output')
5757
mkdirp.sync(reportDir)
5858

5959
// Track overall test execution

output/report.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@
384384
<header class="report-header">
385385
<h1>CodeceptJS Test Report</h1>
386386
<div class="report-meta">
387-
<span>Generated: 2025-08-23T16:28:10.912Z</span>
387+
<span>Generated: 2025-08-23T17:02:58.961Z</span>
388388
<span>Duration: 28ms</span>
389389
</div>
390390
</header>
@@ -443,7 +443,7 @@ <h4>Steps:</h4>
443443
<div class="step-item success">
444444
<span class="step-status success"></span>
445445
<span class="step-title">I.amInPath(".")</span>
446-
<span class="step-duration">1ms</span>
446+
<span class="step-duration">0ms</span>
447447
</div>
448448

449449
<div class="step-item success">
@@ -478,7 +478,7 @@ <h4>Steps:</h4>
478478
<div class="step-item success">
479479
<span class="step-status success"></span>
480480
<span class="step-title">I.seeFile("this-file-should-not-exist.txt")</span>
481-
<span class="step-duration">1ms</span>
481+
<span class="step-duration">0ms</span>
482482
</div>
483483
</div>
484484
</div>
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -384,8 +384,8 @@
384384
<header class="report-header">
385385
<h1>CodeceptJS Test Report</h1>
386386
<div class="report-meta">
387-
<span>Generated: 2025-08-23T16:27:27.727Z</span>
388-
<span>Duration: 30ms</span>
387+
<span>Generated: 2025-08-23T16:56:45.424Z</span>
388+
<span>Duration: 29ms</span>
389389
</div>
390390
</header>
391391

@@ -472,13 +472,13 @@ <h4>Steps:</h4>
472472
<div class="step-item success">
473473
<span class="step-status success"></span>
474474
<span class="step-title">I.amInPath(".")</span>
475-
<span class="step-duration">1ms</span>
475+
<span class="step-duration">0ms</span>
476476
</div>
477477

478478
<div class="step-item success">
479479
<span class="step-status success"></span>
480480
<span class="step-title">I.seeFile("this-file-should-not-exist.txt")</span>
481-
<span class="step-duration">0ms</span>
481+
<span class="step-duration">1ms</span>
482482
</div>
483483
</div>
484484
</div>

0 commit comments

Comments
 (0)