Utility for generating TypeScript / Mocha application tests from HTTP requests, in order to tests APIs.
This project have been tested only on Gnu/Linux Ubuntu.
With this tool, you can record HTTP activity of your web browser in a json file, then export it as a Typescript source code ready-to-use with Mocha and Chai, two greats tools for tests !
See examples directory !
Installation:
$ git clone ...
$ cd node-proxy-test
$ npm run install-cli
Open a proxy on port 3000 and record HTTP traffic:
$ node-proxy-test record
Open a web browser using this proxy (selected browser should not be opened yet):
$ node-proxy-test launch-chromium
Play with your API, watch logs on terminal, then press CTRL-C once to stop recording and write a JSON
file in recorder
directory.
Generate Mocha Typescript tests:
$ node-proxy-test generate
$ node-proxy-test generate 4
$ node-proxy-test generate /path/to/file.json
Play them:
$ node-proxy-test run
Clean them:
$ node-proxy-test clean-generated
Http requests can be modified by programmatic hooks, before persit them on disk and before test generation. See src/hooks/models for more informations.