Skip to content

porchdotcom/nock-back-mocha

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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('https://example.com', function (err, res, body) {
            done(err);
        });
    });
});

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

About

Use nock.back with your mocha tests with minimal hassle.

Resources

Stars

Watchers

Forks

Packages

No packages published