{"id":26328472,"url":"https://github.com/luanphandinh/pits","last_synced_at":"2025-03-15T21:17:02.469Z","repository":{"id":57324942,"uuid":"234347987","full_name":"luanphandinh/pits","owner":"luanphandinh","description":"postman integration test utils","archived":false,"fork":false,"pushed_at":"2020-01-27T15:49:25.000Z","size":85,"stargazers_count":0,"open_issues_count":3,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-15T04:03:47.916Z","etag":null,"topics":["integration-testing","postman","postman-collection","postman-test"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/luanphandinh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-01-16T15:16:44.000Z","updated_at":"2020-01-27T15:49:24.000Z","dependencies_parsed_at":"2022-09-06T06:40:57.333Z","dependency_job_id":null,"html_url":"https://github.com/luanphandinh/pits","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luanphandinh%2Fpits","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luanphandinh%2Fpits/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luanphandinh%2Fpits/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luanphandinh%2Fpits/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/luanphandinh","download_url":"https://codeload.github.com/luanphandinh/pits/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243782337,"owners_count":20347243,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["integration-testing","postman","postman-collection","postman-test"],"created_at":"2025-03-15T21:17:01.823Z","updated_at":"2025-03-15T21:17:02.420Z","avatar_url":"https://github.com/luanphandinh.png","language":"JavaScript","readme":"# pit\nA [postman](https://www.getpostman.com) integration test utils.\\\nTaking advantage of postman's `pre-request script` and `test-script`.\\\nThis utils help `describe and test` your collection with simple syntax.\n\n# Caution\nSince postman doesn't have clear `\"scopes\"` like javascript variables, instead have their own [pm.variables](https://learning.getpostman.com/docs/postman/variables-and-environments/variables/).\\\nIn order to make scripts work, there will be a few `eval()` functions in `lib/t.js`, feel free and inspect the code.\\\nIt's only `eval()` what you code, so please make sure you don't add any danger or malicious script into `describe, test or before` code blocks.\n\n# Install\n```\nnpm i pits\n```\n\n# Project structure ([more on example](https://github.com/luanphandinh/pits/tree/master/example))\n```\nsrc\n  |__GitHubApi\n  |     |__GetUserSuite.js\n  |     |__OtherSuite.js\n  |__googleSuite.js\n  |__spotifySuite.js\n  |\n  |__.pit_collection.js\n  |__package.json\n```\n\n# Suite declaration\n\n`.pit_collection.js`\n```javascript\nconst path = require(\"path\");\n\nmodule.exports = {\n  name: \"Example Fun Postman\",\n  suites: {\n    includes: [\"Suite.js\"], // patterns for `suite` file, could be anything.\n    dirs: [path.join(__dirname)] // paths where `suite` file should be placed.\n  }\n};\n```\n\nDefine your simple script like\n[example/googleSuite.js](https://github.com/luanphandinh/pits/blob/master/example/googleSuite.js)\n```javascript\nconst { describe, before, test } = require(\"pits\");\n\nmodule.exports = describe(\"Let's check google\", () =\u003e {\n  before(\"200\", () =\u003e {\n    console.log(\"This will be called before sending request\");\n    console.log(\"{{request_url}} is hard_code, will be more dynamic later\");\n    pm.variables.set(\"request_url\", \"https://google.com\");\n  });\n\n  test(\"200\", \"Test 200 description\", () =\u003e {\n    pm.response.to.have.status(200);\n  });\n\n  before(\"404\", () =\u003e {\n    console.log(\"This should call when init\");\n    pm.variables.set(\"request_url\", \"https://google.com/404\");\n  });\n\n  test(\"404\", \"Test 404\", () =\u003e {\n    pm.response.to.have.status(404);\n  });\n});\n```\n\n# Run\n```\nnode -e 'require(\"pits\").extract()'\n```\nThis `extract()` function will use the config from `.pit_collection.js` file to generate `.postman_collection.json` into current folder.\n\nIf you have [newman](https://www.npmjs.com/package/newman) installed:\n```\nnewman run test.postman_collection.json\n```\n\n# [Flow diagram](https://www.draw.io/?lightbox=1\u0026highlight=0000ff\u0026edit=_blank\u0026layers=1\u0026nav=1\u0026title=pit.svg#Uhttps%3A%2F%2Fdrive.google.com%2Fuc%3Fid%3D1LAMukZHOzEI1DuxBVMTw8yL-L2ArNVDI%26export%3Ddownload)\n# ![diagram](https://github.com/luanphandinh/pit/blob/master/flow.svg)\n\n# TODO\n* Adding variables file.\n* Improve `pit_collection.json`.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluanphandinh%2Fpits","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fluanphandinh%2Fpits","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluanphandinh%2Fpits/lists"}