mockingjay-npm-wrapper

1.1.3 • Public • Published

mockingjay-npm-wrapper

Wraps the mockingjay server to npm - so you don't have to deal with the binaries manually. Original project: https://github.com/quii/mockingjay-server Supported platforms:

  • darvin (Mac)
  • linux

Installation

Mockingjay-npm-wrapper requires Node.js v6+ to run. Add mockingjay-npm-wrapper to your project:

$ npm install --save-dev mockingjay-npm-wrapper

How to use

Lets see a protractor example:

const mockingServer = require('mockingjay-npm-wrapper');
 
  describe('scenario - hello', function () {
    beforeAll(mockingServer.serve('stubs/scenario-hello.yml')); 
    afterAll(mockingServer.kill());
 
    it('should receive the message', function () {
      browser.get('http://localhost:8080');
      var result = element(by.id('result'));
      expect(result.getText()).toEqual('hello');
    });
  });

The wrapper api is designed to work well with beforeEach, beforeALL, afterEach, afterAll. If you want to use the server outside of those functions, you have to call the callback function manually:

const mockingServer = require('mockingjay-npm-wrapper'); 
 
const servCallback = mockingServer.serve('stubs/scenario-hello.yml'); 
const killCallback = mockingServer.kill();
 
// Mocking server is not available here
serveCallback();
// mocking server is running here
// ...
// mocking server is running here
killCallback();
// Mocking server is not available here

Running the mocking server on a different port (default port is 8000):

const mockingServer = require('mockingjay-npm-wrapper'); 
 
mockingServer.serve('stubs/scenario-hello.yml', 9000)(); 

Readme

Keywords

Package Sidebar

Install

npm i mockingjay-npm-wrapper

Weekly Downloads

2

Version

1.1.3

License

MIT

Last publish

Collaborators

  • zoltan.erdos