import * as ts from 'typescript' ; import * as path from 'path' ; import { extractCollectors , getProgramPaths } from './extract_collectors' ; import { parseTelemetryRC } from './config' ; describe ( 'extractCollectors' , ( ) => { it ( 'extracts collectors given rc file' , async ( ) => { const configRoot = path . join ( process . cwd ( ) , 'src' , 'fixtures' , 'telemetry_collectors' ) ; const tsConfig = ts . findConfigFile ( './' , ts . sys . fileExists , 'tsconfig.json' ) ; if ( ! tsConfig ) { throw new Error ( 'Could not find a valid tsconfig.json.' ) ; } const configs = await parseTelemetryRC ( configRoot ) ; expect ( configs ) . toHaveLength ( 1 ) ; const programPaths = await getProgramPaths ( configs [ 0 ] ) ; const results = [ ... extractCollectors ( programPaths , tsConfig ) ] ; expect ( results ) . toHaveLength ( 8 ) ; expect ( results ) . toMatchSnapshot ( ) ; } ) ; } ) ;