Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async record(pollyRequest) {
pollyRequest.action = ACTIONS.RECORD;
if ('navigator' in global && !navigator.onLine) {
console.warn(
'[Polly] Recording may fail because the browser is offline.\n' +
`${stringifyRequest(pollyRequest)}`
);
}
return this.onRecord(pollyRequest);
}
import { ACTIONS } from '@pollyjs/utils';
const FORMATTED_ACTIONS = {
[ACTIONS.RECORD]: 'Recorded',
[ACTIONS.REPLAY]: 'Replayed',
[ACTIONS.INTERCEPT]: 'Intercepted',
[ACTIONS.PASSTHROUGH]: 'Passthrough'
};
export default class Logger {
constructor(polly) {
this.polly = polly;
this.groupName = null;
}
connect() {
this._middleware = this.polly.server
.any()
.on('error', (...args) => this.logError(...args))
.on('response', (...args) => this.logRequest(...args));