import * as path from 'path' ; import { runTests , downloadAndUnzipVSCode } from 'vscode-test' ; import * as fs from 'fs-extra' ; async function main ( ) { try { let version = 'stable' ; if ( process . env . VERSION ) { version = process . env . VERSION ; } const extensionDevelopmentPath = path . resolve ( __dirname , '..' , '..' ) ; const extensionTestsPath = path . resolve ( __dirname ) ; console . log ( 'downloading vscode' ) ; await downloadAndUnzipVSCode ( version ) ; console . log ( 'setting up tests, running against VS Code version:' , version ) ; await runTests ( { extensionDevelopmentPath , extensionTestsPath , version : version } ) ; const pathToCheck = path . resolve ( __dirname , '..' , '..' , 'coverage' , 'coverage.json' ) ; const exists = await fs . pathExists ( pathToCheck ) ; if ( ! exists && version !== 'insiders' ) { throw new Error ( 'coverage does not exist so tests failed' ) ; } } catch ( err ) { console . error ( 'Failed to run tests' , err ) ; process . exit ( 1 ) ; } } main ( ) ;