0.0.3 • Published 30 days ago

cap-js-mockdata v0.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
30 days ago

SAP CAP Mockdata Plugin

npm test

A SAP CAP plugin to generate CSV files populated with mock data for testing.

This plugin uses Faker to generate meaningful mock data both automatically and through annotations.

Setup

All you need to do is to install the plugin and add the @Mockdata annotations to your entities.

Installation

Install the plugin as an npm module:

npm i -D cap-js-mockdata

Annotation

The annotation tag is @Mockdata. You can add and combine all valid Faker module APIs.

// db/schema.cds

entity Customers : cuid, managed {
  name       String  @Mockdata: {person: 'fullName'};
  sex        String  @Mockdata: {person: 'sex'};
  creditCard String  @Mockdata: {finance: 'creditCardNumber'};
  phone      String  @Mockdata: {phone: 'number'};
  ipAddress  String  @Mockdata: {internet: 'ipv4'};
  email      String  @Mockdata: {internet: 'email'};
  street     String  @Mockdata: {location: 'streetAddress'};
  country    String  @Mockdata: {location: 'countryCode'};
};

Using

Once you have installed the plugin and added the annotations, or not, you can execute the following command in a terminal:

cds add mockdata

The cds add mockdata command will create CSV files for every supported CDS Entity. The CSV files will be created into the db/data folder, the filenames will be something like namespace-entityName.csv and their content will look like:

IDcreatedAtcreatedBymodifiedAtmodifiedBynamesexcreditCardphoneipAddressemailstreetcountry
bef3c7b8-1232-4860-bded-efd51443e508Sun Oct 06 2024 15:55:24 GMT-0300 (Brasilia Standard Time)Julius_Hintz48Sun Nov 03 2024 14:38:56 GMT-0300 (Brasilia Standard Time)Brain_MosciskiEdgar Langoshfemale3564-4519-0923-7387801.226.6645 x01258214.155.102.159Marcellus.Fritsch@hotmail.com640 Bramley CloseAustria
96ac7211-691a-4c2a-8fc0-0ae509693193Thu Mar 28 2024 20:32:35 GMT-0300 (Brasilia Standard Time)Clotilde_DAmoreThu Nov 23 2023 10:49:44 GMT-0300 (Brasilia Standard Time)Brendan.Corwin-SchinnerErica McDermottmale6567-6280-8822-5389-0611(240) 938-122337.230.118.100Shayne78@gmail.com1803 Feeney ParkCocos (Keeling) Islands
4fc525bc-e22b-4c55-a447-0e4c9fef1ffdFri Feb 09 2024 15:21:45 GMT-0300 (Brasilia Standard Time)Lance78Fri Feb 14 2025 05:25:29 GMT-0300 (Brasilia Standard Time)Donny_BlandaJoseph Lehnermale4686210527760312-939-710914.207.231.127Daija_Oberbrunner94@gmail.com79422 Collin DividePortugal
872b47a8-0bb1-47af-bc02-ef7290cff633Sat Feb 22 2025 01:34:16 GMT-0300 (Brasilia Standard Time)Mateo22Sun Sep 15 2024 18:42:41 GMT-0300 (Brasilia Standard Time)Myrtle52Leigh Wintheiser Imale6759-2563-9161-5976553.277.9724 x23110.88.166.234Elyssa.Adams79@gmail.com139 Park DriveMacao
0.0.3

30 days ago

0.0.2

1 month ago