Skip to content

Allowing Unmatched Requests in OpenAI Mock API #2574

Answered by mastermatt
chihebnabil asked this question in Q&A
Discussion options

You must be logged in to vote

You're taking the wrong approach with your "no match" listener. By that point the net-connect check has already happened.
Instead of:

nock.emitter.on('no match', function (req) {
            nock.enableNetConnect(req);
        });

Try:

nock.enableNetConnect(host => host !== "api.openai.com");

This is essentially telling Nock to allow real network connections for any host other than OpenAIs.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by chihebnabil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants