( suite: SuiteLike, ancestors: Array<string>, testNamePatternRE: RegExp | null, )
| 40 | }; |
| 41 | |
| 42 | export const collectSpecs = ( |
| 43 | suite: SuiteLike, |
| 44 | ancestors: Array<string>, |
| 45 | testNamePatternRE: RegExp | null, |
| 46 | ): Array<AssertionResult> => { |
| 47 | const results: Array<AssertionResult> = []; |
| 48 | for (const child of suite.children) { |
| 49 | if ('children' in child) { |
| 50 | results.push( |
| 51 | ...collectSpecs( |
| 52 | child, |
| 53 | [...ancestors, child.description], |
| 54 | testNamePatternRE, |
| 55 | ), |
| 56 | ); |
| 57 | } else { |
| 58 | const fullName = child.getFullName(); |
| 59 | if (!testNamePatternRE || testNamePatternRE.test(fullName)) { |
| 60 | results.push({ |
| 61 | ancestorTitles: [...ancestors], |
| 62 | duration: null, |
| 63 | failing: false, |
| 64 | failureDetails: [], |
| 65 | failureMessages: [], |
| 66 | fullName, |
| 67 | invocations: 0, |
| 68 | location: null, |
| 69 | numPassingAsserts: 0, |
| 70 | retryReasons: [], |
| 71 | startAt: null, |
| 72 | status: 'pending', |
| 73 | title: child.description, |
| 74 | }); |
| 75 | } |
| 76 | } |
| 77 | } |
| 78 | return results; |
| 79 | }; |
| 80 | |
| 81 | export const buildCollectedTestResult = ({ |
| 82 | config, |
no test coverage detected