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