Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions .github/workflows/html-reporter-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: HTML Reporter Tests

on:
push:
branches:
- '3.x'
pull_request:
branches:
- '**'

jobs:
test-html-reporter:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [20, 22]

steps:
- uses: actions/checkout@v4

- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: Install dependencies
run: npm i

- name: Run HTML Reporter Unit Tests
run: npm run test:unit -- test/unit/plugin/htmlReporter_test.js --timeout 10000

- name: Run HTML Reporter Integration Tests
run: npm run test:runner -- test/runner/html-reporter-plugin_test.js --timeout 60000

- name: Upload test artifacts
if: failure()
uses: actions/upload-artifact@v4
with:
name: test-output-node-${{ matrix.node-version }}
path: |
test/data/sandbox/configs/html-reporter-plugin/output/
test/acceptance/output/
retention-days: 7

- name: Upload HTML reports
if: always()
uses: actions/upload-artifact@v4
with:
name: html-reports-node-${{ matrix.node-version }}
path: |
test/data/sandbox/configs/html-reporter-plugin/output/*.html
retention-days: 30
167 changes: 119 additions & 48 deletions lib/plugin/htmlReporter.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
"@pollyjs/core": "6.0.6",
"@types/chai": "5.2.2",
"@types/inquirer": "9.0.9",
"@types/node": "^24.6.0",
"@types/node": "^24.6.2",
"@wdio/sauce-service": "9.12.5",
"@wdio/selenium-standalone-service": "8.15.0",
"@wdio/utils": "9.19.2",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const { setHeadlessWhen, setWindowSize } = require('@codeceptjs/configure')

setHeadlessWhen(process.env.HEADLESS)
setWindowSize(1600, 1200)

exports.config = {
tests: './retry_test.js',
output: './output',
helpers: {
FileSystem: {},
},
plugins: {
htmlReporter: {
enabled: true,
output: './output',
reportFileName: 'retry-report.html',
includeArtifacts: true,
showSteps: true,
showRetries: true,
},
retryFailedStep: {
enabled: true,
retries: 2,
},
},
name: 'html-reporter-plugin retry tests',
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const { setHeadlessWhen, setWindowSize } = require('@codeceptjs/configure')

setHeadlessWhen(process.env.HEADLESS)
setWindowSize(1600, 1200)

exports.config = {
tests: './*_test.js',
output: './output',
helpers: {
FileSystem: {},
},
plugins: {
htmlReporter: {
enabled: true,
output: './output',
reportFileName: 'worker-report.html',
includeArtifacts: true,
showSteps: true,
showSkipped: true,
showMetadata: true,
showTags: true,
showRetries: true,
exportStats: false,
keepHistory: false,
},
},
multiple: {
parallel: {
chunks: 2,
browsers: ['chrome', 'firefox'],
},
},
name: 'html-reporter-plugin worker tests',
}
42 changes: 42 additions & 0 deletions test/data/sandbox/configs/html-reporter-plugin/edge-cases_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
Feature('HTML Reporter Edge Cases')

Scenario('test with special characters <>&"\'', ({ I }) => {
I.amInPath('.')
I.seeFile('package.json')
})

Scenario('test with very long name that should be handled properly without breaking the layout or causing any rendering issues in the HTML report', ({ I }) => {
I.amInPath('.')
I.seeFile('codecept.conf.js')
})

Scenario('test with unicode characters 测试 🎉 ñoño', ({ I }) => {
I.amInPath('.')
I.seeFile('package.json')
})

Scenario('@tag1 @tag2 @critical test with multiple tags', ({ I }) => {
I.amInPath('.')
I.seeFile('codecept.conf.js')
})

Scenario('test with metadata', ({ I }) => {
I.amInPath('.')
I.seeFile('package.json')
}).tag('@smoke').tag('@regression')

Scenario('test that takes longer to execute', async ({ I }) => {
I.amInPath('.')
await new Promise(resolve => setTimeout(resolve, 500))
I.seeFile('package.json')
})

Scenario('test with nested error', ({ I }) => {
I.amInPath('.')
try {
throw new Error('Nested error with <html> tags & special chars')
} catch (e) {
// This will fail
I.seeFile('non-existent-file-with-error.txt')
}
})
3 changes: 3 additions & 0 deletions test/data/sandbox/configs/html-reporter-plugin/empty_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Feature('Empty Feature')

// No scenarios
23 changes: 23 additions & 0 deletions test/data/sandbox/configs/html-reporter-plugin/retry_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Feature('HTML Reporter Retry Test')

let attemptCounter = 0

Scenario('test that fails first time then passes', ({ I }) => {
attemptCounter++
I.amInPath('.')
if (attemptCounter === 1) {
I.seeFile('this-file-does-not-exist.txt') // Will fail first time
} else {
I.seeFile('package.json') // Will pass on retry
}
})

Scenario('test that always fails even with retries', ({ I }) => {
I.amInPath('.')
I.seeFile('this-will-never-exist.txt')
})

Scenario('test that passes without retries', ({ I }) => {
I.amInPath('.')
I.seeFile('codecept.conf.js')
})
Loading
Loading