MCPcopy
hub / github.com/jestjs/jest / addSpecsToSuite

Method addSpecsToSuite

packages/jest-jasmine2/src/jasmine/Env.ts:443–476  ·  view source on GitHub ↗
(
        suite: Suite,
        specDefinitions: SpecDefinitionsFn,
      )

Source from the content-addressed store, hash-verified

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) {

Callers

nothing calls this directly

Calls 2

isPromiseFunction · 0.90
addChildMethod · 0.80

Tested by

no test coverage detected