From 1f5c23c42cab5209f827be3d6b9689a3fac7f765 Mon Sep 17 00:00:00 2001 From: ETtestim Date: Tue, 16 Jul 2024 10:22:50 +0300 Subject: [PATCH] ts expect + remove types --- src/junitParser.ts | 4 ++-- src/test/junitParser.test.ts | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) 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); });