import axios from "axios" ; import { PROXAY_HOST } from "./config" ; import { setupServers } from "./setup" ; describe ( "Switching tapes" , ( ) => { const servers = setupServers ( { mode : "replay" , tapeDirName : "switching-tapes" , } ) ; it ( "can switch between record and replay mode" , async ( ) => { await axios . post ( `${ PROXAY_HOST }/__proxay/tape` , { tape : "my-tape" , mode : "record" , } ) ; expect ( servers . backend . requestCount ) . toBe ( 0 ) ; expect ( ( await axios . get ( `${ PROXAY_HOST }/recorded-path` ) ) . data ) . toBe ( "/recorded-path" ) ; expect ( servers . backend . requestCount ) . toBe ( 1 ) ; await axios . post ( `${ PROXAY_HOST }/__proxay/tape` , { tape : "my-tape" , mode : "replay" , } ) ; expect ( ( await axios . get ( `${ PROXAY_HOST }/recorded-path` ) ) . data ) . toBe ( "/recorded-path" ) ; expect ( servers . backend . requestCount ) . toBe ( 1 ) ; } ) ; } ) ;