1
0
Fork 0
mirror of https://github.com/dorny/test-reporter.git synced 2026-03-21 23:52:12 +01:00

Modernize ESLint configuration

This commit is contained in:
Jozef Izso 2026-03-02 17:15:02 +01:00
parent 393efa337c
commit eed2d2d031
Failed to extract signature
8 changed files with 86 additions and 121 deletions

View file

@ -62,8 +62,11 @@ export class DotnetTrxParser implements TestParser {
}
private getTestClasses(trx: TrxReport): TestClass[] {
if (trx.TestRun.TestDefinitions === undefined || trx.TestRun.Results === undefined ||
!trx.TestRun.TestDefinitions.some(td => td.UnitTest && Array.isArray(td.UnitTest))) {
if (
trx.TestRun.TestDefinitions === undefined ||
trx.TestRun.Results === undefined ||
!trx.TestRun.TestDefinitions.some(td => td.UnitTest && Array.isArray(td.UnitTest))
) {
return []
}
@ -81,7 +84,7 @@ export class DotnetTrxParser implements TestParser {
const testClasses: {[name: string]: TestClass} = {}
for (const r of unitTestsResults) {
const className = r.test.TestMethod[0].$.className ?? "Unclassified"
const className = r.test.TestMethod[0].$.className ?? 'Unclassified'
let tc = testClasses[className]
if (tc === undefined) {
tc = new TestClass(className)

View file

@ -1,8 +1,6 @@
import { ParseOptions, TestParser } from '../../test-parser.js'
import {ParseOptions, TestParser} from '../../test-parser.js'
import { GoTestEvent } from './golang-json-types.js'
import { getExceptionSource } from '../../utils/node-utils.js'
import { getBasePath, normalizeFilePath } from '../../utils/path-utils.js'
import {GoTestEvent} from './golang-json-types.js'
import {
TestExecutionResult,
@ -16,7 +14,7 @@ import {
export class GolangJsonParser implements TestParser {
assumedWorkDir: string | undefined
constructor(readonly options: ParseOptions) { }
constructor(readonly options: ParseOptions) {}
async parse(path: string, content: string): Promise<TestRunResult> {
const events = await this.getGolangTestEvents(path, content)
@ -24,13 +22,16 @@ export class GolangJsonParser implements TestParser {
}
private async getGolangTestEvents(path: string, content: string): Promise<GoTestEvent[]> {
return content.trim().split('\n').map((line, index) => {
try {
return JSON.parse(line) as GoTestEvent
} catch (e) {
throw new Error(`Invalid JSON at ${path} line ${index + 1}\n\n${e}`)
}
})
return content
.trim()
.split('\n')
.map((line, index) => {
try {
return JSON.parse(line) as GoTestEvent
} catch (e) {
throw new Error(`Invalid JSON at ${path} line ${index + 1}\n\n${e}`)
}
})
}
private getTestRunResult(path: string, events: GoTestEvent[]): TestRunResult {
@ -63,9 +64,8 @@ export class GolangJsonParser implements TestParser {
continue
}
let groupName: string | null
let rest: string[]
[groupName, ...rest] = event.Test.split('/')
const [first, ...rest] = event.Test.split('/')
let groupName: string | null = first
let testName = rest.join('/')
if (!testName) {
testName = groupName
@ -80,9 +80,8 @@ export class GolangJsonParser implements TestParser {
const lastEvent = eventGroup.at(-1)!
const result: TestExecutionResult = lastEvent.Action === 'pass' ? 'success'
: lastEvent.Action === 'skip' ? 'skipped'
: 'failed'
const result: TestExecutionResult =
lastEvent.Action === 'pass' ? 'success' : lastEvent.Action === 'skip' ? 'skipped' : 'failed'
if (lastEvent.Elapsed === undefined) {
throw new Error('missing elapsed on final test event')
}
@ -94,7 +93,7 @@ export class GolangJsonParser implements TestParser {
.filter(e => e.Action === 'output')
.map(e => e.Output ?? '')
// Go output prepends indentation to help group tests - remove it
.map(o => o.replace(/^ /, ''))
.map(o => o.replace(/^ {4}/, ''))
// First and last lines will be generic "test started" and "test finished" lines - remove them
outputEvents.splice(0, 1)
@ -103,7 +102,7 @@ export class GolangJsonParser implements TestParser {
const details = outputEvents.join('')
error = {
message: details,
details: details
details
}
}

View file

@ -1,12 +1,4 @@
export type GoTestAction = 'start'
| 'run'
| 'pause'
| 'cont'
| 'pass'
| 'bench'
| 'fail'
| 'output'
| 'skip'
export type GoTestAction = 'start' | 'run' | 'pause' | 'cont' | 'pass' | 'bench' | 'fail' | 'output' | 'skip'
export type GoTestEvent = {
Time: string

View file

@ -130,7 +130,7 @@ export class PhpunitJunitParser implements TestParser {
}
const failure = failures[0]
const details = typeof failure === 'string' ? failure : failure._ ?? ''
const details = typeof failure === 'string' ? failure : (failure._ ?? '')
// PHPUnit provides file path directly in testcase attributes
let filePath: string | undefined

View file

@ -199,7 +199,7 @@ export class NetteTesterJunitParser implements TestParser {
const failure = failures[0]
// For Nette Tester, details are in the message attribute, not as inner text
const details = typeof failure === 'string' ? failure : failure._ ?? failure.$?.message ?? ''
const details = typeof failure === 'string' ? failure : (failure._ ?? failure.$?.message ?? '')
// Try to extract file path and line from error details
let errorFilePath: string | undefined