import * as path from "path" ; import Mocha from "mocha" ; import glob from "glob" ; export function run ( testsRoot , cb ) { const mocha = new Mocha ( { color : true , ui : "tdd" , } ) ; 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 ) { console . error ( err ) ; cb ( err ) ; } } ) ; }