{"id":15680608,"url":"https://github.com/serhatbolsu/api-test-javascript-jest-boilerplate","last_synced_at":"2025-05-07T10:35:41.888Z","repository":{"id":42272239,"uuid":"218220573","full_name":"serhatbolsu/api-test-javascript-jest-boilerplate","owner":"serhatbolsu","description":"Restful API Test Automation Sample - Boilerplate - ATDD - Resource Objects - Jest - Superagent - Express - Allure","archived":false,"fork":false,"pushed_at":"2023-01-24T02:29:55.000Z","size":934,"stargazers_count":14,"open_issues_count":12,"forks_count":7,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-19T21:24:33.052Z","etag":null,"topics":["api-testing","api-testing-framework","javascript-tests","rest-api","restful-api","test","test-automation","testing-tools"],"latest_commit_sha":null,"homepage":"","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/serhatbolsu.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":null}},"created_at":"2019-10-29T06:40:15.000Z","updated_at":"2025-02-08T06:08:52.000Z","dependencies_parsed_at":"2023-02-13T12:16:15.474Z","dependency_job_id":null,"html_url":"https://github.com/serhatbolsu/api-test-javascript-jest-boilerplate","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serhatbolsu%2Fapi-test-javascript-jest-boilerplate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serhatbolsu%2Fapi-test-javascript-jest-boilerplate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serhatbolsu%2Fapi-test-javascript-jest-boilerplate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serhatbolsu%2Fapi-test-javascript-jest-boilerplate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/serhatbolsu","download_url":"https://codeload.github.com/serhatbolsu/api-test-javascript-jest-boilerplate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252860486,"owners_count":21815523,"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","javascript-tests","rest-api","restful-api","test","test-automation","testing-tools"],"created_at":"2024-10-03T16:43:23.503Z","updated_at":"2025-05-07T10:35:41.848Z","avatar_url":"https://github.com/serhatbolsu.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![CircleCI](https://circleci.com/gh/serhatbolsu/api-test-javascript-jest-boilerplate.svg?style=svg)](https://circleci.com/gh/serhatbolsu/api-test-javascript-jest-boilerplate)\n# API Testing Sample Framework with Javascript\nRestful API testing sample framework. ATDD is the suggested design pattern with the help of resouce-objects.\n\n\u003e Jest is chosen since it is sharing the same `expect` library with webdriverio. \n\u003e It is much faster then mocha due to inherent parallelization. \n\n\n## Overview\n\nIn this framework, you will find test suites for included restful api \"Vegetable\" service. \nYou will find three suites that are representing different design choices\n- Test suite using super agent.\n- Test suite using base api which represent DSL of 'Vegetable' application.\n- Test suite using Resource Objects, explained below.\n- Test suite for data import from file.\n\nYou can copy this library and use as you like, however think about the design choices you are changing.\n\n| Technology | Description | \n| ---------- | ----------- |\n| Acceptance Test Driven Development | ATDD involves team members with different perspectives (customer, development, testing) collaborating to write acceptance cases. |\n| Resource Objects | Design pattern like Page Object, represent each endpoint as resource | \n| Code as commit | Everything about test automation should be committed, including CI | \n\n| Tools | Description |\n| --- | --- |\n| superagent | Request is a library for making HTTP requests. This will be used for making the HTTP requests in the tests |\n| jest | Jest is a test executor that is running async. It includes assertion library. |\n| eslint | Static code analysis tool for Javascript |\n| husky | Regulate code commit (with linter in this case) |\n| express | Express is popular HTTP framework for NodeJS which will be used for creating the System Under Test. |\n| allure | Reporting tool, neat html report |\n\n## Setup\nFirst need to create your own configurations.\n\nCopy the sample.env and rename to `.env`\n- change required variables\n\n```npm install```\n\nIn case you want to run against sample api *Vegetables*, \nrun the server with\n\n```npm start```\n\n\n## Test Suites and Example usage\nThese are example usages of library. From 1 to 3 abstraction of endpoints increases.\n\n#### 1- basic.spec.js\nDirectly using superagent to make http requests.\nThere are no helpers. Verification done with jest expect.\n\n#### 2- basic_resource.spec.js\nUses a BaseAPi.js object as a wrapper around superagent.\n\n**Benefit:**\n\n- Wrap around common request parameters\n- Can implement authentication at this level.\n- BaseURL is directly parsed from config\n- Can implement retry\n- superagent chain pattern can still be used\n\n#### 3-base_api_resource.spec.js\nUses resource object, this is a similar method used in selenium with **page Objects**\n\n- Vegetable(endpoint resource) is converted to an object upon retrieval\n- in `vegetable.resource.js` you can write various methods with regards to this specific endpoint.\n- re-usability increased with common vegetable endpoint functions.\n- usage of superagent/requests encapsulated, however still usable look at tc#3\n- Pre-initialized resource-objects are singleton objects. So single object is shared inside test case.\n\n\n## Familiarizing Yourself with the System Under Test\n\nIt's always necessary to get to know the code you are testing. \nLet us examine the API that we are testing. The purpose of the API is to be an interface with a vegetable database. \nSupports the following operations:\n\n- Adding a vegetable\n- Deleting a vegetable\n- Getting all vegetables\n\nThe API supports adding and deleting individual vegetables. You can also get all vegetables in the database. Here are the API routes:\n\n* GET /vegetables\n    * Description\n        * Get all the vegetables in the database\n    * Query Parameters\n        * upperCase\n            * If set to \"true\" the vegetable's name will be return uppercase\n            * Default is false\n        * optional\n            * If set to \"true\", return will include optional: `origin`\n            * Default is true\n\n* POST /vegetables\n    * Description\n        * Add a vegetable to the database\n\n* DELETE /vegetables/:id\n    * Description\n        * Delete a vegetable from the database\n    * Url Parameters\n        * name\n            * The name of the vegetable to delete \n\n\n## Usage\nRun tests in local\n\n```npm test```\n\nRun individual test suite\n\n```npm test -- test/basic.spec.js```\n\nAllure Report\n(you must have installed [allure command line](https://docs.qameta.io/allure/#_get_started))\n\n```npm run report```\n\nPost report to Microsoft Teams channel\n```\nexport HOOK_URL=\u003cmicrosoft_web_hook_url\u003e\nnpm run report.teams\n\n```\n\n## Contributors\nSpecial thanks to [gsypolt](https://github.com/gsypolt/api-testing-javascript) as he is the owner of vegetable api.\n\nPlease create a pull request.\n\n\n## ToDO\n\n- Jenkinsfile\n- Slack Reporter (looking for help, send a PR if you are interested)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fserhatbolsu%2Fapi-test-javascript-jest-boilerplate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fserhatbolsu%2Fapi-test-javascript-jest-boilerplate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fserhatbolsu%2Fapi-test-javascript-jest-boilerplate/lists"}