import { TASK_TEST_RUN_MOCHA_TESTS } from 'redspot/builtin-tasks/task-names' ; import { subtask } from 'redspot/config' ; import { RedspotRuntimeEnvironment } from 'redspot/types' ; import './type-extensions' ; import { GasReporterConfig } from './types' ; import { GasReporter } from './reporter' ; let mochaConfig ; param { RedspotRuntimeEnvironment } rse return { GasReporterConfig } function getDefaultOptions ( rse ) { return { abis : rse . artifacts . readAllArtifactSync ( ) , provider : rse . network . provider , registry : rse . network . registry , enabled : true } ; } param { RedspotRuntimeEnvironment } rse return { any } function getOptions ( rse ) { return { ... getDefaultOptions ( rse ) , ... ( rse . config as any ) . gasReporter } ; } /**
 * Overrides TASK_TEST_RUN_MOCHA_TEST to (conditionally) use eth-gas-reporter as
 * the mocha test reporter and passes mocha relevant options. These are listed
 * on the `gasReporter` of the user's config.
 */ subtask ( TASK_TEST_RUN_MOCHA_TESTS ) . setAction ( async ( args , rse , runSuper ) => { const options = getOptions ( rse ) ; if ( options . enabled ) { mochaConfig = rse . config . mocha || { } ; mochaConfig . reporter = GasReporter ; mochaConfig . reporterOptions = options ; rse . config . mocha = mochaConfig ; } return runSuper ( ) ; } ) ;