Skip to content

Commit 82eb6ed

Browse files
committed
fix UTs and lint issue
1 parent 71977f5 commit 82eb6ed

File tree

5 files changed

+266
-361
lines changed

5 files changed

+266
-361
lines changed

.github/workflows/html-reporter-tests.yml

Lines changed: 0 additions & 53 deletions
This file was deleted.

lib/plugin/htmlReporter.js

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const output = require('../output')
1515
const Codecept = require('../codecept')
1616

1717
const defaultConfig = {
18-
output: (typeof global !== 'undefined' && global.output_dir) ? global.output_dir : './output',
18+
output: typeof global !== 'undefined' && global.output_dir ? global.output_dir : './output',
1919
reportFileName: 'report.html',
2020
includeArtifacts: true,
2121
showSteps: true,
@@ -89,7 +89,7 @@ module.exports = function (config) {
8989

9090
// Track overall test execution
9191
event.dispatcher.on(event.all.before, () => {
92-
reportData.startTime = (new Date()).toISOString()
92+
reportData.startTime = new Date().toISOString()
9393
output.print('HTML Reporter: Starting HTML report generation...')
9494
})
9595

@@ -145,7 +145,7 @@ module.exports = function (config) {
145145
if (step.htmlReporterStartTime) {
146146
step.duration = Date.now() - step.htmlReporterStartTime
147147
}
148-
148+
149149
// Serialize args immediately to preserve them through worker serialization
150150
let serializedArgs = []
151151
if (step.args && Array.isArray(step.args)) {
@@ -164,7 +164,7 @@ module.exports = function (config) {
164164
}
165165
})
166166
}
167-
167+
168168
currentTestSteps.push({
169169
name: step.name,
170170
actor: step.actor,
@@ -246,7 +246,7 @@ module.exports = function (config) {
246246

247247
// Check if this test already exists in reportData.tests (from a previous retry)
248248
const existingTestIndex = reportData.tests.findIndex(t => t.id === testId)
249-
const hasFailedBefore = existingTestIndex >= 0 && reportData.tests[existingTestIndex] && reportData.tests[existingTestIndex].state === 'failed'
249+
const hasFailedBefore = existingTestIndex >= 0 && reportData.tests[existingTestIndex] && reportData.tests[existingTestIndex].state === 'failed'
250250
const currentlyFailed = test.state === 'failed'
251251

252252
// Debug artifacts collection (but don't process them yet - screenshots may not be ready)
@@ -256,7 +256,7 @@ module.exports = function (config) {
256256
// This ensures the feature name is preserved when test data is JSON stringified
257257
const parentTitle = test.parent?.title || test.suite?.title || (suite && suite.title) || null
258258
const suiteTitle = test.suite?.title || (suite && suite.title) || null
259-
259+
260260
const testData = {
261261
...test,
262262
id: testId,
@@ -279,7 +279,7 @@ module.exports = function (config) {
279279

280280
if (existingTestIndex >= 0) {
281281
// Update existing test with final result (including failed state)
282-
if (existingTestIndex >= 0) reportData.tests[existingTestIndex] = testData
282+
if (existingTestIndex >= 0) reportData.tests[existingTestIndex] = testData
283283
output.debug(`HTML Reporter: Updated existing test - ${test.title}, Final state: ${test.state}`)
284284
} else {
285285
// Add new test
@@ -329,9 +329,9 @@ module.exports = function (config) {
329329
})
330330

331331
// Generate final report
332-
event.dispatcher.on(event.all.result, async (result) => {
333-
reportData.endTime = (new Date()).toISOString()
334-
reportData.duration = (new Date(reportData.endTime).getTime() - new Date(reportData.startTime).getTime())
332+
event.dispatcher.on(event.all.result, async result => {
333+
reportData.endTime = new Date().toISOString()
334+
reportData.duration = new Date(reportData.endTime).getTime() - new Date(reportData.startTime).getTime()
335335

336336
// Process artifacts now that all async tasks (including screenshots) are complete
337337
output.debug(`HTML Reporter: Processing artifacts for ${reportData.tests.length} tests after all async tasks complete`)
@@ -382,10 +382,9 @@ module.exports = function (config) {
382382
.map(t => {
383383
const testName = t.title || 'Unknown Test'
384384
// Try to get feature name from BDD, preserved titles (worker mode), or direct access
385-
let featureName = t.feature?.name || t.parentTitle || t.suiteTitle ||
386-
t.parent?.title || t.suite?.title || 'Unknown Feature';
385+
let featureName = t.feature?.name || t.parentTitle || t.suiteTitle || t.parent?.title || t.suite?.title || 'Unknown Feature'
387386
if (featureName === 'Unknown Feature' && t.suite && t.suite.feature && t.suite.feature.name) {
388-
featureName = t.suite.feature.name;
387+
featureName = t.suite.feature.name
389388
}
390389

391390
if (t.err) {
@@ -976,9 +975,7 @@ module.exports = function (config) {
976975
.map(test => {
977976
const statusClass = test.state || 'unknown'
978977
// Use preserved parent/suite titles (for worker mode) or fallback to direct access
979-
const feature = test.isBdd && test.feature ? test.feature.name :
980-
test.parentTitle || test.suiteTitle ||
981-
test.parent?.title || test.suite?.title || 'Unknown Feature';
978+
const feature = test.isBdd && test.feature ? test.feature.name : test.parentTitle || test.suiteTitle || test.parent?.title || test.suite?.title || 'Unknown Feature'
982979
// Always try to show steps if available, even for unknown feature
983980
const steps = config.showSteps && test.steps ? (test.isBdd ? generateBddStepsHtml(test.steps) : generateStepsHtml(test.steps)) : ''
984981
const featureDetails = test.isBdd && test.feature ? generateBddFeatureHtml(test.feature) : ''

test/data/sandbox/configs/html-reporter-plugin/empty_test.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)