Skip to content

Commit

Permalink
🐞 fix: null check
Browse files Browse the repository at this point in the history
  • Loading branch information
maxisam committed Oct 9, 2023
1 parent 9979a20 commit a5a4ced
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
6 changes: 6 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,9 @@ const parseSummary = (file) => {
};
};
const parseResults = (file) => {
if (!file.TestRun.Results || !file.TestRun.Results[0].UnitTestResult) {
return [];
}
const results = file.TestRun.Results[0].UnitTestResult;
return results.map((result) => {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
Expand All @@ -562,6 +565,9 @@ const parseResults = (file) => {
});
};
const parseDefinitions = (file) => {
if (!file.TestRun.TestDefinitions || !file.TestRun.TestDefinitions[0].UnitTest) {
return [];
}
const definitions = file.TestRun.TestDefinitions[0].UnitTest;
return definitions.map(definition => {
var _a;
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion src/parsers/trx.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ResultParser, ITestSuit, TestOutcome } from '../data';
import { ITestSuit, ResultParser, TestOutcome } from '../data';
import { readXmlFile } from '../utils';

const parseTrx: ResultParser = async (filePath: string) => {
Expand Down Expand Up @@ -41,6 +41,9 @@ const parseSummary = (file: any) => {
};

const parseResults = (file: any) => {
if (!file.TestRun.Results || !file.TestRun.Results[0].UnitTestResult) {
return [];
}
const results = file.TestRun.Results[0].UnitTestResult as any[];

return results.map((result: any) => ({
Expand All @@ -62,6 +65,9 @@ const parseResults = (file: any) => {
};

const parseDefinitions = (file: any) => {
if (!file.TestRun.TestDefinitions || !file.TestRun.TestDefinitions[0].UnitTest) {
return [];
}
const definitions = file.TestRun.TestDefinitions[0].UnitTest as any[];

return definitions.map(definition => ({
Expand Down

0 comments on commit a5a4ced

Please sign in to comment.