Skip to main content

Debugging

Simulator Debugging

After the mini app project is compiled, developers can run the mini app in the simulator and quickly preview the mini app without a real machine. The basic interaction mode is to simulate finger touch and drag operations by clicking and dragging the mouse.

By default, the simulator automatically refreshes each time the changed code is saved, achieving quasi-real-time preview.

1. Start the simulator.

By default, the simulator is opened in a separate window: Description of the functions on the simulator (from left to right):

◾ Device Size: Select the preset size of an iOS or Android device to test the compatibility. You can also customize the device.

◾ Zoom: controls the display zoom ratio of the mini app.

◾ Simulation operation: Click the Simulation operation drop-down list box and select the function to be simulated.

◾ Expand/Hide DevTools: Click the icon to expand or hide the debugging tool. By default, the debugging tool is hidden.

◾ Refresh: Recompile the code and refresh the simulator.

◾ Touch function: Simulates gesture touch and drag operations.

◾ Right side of simulator: debugging tool, with simulator debugging mini app code.

• MOCK commissioning

When a mini app invokes a native API or a SuperApp customized API, the simulator cannot simulate the interface return. Therefore, the plug-in provides the API customization function. With this function, developers can customize the API return information for MOCK debugging.

With this function, developers can quickly define APIs, customize API names and callbacks, apply, or delete APIs, and import and export APIs in JSON files.

A simple example will demonstrate the use of this feature:

  1. The mini app invokes an interface customized by the SuperApp, for example, getAppVersion.

  2. Create a new function to call the API

  3. Open Custom API in the plug-in menu to customize the return value of this interface.

  4. Open the simulation window and view the console

  5. Click the button to view the callback information. Figure 1 Invoking APIs

Tips:

  1. The priority of a custom API is higher than that of an existing applet API. If the name of a custom API is the same as that of an existing API, the original API will be overwritten and become invalid.
  2. To prevent API information loss, Macle backs up the customized APIs in the app in real time in the mini app cache directory. The backup path is as follows:
  3. % Current User Directory %.macle\mock\mockApi.json