Mock Guide
Why mock matters in Zova
Zova provides an out-of-the-box mock mechanism so frontend development can continue even when a real backend integration path is incomplete or intentionally decoupled.
That matters because page, API, and server-data workflows often need stable response shapes before the final backend contract is available.
Core mock model
The Zova mock mechanism is based on vite-plugin-fake-server and is integrated into the frontend development workflow.
A mock route is typically defined in a .fake.ts file inside the relevant module.
Mock file structure
Representative example:
import { defineFakeRoute } from 'vite-plugin-fake-server-turbo/client';
export default defineFakeRoute([
{
url: '/home/layout/menu/select',
method: 'get',
response: () => {
return {
code: 0,
message: 'Success',
data: [],
};
},
},
]);Key points:
- mock files use the
.fake.tsextension defineFakeRoute(...)provides the route definition shape- each mock route describes the request path, method, and response
Where mock files belong
Mocks belong near the frontend module that consumes or defines the route shape.
Representative example:
src/suite/a-home/modules/home-layout/mock/menu.fake.ts
This keeps mock behavior close to the page, API, or business module that depends on it.
Relationship to frontend APIs and server data
Mocking fits naturally with:
A common workflow is:
- define or update the frontend page or API contract
- provide a mock route with the expected response shape
- build page, component, or model behavior against that mock response
- later replace the mock-backed path with the real backend contract when ready
Configuration
Mock behavior is configured through environment variables such as:
MOCK_ENABLEDMOCK_LOGGERMOCK_BASE_NAMEMOCK_BUILDMOCK_BUILD_PORTMOCK_BUILD_OUTPUTMOCK_BUILD_CORS
These settings control whether mocks are enabled, whether a standalone fake server should be built, and how the mock server behaves.
Development and production behavior
By default, production builds do not generate the fake server.
If a standalone fake server should be generated during build, MOCK_BUILD must be enabled.
That means mock support can be used in development only, or intentionally packaged for separate deployment when needed.
When to use mock
Use mock when:
- frontend page or API work needs stable response data before the backend is ready
- you want to prototype UI behavior against an expected contract
- you want repeatable local demo or development behavior without a live backend dependency
Do not treat mock as the final source of truth for the contract when a real backend/OpenAPI path already exists.
Implementation checks for mock-versus-contract decisions
When editing frontend integration paths, ask:
- is the real backend contract available yet?
- should this flow use a temporary mock route or a real
$api/OpenAPI path? - does the mock response shape match the intended page, API, or model contract?
- should mock be enabled only for development, or is a standalone fake server also needed?
That helps AI keep frontend development moving without confusing temporary mock behavior with final backend truth.