All Projects → service-mocker → Service Mocker

service-mocker / Service Mocker

Licence: mit
🚀 Next generation frontend API mocking framework

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Service Mocker

Msw
Seamless REST/GraphQL API mocking library for browser and Node.js.
Stars: ✭ 7,830 (+657.99%)
Mutual labels:  mock, service-worker
mswjs.io
Official website and documentation for the Mock Service Worker library.
Stars: ✭ 77 (-92.55%)
Mutual labels:  mock, service-worker
Pytest Responsemock
Simplified requests calls mocking for pytest
Stars: ✭ 24 (-97.68%)
Mutual labels:  mock
Pclmock
A simple mocking framework in a PCL.
Stars: ✭ 40 (-96.13%)
Mutual labels:  mock
Shortify Punit
🔨 PHP Mocking Framework, includes method chaining stubbing.
Stars: ✭ 30 (-97.1%)
Mutual labels:  mock
Hoverboard
Conference website template
Stars: ✭ 935 (-9.49%)
Mutual labels:  service-worker
Budgeting
Budgeting - React + Redux + Webpack (tree shaking) Sample App
Stars: ✭ 971 (-6%)
Mutual labels:  service-worker
Hel
Hel rules over Helheim, where the souls unworthy of Valhalla reside. It's also a mock generator for Go.
Stars: ✭ 16 (-98.45%)
Mutual labels:  mock
Pushkit
All the required components to set up independent web push notifications 🎈
Stars: ✭ 45 (-95.64%)
Mutual labels:  service-worker
Peeplus
python+vue3前后端分离项目
Stars: ✭ 28 (-97.29%)
Mutual labels:  mock
Wiremockui
Wiremock UI - Tool for creating mock servers, proxies servers and proxies servers with the option to save the data traffic from an existing API or Site.
Stars: ✭ 38 (-96.32%)
Mutual labels:  mock
Next Pwa
Zero config PWA plugin for Next.js, with workbox 🧰
Stars: ✭ 909 (-12%)
Mutual labels:  service-worker
Iustudiomock
mock server for front end
Stars: ✭ 8 (-99.23%)
Mutual labels:  mock
Testable Mock
换种思路写Mock,让单元测试更简单
Stars: ✭ 977 (-5.42%)
Mutual labels:  mock
Offit
Simple but powerful API mocking library. Make mocks great again.
Stars: ✭ 25 (-97.58%)
Mutual labels:  mock
Elm Hn Pwa
Hacker News as a PWA built with Elm
Stars: ✭ 43 (-95.84%)
Mutual labels:  service-worker
Beats0.github.io
After a few hundred years, GitHub will become the world's largest digital cemetery, and most of the users have passed away. However, their homepages, projects and commit history describe what they did during their lifetime.
Stars: ✭ 23 (-97.77%)
Mutual labels:  service-worker
Reactspa
combination of react teconology stack
Stars: ✭ 911 (-11.81%)
Mutual labels:  mock
Node Quick Mock
🌞 基于Express的mock接口平台
Stars: ✭ 33 (-96.81%)
Mutual labels:  mock
Parcel Plugin Sw Cache
📦👷 Parcel plugin for caching using a service worker
Stars: ✭ 45 (-95.64%)
Mutual labels:  service-worker

Service Mocker

Travis CI CircleCI Coverage Version License

Build Status

Service Mocker is an API mocking framework for frontend developers. With the power of service workers, we can easily set up mocking services without any real servers. It sets developers free from intricate workflows, complex documentations and endless proxies from server to server.

Q: Is Service Worker ready?

A: No, not yet.

Q: Is Service Mocker ready?

A: Yes! Welcome to the future!

Installation

Since you are likely to run Service Mocker only during development, you will need to add service-mocker as a devDependency:

npm install service-mocker --save-dev

For legacy browsers, you may also need the polyfills:

npm install service-mocker-polyfills --save-dev

Features

  • No server is required.
  • Real HTTP requests and responses that can be inspected in modern browsers.
  • express style routing system.
  • IE10+ compatibility.

Hello new world

A typical mocker includes two parts: client and server. First, let's create a server script named server.js:

// server.js
import { createServer } from 'service-mocker/server';

const { router } = createServer();

router.get('/greet', (req, res) => {
  res.send('Hello new world!');
});

// or you can use the shorthand method
router.get('/greet', 'Hello new world!');

Then, we need to write a client script to connect to the server:

// app.js
import 'service-mocker-polyfills';
import { createClient } from 'service-mocker/client';

const client = createClient('path/to/server.js');

client.ready.then(async () => {
  const response = await fetch('/greet');

  console.log(await response.text());
});

After that, create a .html file and include ONLY the client script:

<script src="app.js"></script>

Now navigate your browser to your local dev server (e.g. http://localhost:3000). Open the console and you will see the following messages:

> [mocker:modern] connection established
>
> Hello new world!

Welcome to the future 👏.

Working with webpack

While using webpack, it's recommended to use sw-loader to create a standalone server script:

import scriptURL from 'sw-loader!path/to/server.js';
import { createClient } from 'service-mocker/client';

const client = createClient(scriptURL);

client.ready.then(...);

Docs & Demos

Team

Dolphin Wood Vincent Bel
Dolphin Wood Vincent Bel

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].