openui5-smart-mockserver
An extended UI5 MockServer that generates meaningful mock data with Faker.js, from the metadata's sap:semantics annotations or from rules that map an OData property to a Faker method.
The UI5 MockServer answers OData requests from metadata and, left to itself, fills the entities with placeholder values. This library adds a SmartMockServer that generates the data from the metadata's sap:semantics annotations, and for metadata without annotations takes smart rules that map an OData property to a Faker.js method such as name.firstName or internet.email. It is used the way the stock mock server is: create an instance with a rootUri, optionally call setSmartRules(), then simulate() with the metadata URL and bGenerateMissingMockData: true, then start(). The repository carries a browser demo and a ServiceWorker variant of it (demo-sw).
Facts
Where it sits
Who is behind it
In the atlas: maintains 16, contributes to 41, wrote 4@mauriciolauffermaintainer
What it declares
Every artifact
- Type
- Package
- Origin
- Independently maintained
As a package
- Where it runs
- does not say
- Distributed through
- npm
Connections
Unit, integration and end-to-end tests for UI5 apps
Framework core: module loader, MVC runtime, binding, routing, theming
Download
Install
npm add openui5-smart-mockserverDerived from the package name. No recipe recorded; the README has the configuration.
README
quoted from mauriciolauffer/openui5-smart-mockserver under MIT, readopenui5-smart-mockserver
An extended and smarter version of UI5 MockServer for meaningful mock data.
OpenUI5 Smart MockServer uses the open source library Faker.js to generate better fake data for testing your app or for a demo. You can use any available method in Faker.js.
Smart data can be automatically generated based on OData SAP Semantics Annotations. You don't need to code anything, just run Smart MockServer with a metadata.xml containing SAP Semantics Annotations. In case your metadata.xml doesn't have SAP Semantics annotations, you can set Smart Rules manually mapping the OData property to a Faker.js method.
Regular MockServer: just a bunch of texts and numbers

Smart MockServer: meaningful data, better for tests and presentations to customer

