Skip to content

Commit

Permalink
Add function to retrieve nested project settings (#32)
Browse files Browse the repository at this point in the history
LGTM
  • Loading branch information
MoochaelCorcoran authored Apr 12, 2023
1 parent dc81339 commit 50bef67
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions src/ResultsParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,19 +102,14 @@ export default class ResultsParser {

addTestResult(suiteName: any, testCase: any) {
const testResults: testResult[] = [];
const projectSettings = this.getParentConfigInformation(testCase);
for (const result of testCase.results) {
testResults.push({
suiteName,
name: testCase.title,
status: result.status,
// eslint-disable-next-line no-underscore-dangle
browser: testCase.parent?.parent?._projectConfig?.use?.defaultBrowserType
? testCase.parent.parent._projectConfig.use.defaultBrowserType
: '',
// eslint-disable-next-line no-underscore-dangle
projectName: testCase.parent?.parent?._projectConfig?.name
? testCase.parent.parent._projectConfig.name
: '',
browser: projectSettings.browser,
projectName: projectSettings.projectName,
retry: result.retry,
retries: testCase.retries,
startedAt: new Date(result.startTime).toISOString(),
Expand Down Expand Up @@ -171,4 +166,16 @@ export default class ResultsParser {
);
return logsStripped;
}

getParentConfigInformation(testCase: any): {projectName: string, browser: string} {
if (testCase._projectConfig !== undefined) {
return {
projectName: testCase._projectConfig.name || '',
browser: testCase._projectConfig.use?.defaultBrowserType || '',
};
} if (testCase.parent) {
return this.getParentConfigInformation(testCase.parent);
}
return { projectName: '', browser: '' };
}
}

0 comments on commit 50bef67

Please sign in to comment.