import * as mock from 'mock-require' ; let response = [ 'unset fake response' ] ; let lastUrl = '' ; let lastRequest = { } ; export let speech = { recognize : ( url , request ) => { lastUrl = url ; lastRequest = request ; return response ; } , } ; export function setResponse ( r ) { response = r ; } export function getLastUrl ( ) { return lastUrl ; } export function getLastRequest ( ) { return lastRequest ; } export function init ( ) { mock ( '@google-cloud/speech' , ( ) => speech ) ; }