New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

mockyeah

Package Overview
Dependencies
Maintainers
2
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mockyeah

A powerful service mocking, recording, and playback utility.

  • 0.18.0-alpha.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
114
decreased by-13.64%
Maintainers
2
Weekly downloads
 
Created
Source

'use strict';

require('../TestHelper'); const MockYeahServer = require('../../server');

/**

  • Instantiate new server that can be closed without
  • affecting other tests. */ const mockyeah = MockYeahServer({ port: 0, adminPort: 0 });

const request = require('supertest')(mockyeah.server);

describe('Wondrous service', () => { // remove service mocks after each test afterEach(() => mockyeah.reset());

// stop mockyeah server after(() => mockyeah.close());

it('should create a mock service that returns an internal error', done => { // create failing service mock mockyeah.get('/wondrous', { status: 500 });

// assert service mock is working
request.get('/wondrous').expect(500, done);

});

it('should create a mock service that returns JSON', done => { // create service mock that returns json data mockyeah.get('/wondrous', { json: { foo: 'bar' } });

// assert service mock is working
request.get('/wondrous').expect(200, { foo: 'bar' }, done);

});

it('should verify a mock service expectation', done => { // create service mock with expectation const expectation = mockyeah .get('/wondrous', { text: 'it worked' }) .expect() .params({ foo: 'bar' }) .once();

// invoke request and verify expectation
request
  .get('/wondrous?foo=bar')
  .expect(200, 'it worked')
  .then(() => {
    expectation.verify();
    done();
  });

}); });

Keywords

FAQs

Package last updated on 12 Sep 2018

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc