Skip to main content

Version: 22.10

Fixtures

Using mock data is an important part of creating a rapid development environment for the front-end development process. Journey Engage comes with a mock server that runs in the browser, allowing you to test you app without needing to rely on any back-end services.

Our mock server is based on Mirage JS. It intercepts any XMLHttpRequest or fetches requests your JavaScript app makes, and lets you mock the response. This means you can develop and test your app just as if it were talking to a real server.

The fixtures folder is set up as shown below.

src/fixtures/default/index.ts
import txnQuery from './txn/query';
import txnCount from './txn/count';
import txnCancel from './txn/cancel';
import txnReopen from './txn/reopen';
import txnAssign from './txn/assign';
import txnUnassign from './txn/unassign';
import txnComment from './txn/comment';
import userQuery from './user/query';
import jobQuery from './job/query';
import formQuery from './form/query';
import spaceQuery from './space/query';
import currentUserQuery from './currentUser/query';
import currentUserProfileUpdate from './currentUser/profile-update';
import currentUserPreferencesUpdate from './currentUser/preferences-update';

export default {
txnQuery,
txnCount,
txnCancel,
txnReopen,
txnAssign,
txnUnassign,
txnComment,
userQuery,
jobQuery,
formQuery,
spaceQuery,
currentUserQuery,
currentUserProfileUpdate,
currentUserPreferencesUpdate,
};

When the client (browser) sends a request, such as POST /workspaces/secure/api/v1/current-user/query, the locally launched app npm run start checks the configuration file to match the request path and method. If it matches, the request is processed through configuration.

For more information on how to specify the fixtures your app uses, see Space Configuration.