MCPcopy Create free account
hub / github.com/arktypeio/arktype / getBaselineSourceFile

Function getBaselineSourceFile

ark/attest/cache/utils.ts:234–258  ·  view source on GitHub ↗
(originalFile: ts.SourceFile)

Source from the content-addressed store, hash-verified

232}
233
234const 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}

Callers 1

Calls 3

getConfigFunction · 0.90
replaceMethod · 0.80
getCallExpressionsByNameFunction · 0.70

Tested by

no test coverage detected