Skip to content

frankdsm/node-config-nock

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

config-nock

Config based mocking using node-nock

Installation

npm install config-nock

Usage

const request = require('request');
const mocker = require('config-nock');
const config = {
  'payment.monitoring': {
    baseUrl: 'https://example.com/api/',
    path: '/status/monitoring',
    method: 'GET',
    status: 200,
    options: {},
    response: ''
  }
};
mocker.setConfig(config);

// Enable mock
mocker.mock('payment.monitoring');

// Make a request in your tests
request.get('https://example.com/api/status/monitoring', (err, response, body) => {
  // Mocked request
});

Run Tests

npm test

About

Config based mocking using node-nock

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published