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

Function _dispatchDescribe

packages/jest-circus/src/index.ts:47–91  ·  view source on GitHub ↗
(
  blockFn: Circus.BlockFn,
  blockName: Circus.BlockNameLike,
  describeFn: DescribeFn,
  mode?: Circus.BlockMode,
)

Source from the content-addressed store, hash-verified

45})();
46
47const _dispatchDescribe = (
48 blockFn: Circus.BlockFn,
49 blockName: Circus.BlockNameLike,
50 describeFn: DescribeFn,
51 mode?: Circus.BlockMode,
52) => {
53 const asyncError = new ErrorWithStack(undefined, describeFn);
54 if (blockFn === undefined) {
55 asyncError.message =
56 'Missing second argument. It must be a callback function.';
57 throw asyncError;
58 }
59 if (typeof blockFn !== 'function') {
60 asyncError.message = `Invalid second argument, ${blockFn}. It must be a callback function.`;
61 throw asyncError;
62 }
63 try {
64 blockName = convertDescriptorToString(blockName);
65 } catch (error) {
66 asyncError.message = (error as Error).message;
67 throw asyncError;
68 }
69
70 dispatchSync({
71 asyncError,
72 blockName,
73 mode,
74 name: 'start_describe_definition',
75 });
76 const describeReturn = blockFn();
77
78 if (isPromise(describeReturn)) {
79 throw new ErrorWithStack(
80 'Returning a Promise from "describe" is not supported. Tests must be defined synchronously.',
81 describeFn,
82 );
83 } else if (describeReturn !== undefined) {
84 throw new ErrorWithStack(
85 'A "describe" callback must not return a value.',
86 describeFn,
87 );
88 }
89
90 dispatchSync({blockName, mode, name: 'finish_describe_definition'});
91};
92
93const _addHook = (
94 fn: Circus.HookFn,

Callers 3

describeFunction · 0.85
onlyFunction · 0.85
skipFunction · 0.85

Calls 3

dispatchSyncFunction · 0.90
isPromiseFunction · 0.90

Tested by 1

describeFunction · 0.68