- Click on the bottom left arrow to open the mock list.
- Select all mocks that you want to intercept.
- Reload page to apply the changes.
- Enjoy!! All requests that are intercepted will be returned with the mock data.
-
Install this package in your project
-
Add init mock service work function to intercept requests
initMockServiceWorker()
in your index, for example:// Init intercept requests (using service worker) to mock requests // just in development or staging environment if (env !== 'production') { const objMocks:GroupMockDebug[] = {YOUR MOCKS IN HERE}; initMockServiceWorker(objMocks); } // here your React render, it is just a e.g. ReactDOM.render( <React.StrictMode> <App /> </React.StrictMode>, document.getElementById('root') );
- the first param is a type
GroupMockDebug[]
with all mocks do has - you can organize mocks with
title
inside your arrayGroupMockDebug[]
- will intercept only mocks selected.
- obs: don't init in production environment
- the first param is a type
-
Add component in your project to you can select what to mock
-
const groupMockDebugsMock:GroupMockDebug[] = `YOUR MOCKS IN HERE`; <SelectMockContainer render={env !== 'production'} mocks={groupMockDebugsMock}>
-
-
Add Service Worker
- Create a file
mockServiceWorker.js
in theroot
from folter public, it need to stay in the root of your application. - Add this code in file you create
mockServiceWorker.js
:self.importScripts('https://truepay-mocks.web.app/mockServiceWorker.js');
- Create a file
-
When you init your application, you can click on bottom left arrow to open the mock list. If it doesn't have a value selected, it won't be intercepted.
This template should help get you started developing with Vue 3 and TypeScript in Vite. The template uses Vue 3 <script setup>
SFCs, check out the script setup docs to learn more.
- VS Code + Volar (and disable Vetur) + TypeScript Vue Plugin (Volar).
TypeScript cannot handle type information for .vue
imports by default, so we replace the tsc
CLI with vue-tsc
for type checking. In editors, we need TypeScript Vue Plugin (Volar) to make the TypeScript language service aware of .vue
types.
If the standalone TypeScript plugin doesn't feel fast enough to you, Volar has also implemented a Take Over Mode that is more performant. You can enable it by the following steps:
- Disable the built-in TypeScript Extension
- Run
Extensions: Show Built-in Extensions
from VSCode's command palette - Find
TypeScript and JavaScript Language Features
, right click and selectDisable (Workspace)
- Run
- Reload the VSCode window by running
Developer: Reload Window
from the command palette.