Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug for missing test suite for innnerSuite #59

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions src/parsers/mochawesome-json/mochawesome-json-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,21 +81,22 @@ export class MochawesomeJsonParser implements TestParser {
}

// Handle nested suites
const processNestedSuites = (suite: MochawesomeJsonSuite, nestedSuiteIndex: number, suiteName: string): void => {
const processNestedSuites = (suite: MochawesomeJsonSuite, suiteName: string): void => {
// Process suite tests
processAllTests(suite.tests, suiteName)

for (const innerSuite of suite.suites) {
for (const childSuite of suite.suites) {
// Process inner suite tests
processAllTests(innerSuite.tests, suiteName)

if (innerSuite?.suites[nestedSuiteIndex]?.suites.length > 0) {
processNestedSuites(innerSuite, 0, suiteName)
} else {
processAllTests(innerSuite?.suites[nestedSuiteIndex]?.tests, suiteName)
nestedSuiteIndex++
if (childSuite.tests.length > 0) {
processAllTests(childSuite.tests, suiteName)
}

// TODO - Figure out how to get 1.1.1.1.2 - suites with more than one object in them
for (const grandChildSuite of childSuite.suites) {
if (grandChildSuite?.suites.length > 0) {
processNestedSuites(childSuite, suiteName)
} else {
processAllTests(grandChildSuite.tests, suiteName)
}
}
}
}
Expand All @@ -114,7 +115,7 @@ export class MochawesomeJsonParser implements TestParser {
// Process tests that are in a suite
if (suites?.length > 0) {
for (const suite of suites) {
processNestedSuites(suite, 0, filePath ? filePath : suite.title)
processNestedSuites(suite, filePath ? filePath : suite.title)
}
}
}
Expand Down