import * as path from 'path' ; import testRunner = require ( 'vscode/lib/testrunner' ) ; const options = { ui : 'tdd' , useColors : true } ; options . reporter = 'mocha-multi-reporters' ; options . reporterOptions = { reporterEnabled : 'spec, mocha-junit-reporter' , mochaJunitReporterReporterOptions : { mochaFile : path . join ( __dirname , '..' , '..' , 'test-results.xml' ) } } ; for ( const envVar of Object . keys ( process . env ) ) { const match = envVar . match ( /^mocha_(.+)/i ) ; if ( match ) { const [ , option ] = match ; let value = process . env [ envVar ] || '' ; if ( typeof value === 'string' && ! isNaN ( parseInt ( value ) ) ) { value = parseInt ( value ) ; } options [ option ] = value ; } } console . warn ( `Mocha options: ${ JSON . stringify ( options , null , 2 ) }` ) ; testRunner . configure ( options ) ; module . exports = testRunner ;