mardi 26 mai 2020

nockBack fails to record any fixtures

I cannot get nockBack to record any fixtures, although it should do that. My test code looks as follows:

describe("#searchForProjects", function () {
beforeEach(function () {
  nock.back.setMode("record");
  this.con = getTestConnection(ApiType.Production);
});

it("finds a home project", async function () {
  const { nockDone, context } = await nock.back("search_for_project.json");

  await searchForProjects(this.con, "home:dancermak", {
    idOnly: true,
    exactMatch: true
  }).should.eventually.deep.equal([
    {
      name: "home:dancermak",
      apiUrl: normalizeUrl(ApiType.Production)
    }
  ]);

  nockDone();
});

});

Just running this specific test results in a NetConnectNotAllowedError: Nock: Disallowed net connect for $URL.

I have tried including a nock.restore() before the whole test, which results in the request going through, but nock doesn't bother recording anything.

The underlying code is using the https module from nodejs, so that shouldn't be a problem?

Any help would be greatly appreciated.

Aucun commentaire:

Enregistrer un commentaire