title: nock: reply is not a function
body: <p>I am using <code>nock</code> to intercept my http requests in a <code>mocha</code> / <code>chai</code> environment. Also i am using <code>supertest</code> and <code>supertest-chai</code> to query my own <code>express</code> server. Like this:</p>
  
  <p>import { it } from 'mocha';
  import chai, { should } from 'chai';</p>
  
  <pre><code>import request from 'supertest';
  import supertestChai from 'supertest-chai';
  import Joi from 'joi';
  import chaiJoi from 'chai-joi';
  // others
  
  function itRespondsTo({ url, response, description, parameters = {} }) {
    const maxAge = parameters.maxAge || serverConfig.defaultCacheAge;
    const params = parameters ? `${Object.entries(parameters).map(([name, val]) =&gt; `&amp;${name}=${val}`).join('&amp;')}` : '';
    const path = `/oembed?url=${encodeURIComponent(url)}${params}`;
    const desc = description || `/oembed?url=${url}${params}`;
    it(`should respond to ${desc}`, (done) =&gt; {
      request(server)
        .get(path)
        .expect(200)
        .expect('Content-Type', /json/)
        .expect('Access-Control-Allow-Methods', 'GET')
        .expect('Cache-Control', `public, max-age=${maxAge}`)
        .expect(res =&gt; Object.values(OEMBED_TYPES).should.include(res.body.type)) // [1]
        .expect(res =&gt; Joi.validate(res.body, OEMBED_SCHEMAS[res.body.type]).should.validate)
        .expect(response)
        .end(done);
    });
  }
  
  describe('YouTube endpoint', () =&gt; {
    beforeEach(() =&gt; {
      nock(/youtube\.com/)
        .reply(200, remoteResponse);
    });
  
    afterEach(() =&gt; {
      nock.restore();
    });
  
    itRespondsTo({ url: 'https://youtu.be/m4hklkGvTGQ', response });
    itRespondsTo({ url: 'https://www.youtube.com/embed/m4hklkGvTGQ', response });
    itRespondsTo({ url: 'https://www.youtube.com/watch?v=m4hklkGvTGQ', response });
    itRespondsTo({ url: 'https://www.youtube.com/?v=m4hklkGvTGQ', response });
  });
  </code></pre>
  
  <p>When I run my tests, the first call of <code>itRespondsTo</code> will always throw an error:</p>
  
  <blockquote>
    <p>1) YouTube endpoint "before each" hook for "should respond to /oembed?url=<a href="https://youtu.be/m4hklkGvTGQ" rel="nofollow noreferrer">https://youtu.be/m4hklkGvTGQ</a>":</p>
    
    <p>TypeError: nock.reply is not a function</p>
  </blockquote>
  
  <p>And it will always be the first call of <code>itRespondsTo</code>. If I remove the first call, the next call will throw the error and so on. I have no idea why this is happening.</p>