ya-done-api
A BDD based API automation framework based on JAVASCRIPT
npm i ya-done-api --save
The aim of this Package is to help QA teams to automate API's using Javascript. Ya-done-api
comes with predefined method for REST API calls.
How to use the Package for automating- Please follow the below Steps.
There are two structures mentioned below. Sample Projects for both the structures are available for download in GITHUB. (To Skip the Reading 😉)
1. Decide Your Directry Structure: Sample Folder Structure 1
features
├─sampleFeature.js
steps
├─lib
| ├─all-steps.js
├─index.js
index.js
package.json
2. write the feature File
Feature: Sample Feature to Test the package Scenario: Given Get random postcode
3. Write the code for the step
./steps/lib/all-steps.js
;const addContext = ;; { return this ; }
Ya-done-api
framework for execution
4. Extract the code to pass it ./steps/index.js
;; const bootstrap = { return _allSteps;}; ;
5. Pass the requried steps in main index File
./index.js
;; //Set the Framework for stepLevel Execution const framework = stepLevel: true // This is a feture to show the steps wise progess in terminal, completely optional //running the test cases using Yadda;
6. install and run the project 🥳
npm inpm test
If you want to split the Given when then in steps, you can follow the below structure: Structure 2
features
├─sampleFeature.js
steps
├─given
| ├─lib
| | ├─givenSteps.js
| ├─index.js
├─when
| ├─lib
| | ├─whenSteps.js
| ├─index.js
├─then
| ├─lib
| | ├─thenSteps.js
| ├─index.js
├─index.js
index.js
package.json
Adding a dictionary
Dictionaries have been abstracted for simple use in ya-done. Dictionaries allow the use of tables and variables within steps.
how to consume reading scenario count from feature files
In local index.js:
- import the count scenarios function -->
;
- countScenarios(filePath) (Where file path is where your feature files are stored)
we have written most used REST API methods for reuse, please find below the functions available.
- GET
- POST
- PUT
- PATCH
- DELETE
- HEAD
- OPTIONS
- wait
how to consume the common REST API Methods
- import the utils from ya-done
;await utils; //please refer to the step3 for detailed example