Coder Social home page Coder Social logo

slve / har.test Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 4 KB

API integration test runner and test reporter using .har files

License: MIT License

Shell 100.00%
har test testing-tools test-automation test-runner api-test api-testing integration-testing integration-tests har-files

har.test's Introduction

GitHub code size in bytes

har.test

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

  1. 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.
  2. Run ./main.sh https://yourdomain.here.
  3. Har.test will filter all the requests made to your domain and replays them in the original order.
  4. 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.
  5. 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.
  6. Discover the source code main.sh.
  7. Tip: Don't forget to check out json.test a similar tool for when you don't have .har files.
  8. 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.

Dependencies

  • jq - stedolan.github.io
  • curl - you probably have one already
  • diff - same here
  • awk - again

Limitations that might change in the future

  • har.test is running each .har file in alphabetical order syncronously
  • also, each test cases are processed syncronously
  • there is no HTTP response code checking
  • there is no option for any kind of timing

References and similar or other .har tools

Similar tool without .har

har.test's People

Contributors

slve avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.