Prerequisite:
- Need to have
node.js
(version "^v17.8.0")- Rancher desktop (can be downloaded from rancher website)
- docker (if on mac run
brew install docker
) - docker compose (if on mac run
brew install docker-compose
)
installed on the local machine
Setup:
- Run '
npm install
' command
API key:
- Register with https://openweathermap.org/stations website and get the API key
Setting up environment variables:
- Rename '.env.example' file to '.env'
- Update API_KEY value in '.env' file
Using linting utility:
- Run '
npm run lint
' command to run eslint
Starting wiremock:
- run
npm run start:mock:server
to start the wiremock (should be able to see wiremock test data on wiremock mappping page url) OR - Download wiremock standalone JAR from here
- start the wiremock in standalone mode using '
java -jar wiremock-standalone-<version>.jar --port 9000
'
Stopping wiremock:
- run
npm run stop:mock:server
to stop the wiremock
Running tests:
- Run '
npm run test:mock
' command to run all the tests against mock - Run '
npm run test:prod
' command to run all the tests against prod - Run
npm run generate:report
command to open html report of the test execution results
Test execution report:
- Test execution report can be found in './mochawesome-report'
-
Test framework:
- Jest
-
Reporting framework:
- Jest html reporters
-
HTTP client:
-
CI:
- Travis CI
-
Mock:
- Wiremock docker image
-
Linting Utility:
- ESLint (extends typescript recommened rules. Details can be found here)
-
Pre-Commit hook:
- pre-commit npm package to run linting utility before commit
Error: If getting error.code: ECONNREFUSED
error when running tests against mock then
- update the base url with ip instead of localhost in test-data.json file
"baseUrl": "http://<ip-of-the-machine>:9000/",
for more details refer to following stackoverflow pages
- Get api working in Postman but not with Axios and
- Can't send HTTP requests to Localhost Backend from React Native Mobile App
If you have any feedback or question, please email me at kapil.sethi9+github@gmail.com