Skip to content

Commit

Permalink
Add functionality to write test results to a JSON file and improve te…
Browse files Browse the repository at this point in the history
…st case failure detection
  • Loading branch information
DE7924 committed Dec 23, 2024
1 parent c6e0295 commit 0960def
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
4 changes: 3 additions & 1 deletion dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

10 changes: 8 additions & 2 deletions src/scripts/testing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,26 @@ export const testing = async (
convert.xml2json(testResults, { compact: false, spaces: 2 }),
);

fs.writeFileSync(
"src/test/testResults.json",
convert.xml2json(testResults, { compact: true, spaces: 2 }),
);

outputStr +=
"<table><tr><th>File</th><th>Test Name</th><th>Line</th><th>Type</th><th>Message</th></tr>";

const testSuites = jsonResults["elements"][0]["elements"];
for (let i = 0; i < testSuites.length; i++) {

Check warning on line 66 in src/scripts/testing.ts

View workflow job for this annotation

GitHub Actions / code-quality

Expected a `for-of` loop instead of a `for` loop with this simple iteration
const testSuite = testSuites[i];
console.log(testSuite);
const testCases = testSuite["elements"].filter(
(element: any) => element.name === "testcase",
);
for (let j = 0; j < testCases.length; j++) {

Check warning on line 72 in src/scripts/testing.ts

View workflow job for this annotation

GitHub Actions / code-quality

Expected a `for-of` loop instead of a `for` loop with this simple iteration
const testCase = testCases[j];
const testCaseName = testCase["attributes"]["name"];
const testCaseFailure = testCase["elements"][0].filter(
(element: any) => element.name === "failure",
const testCaseFailure = testCase.filter(
(element: any) => element["elements"][0].name === "failure",
);
if (testCaseFailure) {
const file = testCase["attributes"]["file"];
Expand Down

0 comments on commit 0960def

Please sign in to comment.