Skip to content

Commit

Permalink
ts expect + remove types
Browse files Browse the repository at this point in the history
  • Loading branch information
ETtestim committed Jul 16, 2024
1 parent e18bd02 commit 1f5c23c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/junitParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<JUnitReport>;
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) {
Expand Down
9 changes: 6 additions & 3 deletions src/test/junitParser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

0 comments on commit 1f5c23c

Please sign in to comment.