import { cleanAll , disableNetConnect , isDone , load , Scope } from 'nock' ; import * as path from 'path' ; import { HttpTestFileOptions } from "." ; import { findRootModuleDir } from './find-root-module-dir' ; /**
 * Test utility that will load stored HTTP sessions from disk and intercept subsequent requests.
 */ export class HttpTestPlayback { param options constructor ( private options ? ) { this . options = options || { } ; if ( ! this . options . testDataDirectory ) { this . options . testDataDirectory = path . join ( findRootModuleDir ( ) , 'test' , 'data' ) ; } } param name param disableOutboundHttp load ( name , disableOutboundHttp = true ) { if ( ! isDone ( ) ) { throw new Error ( 'HttpTestPlayback still has outstanding responses that were never requested!' ) ; } if ( disableOutboundHttp ) { disableNetConnect ( ) ; } cleanAll ( ) ; if ( ! name . endsWith ( '.json' ) ) { name += '.json' ; } return load ( path . join ( this . options . testDataDirectory , name ) ) ; } /**
     * Returns true if all loaded HTTP sessions have been served
     */ isDone ( ) { return isDone ( ) ; } }