| 441 | }; |
| 442 | |
| 443 | const addSpecsToSuite = ( |
| 444 | suite: Suite, |
| 445 | specDefinitions: SpecDefinitionsFn, |
| 446 | ) => { |
| 447 | const parentSuite = currentDeclarationSuite; |
| 448 | parentSuite.addChild(suite); |
| 449 | currentDeclarationSuite = suite; |
| 450 | |
| 451 | let declarationError: undefined | Error = undefined; |
| 452 | let describeReturnValue: unknown | Error; |
| 453 | try { |
| 454 | describeReturnValue = specDefinitions.call(suite); |
| 455 | } catch (error: any) { |
| 456 | declarationError = error; |
| 457 | } |
| 458 | |
| 459 | if (isPromise(describeReturnValue)) { |
| 460 | declarationError = new Error( |
| 461 | 'Returning a Promise from "describe" is not supported. Tests must be defined synchronously.', |
| 462 | ); |
| 463 | } else if (describeReturnValue !== undefined) { |
| 464 | declarationError = new Error( |
| 465 | 'A "describe" callback must not return a value.', |
| 466 | ); |
| 467 | } |
| 468 | |
| 469 | if (declarationError) { |
| 470 | this.it('encountered a declaration exception', () => { |
| 471 | throw declarationError; |
| 472 | }); |
| 473 | } |
| 474 | |
| 475 | currentDeclarationSuite = parentSuite; |
| 476 | }; |
| 477 | |
| 478 | function findFocusedAncestor(suite: Suite) { |
| 479 | while (suite) { |