| 199 | } |
| 200 | |
| 201 | function checkFlakyTestList(this: Context) { |
| 202 | const allTests: string[] = []; |
| 203 | |
| 204 | const stack = [this.test.parent]; |
| 205 | while (stack.length) { |
| 206 | const suite = stack.pop(); |
| 207 | allTests.push(...suite.tests.map(test => test.fullTitle())); |
| 208 | stack.push(...suite.suites); |
| 209 | } |
| 210 | allTests.reverse(); // Doesn't matter but when debugging easier to see this in the expected order. |
| 211 | |
| 212 | const flakyTestDoesNotExist = flakyTests.find(testName => !allTests.includes(testName)); |
| 213 | if (flakyTestDoesNotExist != null) { |
| 214 | console.error( |
| 215 | '\n' + '='.repeat(100) + '\n', |
| 216 | 'Flaky test:', |
| 217 | JSON.stringify(flakyTestDoesNotExist), |
| 218 | 'is not run at all', |
| 219 | '\n' + '='.repeat(100) + '\n' |
| 220 | ); |
| 221 | } |
| 222 | } |
| 223 | |
| 224 | export const mochaHooks = { |
| 225 | beforeAll: [beforeAllPluginImports, testConfigBeforeHook, checkFlakyTestList], |