assaf / node-replay

When API testing slows you down: record and replay HTTP responses like a boss
http://documentup.com/assaf/node-replay
MIT License
522 stars 107 forks source link

Fixture not getting created for HTTPS requests #157

Closed saketh009 closed 5 years ago

saketh009 commented 6 years ago

Hi,

While recording HTTPS requests, I am getting the correct response and other details, but the Fixture is not getting created. Fixtures are getting created for a HTTP request for the same piece of code.

Can anyone please tell me if any additional settings or configuration is necessary for fixture creation for HTTPS requests?

TestScript:

"use strict";
const {
  setup,
  HTTP_PORT,
  HTTPS_PORT,
  INACTIVE_PORT,
  CORRUPT_PORT
} = require("./helpers");
const assert = require("assert");
const File = require("fs");
const HTTP = require("http");
const HTTPS = require("https");
const Async = require("async");
const Request = require("request");
const Replay = require("../src");

describe("Record", function() {
  describe("recording multiple of the same header", function() {
    const fixturesDir = `${__dirname}/fixtures/occ/localhost-${HTTPS_PORT}`;

    before(function() {
      Replay.mode = "record";
      Replay.reset("localhost");
    });

    before(function(done) {
      const options = {
        method: "GET",
        hostname: "localhost",
        path: "/home",
        port: HTTPS_PORT,
        rejectUnauthorized: false
      };
      const request = HTTPS.request(options, function(_) {
        response = _;
        response.body = "";
        response.on("data", function(chunk) {
          response.body += chunk;
        });
        response.on("end", done);
      });
      request.on("error", done);
      request.end();
    });

    it("should return response body", function() {
      console.log(
        "https app response body:-------------------------------",
        response.body
      );
    });
  });
});
shmargum commented 6 years ago

I am experiencing the same issue

tamlyn commented 5 years ago

Which version of Node are you using? Could be related to #141 or #155.

shmargum commented 5 years ago

I have 10.4.1 so it does indeed sound related

djanowski commented 5 years ago

This should be fixed in 2.4.0. See #157 for reference. Thank you.