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

Function wrapIt

packages/jest-jasmine2/src/index.ts:131–150  ·  view source on GitHub ↗
(original: T)

Source from the content-addressed store, hash-verified

129 // in a future version
130 if (config.testLocationInResults === true) {
131 function wrapIt<T extends Global.ItBase>(original: T): T {
132 const wrapped = (
133 testName: Global.TestName,
134 fn: Global.TestFn,
135 timeout?: number,
136 ) => {
137 const sourcemaps = runtime.getSourceMaps();
138 let stack = getCallsite(1, sourcemaps);
139 const it = original(testName, fn, timeout);
140
141 if (stack.getFileName()?.startsWith(jestEachBuildDir)) {
142 stack = getCallsite(2, sourcemaps);
143 }
144 // @ts-expect-error: `it` is `void` for some reason
145 it.result.__callsite = stack;
146
147 return it;
148 };
149 return wrapped as any as T;
150 }
151
152 environment.global.it = wrapIt(environment.global.it);
153 environment.global.xit = wrapIt(environment.global.xit);

Callers 1

jasmine2Function · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected