Skip to content

Commit 0db01c6

Browse files
authored
fix: address HTML reporter issues (#5240)
* address HTML reporter issues * address HTML reporter issues * fix UTs and lint issue
1 parent c1c0a51 commit 0db01c6

File tree

7 files changed

+683
-49
lines changed

7 files changed

+683
-49
lines changed

lib/plugin/htmlReporter.js

Lines changed: 116 additions & 48 deletions
Large diffs are not rendered by default.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@
141141
"@pollyjs/core": "6.0.6",
142142
"@types/chai": "5.2.2",
143143
"@types/inquirer": "9.0.9",
144-
"@types/node": "^24.6.0",
144+
"@types/node": "^24.6.2",
145145
"@wdio/sauce-service": "9.12.5",
146146
"@wdio/selenium-standalone-service": "8.15.0",
147147
"@wdio/utils": "9.19.2",
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
const { setHeadlessWhen, setWindowSize } = require('@codeceptjs/configure')
2+
3+
setHeadlessWhen(process.env.HEADLESS)
4+
setWindowSize(1600, 1200)
5+
6+
exports.config = {
7+
tests: './retry_test.js',
8+
output: './output',
9+
helpers: {
10+
FileSystem: {},
11+
},
12+
plugins: {
13+
htmlReporter: {
14+
enabled: true,
15+
output: './output',
16+
reportFileName: 'retry-report.html',
17+
includeArtifacts: true,
18+
showSteps: true,
19+
showRetries: true,
20+
},
21+
retryFailedStep: {
22+
enabled: true,
23+
retries: 2,
24+
},
25+
},
26+
name: 'html-reporter-plugin retry tests',
27+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
const { setHeadlessWhen, setWindowSize } = require('@codeceptjs/configure')
2+
3+
setHeadlessWhen(process.env.HEADLESS)
4+
setWindowSize(1600, 1200)
5+
6+
exports.config = {
7+
tests: './*_test.js',
8+
output: './output',
9+
helpers: {
10+
FileSystem: {},
11+
},
12+
plugins: {
13+
htmlReporter: {
14+
enabled: true,
15+
output: './output',
16+
reportFileName: 'worker-report.html',
17+
includeArtifacts: true,
18+
showSteps: true,
19+
showSkipped: true,
20+
showMetadata: true,
21+
showTags: true,
22+
showRetries: true,
23+
exportStats: false,
24+
keepHistory: false,
25+
},
26+
},
27+
multiple: {
28+
parallel: {
29+
chunks: 2,
30+
browsers: ['chrome', 'firefox'],
31+
},
32+
},
33+
name: 'html-reporter-plugin worker tests',
34+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
Feature('HTML Reporter Edge Cases')
2+
3+
Scenario('test with special characters <>&"\'', ({ I }) => {
4+
I.amInPath('.')
5+
I.seeFile('package.json')
6+
})
7+
8+
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 }) => {
9+
I.amInPath('.')
10+
I.seeFile('codecept.conf.js')
11+
})
12+
13+
Scenario('test with unicode characters 测试 🎉 ñoño', ({ I }) => {
14+
I.amInPath('.')
15+
I.seeFile('package.json')
16+
})
17+
18+
Scenario('@tag1 @tag2 @critical test with multiple tags', ({ I }) => {
19+
I.amInPath('.')
20+
I.seeFile('codecept.conf.js')
21+
})
22+
23+
Scenario('test with metadata', ({ I }) => {
24+
I.amInPath('.')
25+
I.seeFile('package.json')
26+
}).tag('@smoke').tag('@regression')
27+
28+
Scenario('test that takes longer to execute', async ({ I }) => {
29+
I.amInPath('.')
30+
await new Promise(resolve => setTimeout(resolve, 500))
31+
I.seeFile('package.json')
32+
})
33+
34+
Scenario('test with nested error', ({ I }) => {
35+
I.amInPath('.')
36+
try {
37+
throw new Error('Nested error with <html> tags & special chars')
38+
} catch (e) {
39+
// This will fail
40+
I.seeFile('non-existent-file-with-error.txt')
41+
}
42+
})
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
Feature('HTML Reporter Retry Test')
2+
3+
let attemptCounter = 0
4+
5+
Scenario('test that fails first time then passes', ({ I }) => {
6+
attemptCounter++
7+
I.amInPath('.')
8+
if (attemptCounter === 1) {
9+
I.seeFile('this-file-does-not-exist.txt') // Will fail first time
10+
} else {
11+
I.seeFile('package.json') // Will pass on retry
12+
}
13+
})
14+
15+
Scenario('test that always fails even with retries', ({ I }) => {
16+
I.amInPath('.')
17+
I.seeFile('this-will-never-exist.txt')
18+
})
19+
20+
Scenario('test that passes without retries', ({ I }) => {
21+
I.amInPath('.')
22+
I.seeFile('codecept.conf.js')
23+
})

0 commit comments

Comments
 (0)