OData SAP Semantics Annotations
OData SAP Semantic Annotations tell which of the OData properties contain e.g. a phone number, a part of a name or address, or something related to a calendar event or an analytic query. This is important for apps running on mobile devices that want to seamlessly integrate into contacts, calendar, and telephony. https://wiki.scn.sap.com/wiki/display/EmTech/SAP+Annotations+for+OData+Version+2.0#SAPAnnotationsforODataVersion2.0-Property_sap_semanticsAttributesap:semantics
Smart MockServer will generate data for these properties automatically, but not for all of them, have a look at the demo to see the supported sap:semantics annotations.
Faker.js
For any references, please follow
Faker.js: https://github.com/marak/Faker.js
Faker.js methods: https://github.com/marak/Faker.js/#api-methods
Demo
You can check out a live demo here:
https://mauriciolauffer.github.io/openui5-smart-mockserver/demo/webapp/index.html
And for a live demo using ServiceWorker:
https://mauriciolauffer.github.io/openui5-smart-mockserver/demo-sw/webapp/index.html
Project Structure
- demo - Library's live demo
- demo-sw - Library's live demo with ServiceWorker
- dist - Distribution folder which contains the library ready to use
- src - Development folder
- test - Testing framework for the library
Getting started
Installation
Install openui5-smart-mockserver as an npm module
$ npm install openui5-smart-mockserver
Configure manifest.json
Add the library to sap.ui5/dependencies/libs and set its path in sap.ui5/resourceRoots in your manifest.json file, as follows:
{
"sap.ui5": {
"dependencies": {
"libs": {
"openui5.smartmockserver": {}
}
},
"resourceRoots": {
"openui5.smartmockserver": "./FOLDER_WHERE_YOU_PLACED_THE_LIBRARY/openui5/smartmockserver/"
}
}
}
How to use
You can use Smart MockServer just like you use your old MockServer! Import openui5-smart-mockserver to your UI5 controller using sap.ui.define or sap.ui.require:
sap.ui.define([
'openui5/smartmockserver/SmartMockServer'
], function (SmartMockServer) {
'use strict';
return {
init: function() {
const metadataUrl = 'local/path/to/the/file/metadata.xml';
const mockServerUrl = 'odata/service/url';
const mockServer = new SmartMockServer({ rootUri: mockServerUrl });
// You only need to call this method in case your metadata.xml doesn't have sap:semantics annotations
// and you want to create nice data for the OData property
mockServer.setSmartRules(this._getSmartRules());
SmartMockServer.config({
autoRespond: true,
autoRespondAfter: 1
});
mockServer.simulate(metadataUrl, {
bGenerateMissingMockData: true
});
mockServer.start();
},
_getSmartRules: function() {
//Here we define the smart rules for entity's properties
const smartRules = []; //Smart rules must be an array with objects such as the following example
smartRules.push({
entityName: 'Employee', //Entity Name
properties: [
{
name: 'FirstName', // Entity's property name
fakerMethod: 'name.firstName' //Faker.js method which will be used for this property
},
{ name: 'Address', fakerMethod: 'location.streetAddress' },
{ name: 'Phone', fakerMethod: 'phone.number' },
{ name: 'Email', fakerMethod: 'internet.email' }
]
});
return smartRules;
}
};
}
);
Author
Mauricio Lauffer
License
This project is licensed under the MIT License - see the LICENSE file for details
History
Others providing
Compare all 14 on the UI5 testing page →- ui5-test-runnerui5-test-runnerA standalone command line that runs a UI5 project's QUnit and OPA test pages in parallel browser instances, written for suites too large for one browser, and merges their coverage into one report.independent, ui5Command line running UI5 QUnit and OPA tests in parallelfrom UI5
- ui5-middleware-odata-recorderui5-middleware-odata-recorderA UI5 server middleware that records the OData traffic a running app makes against a real backend and writes entity JSON files and metadata.xml that the Fiori elements mock server can replay.independent, ui5UI5 middleware recording OData traffic as mock server datasetsfrom UI5
- jest-environment-ui5jest-environment-ui5A Jest test environment named ui5 that boots UI5 from a local HTML file into jsdom, so UI5 unit tests run in Node.js with no web server and no browser.independent, ui5Jest environment running UI5 unit tests in Node.jsfrom UI5
- vitest-environment-ui5vitest-environment-ui5A Vitest environment named ui5 that boots UI5 from a local HTML file into jsdom, so UI5 unit tests run in Node.js with no web server and no browser.independent, ui5Vitest environment running UI5 unit tests in Node.jsfrom UI5
- wdio-qunit-servicewdio-qunit-serviceA WebdriverIO service that runs QUnit HTML test pages in a browser and reports the results as WebdriverIO test suites, presented as a drop-in replacement for Karma-based QUnit setups.independent, ui5WebdriverIO service running QUnit test pagesfrom UI5
- @openui5/sap.ui.core@openui5/sap.ui.coreThe OpenUI5 core: the module loader, the MVC runtime, data binding, routing, theming and the test stack, which is everything a UI5 app does before a single community package is added.sap official, ui5Framework core: module loader, MVC runtime, binding, routing, themingfrom UI5
- karma-ui5-transpilekarma-ui5-transpileA Karma preprocessor that transpiles a UI5 project's sources with the ui5-tooling-transpile configuration in its ui5.yaml.community org, ui5Karma preprocessor transpiling UI5 sources via ui5-tooling-transpilefrom UI5
- ui5-journey-recorderui5-journey-recorderA Chrome extension that records clicks and inputs against a running UI5 app and generates OPA5 or wdi5 end-to-end test code from the recorded journey.community org, ui5Chrome extension generating OPA5 or wdi5 tests from recorded journeysfrom UI5
- wdi5-cucumberwdi5-cucumberA wdi5 plugin that extends wdi5's end-to-end testing with Cucumber-style BDD scenarios, run against UI5 Fiori Elements apps.community org, ui5wdi5 plugin for Cucumber-style BDD tests on Fiori Elements appsfrom UI5
- wdi5-fe-selectorswdi5-fe-selectorsA set of wdi5-flavoured control selectors tuned for locating controls in Fiori Elements apps, extending the selectors wdi5 itself provides.community org, ui5wdi5 selectors for locating controls in Fiori Elements appsfrom UI5
- wdio-ui5-servicewdio-ui5-serviceEnd-to-end testing for UI5 as a WebdriverIO service that drives a real browser through UI5's own test API, so a test addresses controls with OPA5-compatible selectors rather than DOM nodes.community org, ui5End-to-end testing for UI5 on WebdriverIO with UI5 control selectorsfrom UI5
- @ui5/middleware-code-coverage@ui5/middleware-code-coverageUI5 CLI server middleware that instruments a project's JavaScript files with Istanbul as the dev server sends them, and generates the coverage report from the records the OpenUI5 QUnit tests send back.sap official, ui5UI5 CLI middleware for Istanbul code coveragefrom UI5
- vscode-ui5-odata-mock-generatorvscode-ui5-odata-mock-generatorVS Code extension that generates JSON mock data files for an OData service from its metadata, with faker.js values, per-set sizes, value lists and values tied to other properties.independent, ui5VS Code extension generating OData mock data from service metadatafrom UI5
Details
Sources
Sources are graph entities: the same page may back several entries, and an unreachable source flags every row that rests on it.
Compatibility and provenance
History in the atlas
- First seen.
For your agent
- Ref
artifact:mauriciolauffer-openui5-smart-mockserver- JSON
- /artifacts/mauriciolauffer-openui5-smart-mockserver.json
- MCP
- Connecting an agent