How to use the @pollyjs/utils.timestamp function in @pollyjs/utils

To help you get started, we’ve selected a few @pollyjs/utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Netflix / pollyjs / packages / @pollyjs / core / src / -private / request.js View on Github external
async respond(response) {
    const { statusCode, headers, body } = response || {};

    assert(
      'Cannot respond to a request that already has a response.',
      !this.didRespond
    );

    // Timestamp the response
    this.response.timestamp = timestamp();

    // Set the status code
    this.response.status(statusCode);

    // Se the headers
    this.response.setHeaders(headers);

    // Set the body without modifying any headers (instead of using .send())
    this.response.body = body;

    // Trigger the `beforeResponse` event
    await this._emit('beforeResponse', this.response);

    // End the response so it can no longer be modified
    this.response.end();
github Netflix / pollyjs / packages / @pollyjs / core / src / -private / request.js View on Github external
async setup() {
    // Trigger the `request` event
    await this._emit('request');

    // Setup the response
    this.response = new PollyResponse();
    this.didRespond = false;

    // Setup this request's identifiers, id, and order
    await this._identify();

    // Timestamp the request
    this.timestamp = timestamp();
  }