(originalFile: ts.SourceFile)
| 232 | } |
| 233 | |
| 234 | const getBaselineSourceFile = (originalFile: ts.SourceFile): string => { |
| 235 | const functionNames = getConfig().testDeclarationAliases |
| 236 | |
| 237 | const calls = getCallExpressionsByName(originalFile, functionNames) |
| 238 | |
| 239 | let baselineSourceFileText = originalFile.getFullText() |
| 240 | |
| 241 | // for each test function like `it` or `bench`, walk up the AST to find the complete expression |
| 242 | for (const call of calls) { |
| 243 | let currentNode: ts.Node = call |
| 244 | |
| 245 | // ensure we capture the entire chain like bench(...).types(...) |
| 246 | while (currentNode.parent && !ts.isExpressionStatement(currentNode)) |
| 247 | currentNode = currentNode.parent |
| 248 | |
| 249 | const fullExpressionText = currentNode.getFullText() |
| 250 | |
| 251 | baselineSourceFileText = baselineSourceFileText.replace( |
| 252 | fullExpressionText, |
| 253 | "" |
| 254 | ) |
| 255 | } |
| 256 | |
| 257 | return baselineSourceFileText |
| 258 | } |
no test coverage detected