In the long-term service process, we often encounter the following feedback from users who come to consult with us: Consultants is a front end staff, in the process of project development needs with the back-end for docking, encounter have not finished the back-end data output, he had to write static simulation data, in case of large projects, lengthy, complex code, a variety of data types including IP, pictures, address, function, etc., in a very short project cycle and acceptance of time, Manually modifying the simulation data is not practical at all.

EoLinker offers the best solution to this problem: the Mock API.Copy the code

With the Mock API, people at the front and back end just need to define interface documents to start working in parallel; Interface coupling between back ends and unprepared dependency interfaces in testing can also be Mock out without team parity. In this way, the development of self-testing can be carried out as soon as possible, and then advance the time of finding and repairing defects, but also effectively ensure the quality and progress of the whole product.

Basic Mock & Advanced Mock

EoLinker provides two ways to Mock an API, basic Mock and advanced Mock. How do you use both mocks? What is the difference between a basic Mock and an advanced Mock? Take a look below:

In eoLinker, basic Mocks, also known as simple Mocks, provide the following capabilities:

HTTP and HTTPS RESTful apis Verifying request modes (the free version is enabled by default. Advanced Mocks have the same functionality as basic Mocks. Advanced Mocks have the same functionality as basic Mocks. Support for mock data generation from MockJS rules, support for custom JS functions Support for mock (Pro) function points 3, 6, and 8 from mock (Pro) based on the values of build rules & properties set in advanced Mock. Go to AMS Pro for use. Let’s take a quick look at three important feature points.

1. Support generating mock data according to mock.js rules, support custom JS functions

Mock.js is surprisingly easy to Mock backend data with because it intercepts and simulates Ajax requests. Combined with the above scenario, eoLinker solves all of the following problems by supporting MockJS.

The documentation is not defined in advance, the development process, and the backend personnel may verbally tell you that the data is not actually returned. The eoLinker Advanced Mock itself standardizing this behavior, and efficient collaboration is not a problem.

You don’t need to write more code or manually modify the simulated data to restore as much real data as possible. Directly simulate background data return, get twice the result with half the effort.

Don’t worry about special formats such as IP, random number, picture, address multiple collection, rich format support to save a lot of time.

EoLinker’s Mock also supports complex data types such as custom functions and regees, making it easy to extend a wide variety of data types. .

Because of this, the eoLinker Mock API supports mock. js, which solves the problem of data emulation in front and back end development and greatly improves the productivity of development.

2. Verify the request parameters

EoLinker takes into account that many back-end interfaces verify parameters during development to determine which interface parameters are mandatory and which are non-mandatory.

Front-end development calls Mock interfaces. From the perspective of assistance, Mock APIS are used to simulate the backend interface to return parameters for collaborative front-end development, so parameter verification is necessary to simulate the most real back-end interface and better assist front-end development.

EoLinker Mock supports validation of request parameters to determine whether interface parameters are required to be passed so that no parameter is missed, thereby avoiding redundant work.

Support for Mock reconstruction based on generation rules & property values set in advanced Mocks

This feature is an advanced version of eoLinker’s functionality. EoLinker recognizes that the ability to recreate results based on the generation rules and attribute values set in advanced Mocks is very important in simulating background data because the parameters returned by the interface are different each time. So random generation can make the results of simulation more realistic.

Advanced Mock Tutorials

1. Edit Mock data

To go to the Interface editing page, click the advanced Mock TAB at the top to go to the Mock Settings page:

Note:

The completion of the Mock depends on the return parameters in the interface document. If you go to the Mock Settings page and find no fields that can be set, please return to the basic information TAB to improve the return information of the interface.

Use steps:

Return parameter to fill in key value pairs. If you have hierarchy results, please use two English right arrows >> or :: to indicate hierarchy:

Split fill out the Mockjs sample. The red box part of the following figure is explained:

Name Indicates the field name of the list. Min-max corresponding list generation rule; String corresponds to the value of the list attribute. Use it with @mock =, for example, @mock = ‘★’ to write the Mock syntax in the figure above.

Note: The part in red box is to set the overall return result type, which supports two types (Object /array). The generated rules and attribute values also correspond to Mockjs syntax.

2. Call MockAPI

Go to the interface details page and click the Mock TAB at the top. In the Mock section below, you can see the Mock API request address. Copy this address to access the Mock API and get the Mock data: