{"id":13395375,"url":"https://github.com/outbrain-inc/Leonardo","last_synced_at":"2025-03-13T20:32:12.378Z","repository":{"id":18727799,"uuid":"21939074","full_name":"outbrain-inc/Leonardo","owner":"outbrain-inc","description":"Your mocking ninja - an add-on tool for centralizing your client side mocking","archived":false,"fork":false,"pushed_at":"2024-03-03T07:55:23.000Z","size":8211,"stargazers_count":94,"open_issues_count":41,"forks_count":23,"subscribers_count":23,"default_branch":"master","last_synced_at":"2024-12-19T15:10:47.091Z","etag":null,"topics":["e2e-tests","front-end-development","javascript","leonardo","mocking","typescript","ui-tests"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/outbrain-inc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-07-17T11:16:53.000Z","updated_at":"2024-11-25T14:09:19.000Z","dependencies_parsed_at":"2023-02-15T09:16:09.339Z","dependency_job_id":"eac00e06-f403-4cbb-a942-3181540edd24","html_url":"https://github.com/outbrain-inc/Leonardo","commit_stats":{"total_commits":723,"total_committers":37,"mean_commits":19.54054054054054,"dds":0.7482710926694329,"last_synced_commit":"42cdf03ee51403a4dca4f86bfaa2f976f5700594"},"previous_names":["outbrain-inc/leonardo","outbrain/leonardo"],"tags_count":53,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/outbrain-inc%2FLeonardo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/outbrain-inc%2FLeonardo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/outbrain-inc%2FLeonardo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/outbrain-inc%2FLeonardo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/outbrain-inc","download_url":"https://codeload.github.com/outbrain-inc/Leonardo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242980830,"owners_count":20216285,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["e2e-tests","front-end-development","javascript","leonardo","mocking","typescript","ui-tests"],"created_at":"2024-07-30T17:01:54.684Z","updated_at":"2025-03-13T20:32:11.886Z","avatar_url":"https://github.com/outbrain-inc.png","language":"TypeScript","funding_links":[],"categories":["TypeScript","Developer"],"sub_categories":[],"readme":"\n\u003cdiv align=\"center\"\u003e\n\u003cimg\n  width=\"100\"\n  src=\"https://raw.githubusercontent.com/outbrain/Leonardo/master/leonardo.png\"\n  alt=\"Mocking and testing made simple and consistent. Developed by Outbrain.\"\n/\u003e\n\u003ch1\u003eLeonardo\u003c/h1\u003e\n\u003ch3\u003eClient side mocking for the server side \u003c/h3\u003e\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/outbrain/Leonardo/actions/workflows/tests.yml\"\n    \u003e\u003cimg\n      src=\"https://github.com/outbrain/Leonardo/actions/workflows/tests.yml/badge.svg\"\n      alt=\"travis-ci workflow status\"\n  /\u003e\u003c/a\u003e\n  \u003ca href=\"http://badge.fury.io/js/leonardojs\"\n    \u003e\u003cimg\n      src=\"https://badge.fury.io/js/leonardojs.svg\"\n      alt=\"NPM version\"\n  /\u003e\u003c/a\u003e\n  \u003ca href=\"http://packagequality.com/#?package=leonardojs\"\n    \u003e\u003cimg\n      src=\"http://npm.packagequality.com/shield/leonardojs.svg\"\n      alt=\"Package Quality\"\n  /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\u003c/div\u003e\n\n\n## Install\n\n### npm\n\n```bash\n$ npm install leonardojs --save-dev\n```\n## Example\n\n[Full Application Example](http://outbrain.github.io/Leonardo/examples/angularIL/)\n\n[Video Example - AngularJS Israel Conference (Hebrew)](http://www.youtube.com/watch?v=zPBmMiJZ5O8)\n\n# Getting Started\n\n## 1. Add Leonardo script\n\n### Require in your code\n\n```javascript\n    // in dev environment\n    import 'leonardojs';\n```\n\n### Or directly in html\n```html\n \u003c!DOCTYPE HTML\u003e\n \u003chtml\u003e\n \u003cbody\u003e\n   //.....\n   \u003cscript src=\"[node_modules|other]/leonardo/dist/leonardo.js\"\u003e\u003c/script\u003e\n \u003c/body\u003e\n \u003c/html\u003e\n```\n\n## 2. Run your app\nYou should now see Leonardo's icon on the bottom right corner. Click It.\n\n## 3. Start mocking your http calls via the recorder tab \n![Mocking and testing made simple and consistent. Developed by Outbrain.](./images/recorder.png)\n\n## 4. Turn your mocking on and off as you wish\n![Mocking and testing made simple and consistent. Developed by Outbrain.](./images/scenario.png)\n\n## 5. Change your responses as you wish\n![Mocking and testing made simple and consistent. Developed by Outbrain.](./images/responses.png)\n\n## Javascript API\nAutomate your mocks using Leonardo's API\n\n**State**:\n- name: (string) State name, must be unique\n- url: (string) request url, treated as regex\n- verb: (string) request http verb\n- options (StateOption array)\n\n**StateOption**:\n- name: (string) option name\n- status: (number) http status code\n- data: (primitive | Object | Function) the data to be returned in response body. \n    - Use function to dynamically control the response (first parameter is the request object).\n\n\n### Add States\n`addState(State array)`\n```javascript\n //.....\n    Leonardo.addStates([\n        {\n          name: 'Get Data',\n          url: '/api/user/43435',\n          verb: 'GET',\n          options: [\n            {name: 'success', status: 200, data: { name: \"Master Splinter\" }},\n            {name: 'error 500', status: 500}\n          ]\n        },{\n          name: 'Get Data',\n          url: '/api/user/43435',\n          verb: 'GET',\n          options: [\n            {name: 'success', status: 200, data: { name: \"Master Splinter\" }},\n            {name: 'error 500', status: 500}\n          ]\n        },\n        {\n          name: 'Get Characters',\n          url: '/api/character',\n          verb: 'GET',\n          options: [\n            {\n              name: 'success', \n              status: 200,\n              data: function(request) {\n                if (request.url.indexOf('term=Donatello') \u003e 0) {\n                  return { name: \"Donatello\" };\n                } else {\n                  return { name: \"Raphael\" };                  \n                }\n              }\n            },\n          ]\n        }\n  ]);\n```\n\n### Activate State Option\n`activateStateOption(stateName, optionName)`\n\nActivates state option, mocked response will be returned when calling the state url\n\n```javascript\n//.....\n    Leonardo.activateStateOption('Update Data', 'success');\n    $http.put('/api/user/43435', { name: \"Master Splinter\" }).success(function(data, status) {\n        console.log(status); // 200 \n    });\n    \n    Leonardo.activateStateOption('Update Data', 'error 500');\n    $http.put('/api/user/43435', { name: \"Master Splinter\" }).error(function(data, status) {\n        console.log(status); // 500 \n    });\n//.....\n```\n\n### Deactivate State\n`deactivateState(stateName)`\n\nDeactivates a specific state, when calling the state url request will pass through to the server\n\n```javascript\n//.....\n    Leonardo.deactivateState('Update Data');\n//.....\n```\n\n### Hide/Show Leonardo icon\nYou can hide Leonardo activator icon by clicking `ctrl` + `shift` + `l`.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foutbrain-inc%2FLeonardo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foutbrain-inc%2FLeonardo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foutbrain-inc%2FLeonardo/lists"}