()
| 236 | |
| 237 | /** The *.test.ts file that called scenario(), from the registration stack. */ |
| 238 | const captureTestFile = (): string | undefined => { |
| 239 | const stack = new Error().stack ?? ""; |
| 240 | for (const line of stack.split("\n")) { |
| 241 | const match = /\(?(?:file:\/\/)?(\/[^():]+\.test\.ts)/.exec(line); |
| 242 | if (match) return match[1]; |
| 243 | } |
| 244 | return undefined; |
| 245 | }; |
| 246 | |
| 247 | /** |
| 248 | * This scenario's code as a reader sees it: the file minus import statements |