@falvhb/apitester
v1.0.5
Published
Sleek GET API tests
Readme
Sleek API testing for GET endpoints
Fetch some endpoints, compare results to baseline. Success.
npm i @falvhb/apitesterAdd to package.json
"scripts": {
"test": "BASE_URL=\"http://localhost:8080\" apitester"
},Run tests with
npm testGuide
Put files in baseline folder similar to the API paths you want to test:
A file in
baseline/test/info.jsonwill result in a GET request to
http://localhost:8080/test/infoand compare the results to the local file.
Different baseline folder
Set the BASE_FOLDER env variable, e.g.
"scripts": {
"test": "BASE_FOLDER=tests BASE_URL=\"http://localhost:8080\" apitester"
},Slash handling
You can replace a slash / in the path with *slash*:
baseline/test*slash*info.jsonwill also fetch
http://localhost:8080/test/infoAdding tests shorthand method
Add to package.json
"scripts": {
"add": "REMOVE_PATH=\"/api/content\" apitester add"
},and run it with
npm run add -- http://localhost:4200/api/content/test/content/The REMOVE_PATH variable is totally optional.
