Package Exports
- mockingjay-npm-wrapper
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (mockingjay-npm-wrapper) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
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-wrapperHow 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 hereRunning the mocking server on a different port (default port is 8000):
const mockingServer = require('mockingjay-npm-wrapper');
mockingServer.serve('stubs/scenario-hello.yml', 9000)();