Socket
Socket
Sign inDemoInstall

nock-back-mocha

Package Overview
Dependencies
34
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    nock-back-mocha

Thin wrapper around [nock.back](https://github.com/pgte/nock#nock-back) that uses different nock files for each test, and cleans up when the mocha test is done.


Version published
Maintainers
1
Install size
3.35 MB
Created

Readme

Source

nock-back-mocha

Thin wrapper around nock.back that uses different nock files for each test, and cleans up when the mocha test is done.

Arguments

  • directory - where do you want the nock files stored?

Usage

describe('Tests that make http requests', function () {
    var nockFixtureDirectory = path.resolve(__dirname, './fixtures');
    var nockBackMocha = require('nock-back-mocha')(nockFixtureDirectory);
    beforeEach(nockBackMocha.beforeEach);
    afterEach(nockBackMocha.afterEach);
    
    it('makes an http request', function (done) {
        request('http://example.com', function (err, res, body) {
            done(err);
        });
    });
});

Pro Tip: use in combination with NOCK_BACK_MODE to generate http fixtures for your tests

FAQs

Last updated on 03 Dec 2015

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc