diff --git a/src/junitParser.ts b/src/junitParser.ts index 5b922d9..9c74efd 100644 --- a/src/junitParser.ts +++ b/src/junitParser.ts @@ -70,8 +70,8 @@ async function parseFile(file: string, projectTokenDictionaryStrs: string[]) { const data: string = fs.readFileSync(file, 'utf8'); const parser = new XMLParser({ allowBooleanAttributes: true, ignoreAttributes: false, attributeNamePrefix: '' }); const report = parser.parse(data) as Partial; - const testsuites = castArray(report?.testsuite || report.testsuites?.testsuite); - return Promise.all(testsuites.map(async (testsuite: JUnitSuite | undefined) => parseSuite(file, projectTokenDictionaryStrs, testsuite))); + const testsuites = castArray(report.testsuite || report.testsuites?.testsuite); + return Promise.all(testsuites.map(async (testsuite) => parseSuite(file, projectTokenDictionaryStrs, testsuite))); } async function parseSuite(fileName: string, projectTokenDictionaryStrs: string[], testsuite?: JUnitSuite) { diff --git a/src/test/junitParser.test.ts b/src/test/junitParser.test.ts index 811354e..5718473 100644 --- a/src/test/junitParser.test.ts +++ b/src/test/junitParser.test.ts @@ -2,14 +2,17 @@ import { test } from 'node:test'; import { parseTestReports } from '../junitParser.ts'; const DIRNAME = import.meta.dirname; - -test('should parse junit report with 3 suites', async (t: any) => { +test('should parse junit report with multiple suites', async (t) => { const testReports = await parseTestReports('test', 'test', `${DIRNAME}/xml/testsuites.xml`, []); + // @ts-expect-error t.assert.strictEqual(testReports.length, 3); + // @ts-expect-error t.assert.strictEqual(testReports[0].annotations.length, 2); }); -test('should parse junit report with 1 suite', async (t: any) => { +test('should parse junit report with 1 suite', async (t) => { const testReports = await parseTestReports('test', 'test', `${DIRNAME}/xml/testsuite.xml`, []); + // @ts-expect-error t.assert.strictEqual(testReports.length, 1); + // @ts-expect-error t.assert.strictEqual(testReports[0].annotations.length, 2); });