This framework is designed to automate API testing for the PetStore application. It integrates popular tools and libraries like Supertest, JEST, Jest HTML Reports, and CI/CD - Github Actions to provide a robust and maintainable testing solution.
- Should have NodeJs installed on machine.
The different test 'packets' are located under packages folder.
In most of the cases the setup would still be the same, something along the following lines to be run within the relevant pack:
nvm usenpm ci(or if adding new dependencies thennpm install)npm run test:pestore- It will generate junit report in xml format at result foldernpm run test:petstore-html-report- It will generate html report at jest_html_reporters.html
- Default reporter will print console log and Test status on console.
- We also added jest html reporter, Once test complete report can be found at
packages/api/jest_html_reporters.html - Open above report in Browser
As an initial example petstore-api.spec.ts can be used.
- For New test cases create new spec
...spec.tsunder petstore folder - If this is something of a bigger nature - create a dedicated folder and put all of the relevant helpers/utils within it
- On the top level there is a
commonsfolder - add common things here - Make sure to run
npm run lint:fixif adding new code - When adding new dependency - make sure to run
npm installand commit all of the changes
The GitHub actions workflow are found in this directory - .github/workflows
- Go to Actions tab - Actions
- From the left, below All workflows select the workflow - PetStore API - E2E
- A
Run workflowdropdown will appear on the right, Select it, then choosebranch - main, and clickRun Workflow. - Refresh Page
- You can now see -
PetStore API - E2Ejob is running, While completes, open Java CI with Maven to monitor the test running status and view logs. - Once the
PetStore API - E2Ejob complete, theReport - PetStore Api Testsjob will start running automatically, wait for it to complete. - Once the
Report - PetStore Api Testsgets completes, double-click on job name. - You can see Status of run in html format