import * as glob from 'glob' ; import * as Mocha from 'mocha' ; import * as path from 'path' ; export function run ( testsRoot , cb ) { const mocha = new Mocha ( { ui : 'tdd' , reporter : 'mocha-multi-reporters' , reporterOptions : { reporterEnabled : 'spec, xunit' , xunitReporterOptions : { output : path . resolve ( __dirname , '..' , '..' , 'extensions-tests.xml' ) } } , color : true } ) ; glob ( '**/**.test.js' , { cwd : testsRoot } , ( err , files ) => { if ( err ) { return cb ( err ) ; } files . forEach ( f => mocha . addFile ( path . resolve ( testsRoot , f ) ) ) ; try { mocha . run ( failures => { cb ( null , failures ) ; } ) ; } catch ( err ) { cb ( err ) ; } } ) ; }