API integration test runner and reporter using .har files
How it works
./main.sh http://your.host
finds queries in all .har files in the folder
which have http://your.host in their target
builds queries and runs them -> saves responses -> compares -> reports -> logs failures
*.har -> ./queries.sh ./responses ./expected ./log
...other.host...
...your.host... curl -XPOST ...1 -d '{..1}' {"a":1} {"a":1} Pass Diff at line: 2. query: curl '...'
...your.host... curl -XPOST ...2 -d '{..2}' {"b":1} {"b":2} Fail Response: { "userId": 1, ... }
...your.host... Expected: { "userId": 2, ... }
...other.host...
compare does sanitization both on ./responses and ./expected using ./sanitize
Intro
Grab your favorite web browser save all the network traffic you have recorded in you current tab; and copy your .har file to this folder.
Run ./main.sh https://yourdomain.here.
Har.test will filter all the requests made to your domain and replays them in the original order.
On the first run har.test will generate the ./expected file based on your .har files; ./expected will be your snapshot but you can edit it; is just simply text.
Discover the jq tutorial and the local ./sanitize file here in the repo, which serves not only as an example but har.test actively uses it.
Tip: Don't forget to check out json.test a similar tool for when you don't have .har files.
Give it a star and fork it, create your private clone, add your .gitignore to your needs and link it into your CI flow.
Output
The output will go to stdout so you could pipe it into a file for example, but there is a more detailed ./log file. Also, the exit code can be 0 if all test passed, or 1 if any of the tests have failed, so is compatible with the standard CI tools.
Goal
The original goal was to create an easy setup integration test runner and reporter using .har file.
Advantages
Small set of dependencies: some common GNU commands plus jq,
~100 lines of shell script - lightweight codebase,
and so its easy to fork and hack it to your own needs.
You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.
We use optional third-party analytics cookies to understand how you use GitHub.com so we can build better products.
Learn more.
We use optional third-party analytics cookies to understand how you use GitHub.com so we can build better products.
You can always update your selection by clicking Cookie Preferences at the bottom of the page.
For more information, see our Privacy Statement.
Essential cookies
We use essential cookies to perform essential website functions, e.g. they're used to log you in.
Learn more
Always active
Analytics cookies
We use analytics cookies to understand how you use our websites so we can make them better, e.g. they're used to gather information about the pages you visit and how many clicks you need to accomplish a task.
Learn more