Skip to content
This repository was archived by the owner on Dec 16, 2023. It is now read-only.
This repository was archived by the owner on Dec 16, 2023. It is now read-only.

Replay Needs Reset or Cleanup Function #159

Description

@ggb667

Replay needs a cleanup function.

I tried this at the start of index.js (for use in a before block in a mocha test):

const HTTP = require('http');
const HTTPS = require('https');
const DNS = require('dns');
const origHttpRequest = HTTP.request;
const origHttpGet = HTTP.get;
const origHttpsGet = HTTPS.get;
const originalLookup = DNS.lookup;

restore() {
HTTP.request = origHttpRequest;
HTTP.get = origHttpGet;
HTTPS.get = origHttpsGet;
DNS.lookup = originalLookup;
}

But I missed something because this still has problems when people use nock or sinon, and we would need something for the before block to undo this.

Activity

ggb667 commented on Nov 12, 2018

@ggb667
Author

What I ended up doing for now in each test:

before(function(){
if(process.env.REPLAY) {
Replay.mode = process.env.REPLAY;
}
});

after(function(){
Replay.mode = "bloody";
});

reopened this on Nov 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions