{"id":14989763,"url":"https://github.com/shashikumarraja/api_automation_boilerplate-javascript","last_synced_at":"2025-08-22T22:11:50.812Z","repository":{"id":102400386,"uuid":"137779848","full_name":"shashikumarraja/api_automation_boilerplate-javascript","owner":"shashikumarraja","description":null,"archived":false,"fork":false,"pushed_at":"2020-03-28T12:03:52.000Z","size":15,"stargazers_count":18,"open_issues_count":0,"forks_count":11,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-25T21:03:11.271Z","etag":null,"topics":["api-testing","api-testing-framework","boilerplate","chai","javascript","mocha","test-automation"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shashikumarraja.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":"support/apis/createSuperhero.js","governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-06-18T16:46:43.000Z","updated_at":"2021-05-23T18:16:43.000Z","dependencies_parsed_at":null,"dependency_job_id":"9038feba-02a0-4623-88ff-e1cf23f5be71","html_url":"https://github.com/shashikumarraja/api_automation_boilerplate-javascript","commit_stats":{"total_commits":3,"total_committers":1,"mean_commits":3.0,"dds":0.0,"last_synced_commit":"a2a7ba03542755dd38c5948376a43760290c0387"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shashikumarraja%2Fapi_automation_boilerplate-javascript","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shashikumarraja%2Fapi_automation_boilerplate-javascript/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shashikumarraja%2Fapi_automation_boilerplate-javascript/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shashikumarraja%2Fapi_automation_boilerplate-javascript/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shashikumarraja","download_url":"https://codeload.github.com/shashikumarraja/api_automation_boilerplate-javascript/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248501430,"owners_count":21114674,"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":["api-testing","api-testing-framework","boilerplate","chai","javascript","mocha","test-automation"],"created_at":"2024-09-24T14:18:52.829Z","updated_at":"2025-04-12T00:32:29.354Z","avatar_url":"https://github.com/shashikumarraja.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"API Automation\n====================\n***\n\nProject to create automation tests of APIs with [Mocha](https://mochajs.org/) bringing [BDD](http://en.wikipedia.org/wiki/Behavior-driven_development) to JavaScript.\n\n## Requirements\n\n- Node version 7 or higher\n\nAlthough this project works fine with NPM we recommend to use Yarn (\u003e= 0.20.0) instead,  due to its speed \u0026 solid dependency locking mechanism. To keep things simple we use yarn in this guide, but feel free to replace this with NPM if that is what you are using.\n\n## Quick start\n\nChoose one of the following options:\n\n1. Download the latest stable release or clone the git repo — `git clone repoName`\n\n2. Then:\n- Copy the files to your project into a directory like `/api_automation_boilerplate-javascript`\n\n3. Install the dependencies (`yarn install`) or (`npm install`)\n\nNow you are ready to write your own tests.\n\n# How to write a test\n\nTests are written in [Mocha BDD syntax](https://mochajs.org/)\n\n\n__myFirstTest.js__\n```mocha\ndescribe('My First test', () =\u003e {\n    let app = 'My first test';\n    it('should pass', () =\u003e {\n      app.should.equal('My first test')\n    });\n});\n\n```\n\n# How to run the test\n\nTraverse to the project directory\n\n```sh\n$ cd api_automation_boilerplate-javascript\n```\nOn one tab run faker api(Using the [json-server](https://github.com/typicode/json-server) module we are creating fake api for testing purpose) :\n\n```sh\n$ npm run fakeApi\n```\n\nIn another tab execute the test run using :\n\n```sh\n$ npm test\n```\n\n# Configurations\n\nTo configure your tests, checkout the [`setup.js`] file in your test directory.\n\n## Environment-specific configurations\n\nYou can setup multiple configs for specific environments. Let's say you want to have a different `baseUrl` for\nyour local and pre-deploy tests. Use the `setup` to set all general configs (in mochaOpts) that don't change.\nThey act as default values. For each different environment you can create a new setup with the following name\nscheme:\n\n```txt\nsetup.\u003cENVIRONMENT\u003e.js\n```\nand then accordingly require it in your mocha.opts file using\n```txt\n--require ./test/setup.js\n```\n\n# Running single test\nSometimes its useful to only execute a single test file, to do so use the following command:\n\n```sh\n$ npm test --grep nameOfSuite (nameOfSuite is the name of describe or it block)\n```\n\n# Skip test\n\nIf you have failing or unimplemented tests you can mark them as \"skip\" so they will get skipped.\n\n```javascript\ndescribe.skip();\nit.skip();\n```\n\n# Assertions\n\nTo assert values this project comes with a [Chai](http://chaijs.com/) integration.\n\n# Logger\n\n[Winston](https://github.com/winstonjs/winston) is used as logger in the project. Use the below command to get logs on console while running tests- \n```sh \nlogLevel='debug' npm test\n```\nSupported log levels are-\n```\n{ error: 0, warn: 1, info: 2, verbose: 3, debug: 4, silly: 5 }\n```\nTo use logger, use any of the below format with respective logLevels-\n\n```javascript\n// Default logger\nwinston.log('info', \"127.0.0.1 - there's no place like home\");\nwinston.info(\"127.0.0.1 - there's no place like home\");\n```\nTo use winston's inbuilt logger module(project uses winston directly), make the configuration as -\n``` javascript\nvar winston = require('winston');\nvar logger = new (winston.Logger)({\n  levels: {\n    trace: 9,\n    input: 8,\n    verbose: 7,\n    prompt: 6,\n    debug: 5,\n    info: 4,\n    data: 3,\n    help: 2,\n    warn: 1,\n    error: 0\n  },\n  colors: {\n    trace: 'magenta',\n    input: 'grey',\n    verbose: 'cyan',\n    prompt: 'grey',\n    debug: 'blue',\n    info: 'green',\n    data: 'grey',\n    help: 'cyan',\n    warn: 'yellow',\n    error: 'red'\n  }\n});\n\nlogger.add(winston.transports.Console, {\n  level: 'trace',\n  prettyPrint: true,\n  colorize: true,\n  silent: false,\n  timestamp: false\n});\n\nlogger.add(winston.transports.File, {\n  prettyPrint: false,\n  level: 'info',\n  silent: false,\n  colorize: true,\n  timestamp: true,\n  filename: './nKindler.log',\n  maxsize: 40000,\n  maxFiles: 10,\n  json: false\n});\n```\n\n# Reporter\n\nThe project uses two reporters-\n1. [mocha-allure-reporter](https://github.com/allure-framework/allure-mocha) - It generates report and runs a server to display all the reports.\nTo see the allure report-\n```sh\nnpm run report\n```\n\n2. [spec reporter](https://mochajs.org/#reporters)- It is the default mocha reporter to display report on the terminal.\n\nUse of more than one reporter has been made possible by using [mocha-multi](https://github.com/glenjamin/mocha-multi)\n\n# Api Documentation\nThe project uses [apiDoc](http://apidocjs.com/) to document the Apis. To generate and see the api documentation use-\n```sh\nnpm run generateDocument\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshashikumarraja%2Fapi_automation_boilerplate-javascript","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshashikumarraja%2Fapi_automation_boilerplate-javascript","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshashikumarraja%2Fapi_automation_boilerplate-javascript/lists"}