Product
Socket Now Supports uv.lock Files
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
:bangbang: This package has been renamed to mockyeah
Install latest:
$ npm install mockyeah --save-dev
Latest documentation and repository:
The documentation below is relevant to mockyeah version v0.8.x, which is old and crusty. Installing the latest above is advised.
"An invaluable service mocking platform built on Express."
Testing is difficult when you don't have control of your data. This project puts you in complete control, enabling you to implement real mock web services with ease. Real mock services means you have control of response payloads, HTTP Status Codes, response latency, and more.
Have a requirement to implement specific behavior when a service is slow to respond or a server returns an unexpected status code? No problem! This platform makes developing for such requirements easy.
$ npm install mock-yeah --save-dev
$ mkdir example-app && cd example-app
$ npm init # all defaults will be fine
mock-yeah
$ npm install mock-yeah --save-dev
$ touch index.js
const mockyeah = require('mock-yeah');
mockyeah.get('/hello-world', { text: 'Hello World' });
$ node index.js
Profit. You should see "Hello World" returned from your mock server.
const request = require('supertest')('http://localhost:4041');
const mockyeah = require('mock-yeah');
describe('Wondrous service', () => {
// remove service mocks after each test
afterEach(() => mockyeah.reset());
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);
});
});
mockyeah.get(path, options)
mockyeah.put(path, options)
mockyeah.post(path, options)
mockyeah.delete(path, options
Each of the methods above create a mock service with a HTTP verb matching its respective method name.
Path to which to respond. Fully supports all Express path matching options.
Response options informing Mock Yeah how to respond to matching requests. Supported options:
text/html
.application/json
.text/plain
.res.type(type)
; more info here: http://expressjs.com/en/4x/api.html#res.typeNote, only one of the following is permitted per service: filePath, fixture, html, json, or text.
Resets all existing mock services. Useful on test teardown.
Shuts down the Mock Yeah Express server. Useful if running Mock Yeah with a file
watcher. Mock Yeah attempts to start a new instance of Express each test
iteration. After all tests run, mockyeah.close()
should be called to shutdown
Mock Yeah's Express server. Failing to do so will result in EADDRINUSE
exceptions. This is due to Mock Yeah attempting to start a server on a port
occupied by a server it started previously.
Installing project and dependencies
# download project
$ git clone git@github.com:ryanricard/mock-yeah.git
$ cd mock-yeah
# install proper Node version
$ nvm install v4.2.3
$ nvm use
# install mocha
$ npm install -g mocha
# if tests pass, you're good to go
$ npm test
FAQs
This package has been renamed to "mockyeah".
The npm package mock-yeah receives a total of 1 weekly downloads. As such, mock-yeah popularity was classified as not popular.
We found that mock-yeah demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.
Security News
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.