{"id":13472349,"url":"https://github.com/JamesMessinger/postman-bdd","last_synced_at":"2025-03-26T15:32:02.931Z","repository":{"id":51795507,"uuid":"50974646","full_name":"JamesMessinger/postman-bdd","owner":"JamesMessinger","description":"A BDD test framework for Postman and Newman","archived":true,"fork":false,"pushed_at":"2018-07-26T11:31:31.000Z","size":6523,"stargazers_count":140,"open_issues_count":4,"forks_count":29,"subscribers_count":15,"default_branch":"master","last_synced_at":"2024-10-30T04:13:44.282Z","etag":null,"topics":["api","assertions","bdd","chai","javascript","newman","postman","rest","testing"],"latest_commit_sha":null,"homepage":"http://www.getpostman.com","language":"HTML","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/JamesMessinger.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2016-02-03T04:47:02.000Z","updated_at":"2024-05-19T13:03:13.000Z","dependencies_parsed_at":"2022-08-17T15:05:26.111Z","dependency_job_id":null,"html_url":"https://github.com/JamesMessinger/postman-bdd","commit_stats":null,"previous_names":["bigstickcarpet/postman-bdd"],"tags_count":31,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JamesMessinger%2Fpostman-bdd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JamesMessinger%2Fpostman-bdd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JamesMessinger%2Fpostman-bdd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JamesMessinger%2Fpostman-bdd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JamesMessinger","download_url":"https://codeload.github.com/JamesMessinger/postman-bdd/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245681427,"owners_count":20655192,"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":["api","assertions","bdd","chai","javascript","newman","postman","rest","testing"],"created_at":"2024-07-31T16:00:53.969Z","updated_at":"2025-03-26T15:32:01.308Z","avatar_url":"https://github.com/JamesMessinger.png","language":"HTML","funding_links":[],"categories":["HTML"],"sub_categories":[],"readme":"![Postman BDD](docs/logo.gif)\n\n✨ Postman now has it's own BDD test syntax ✨\n--------------------------\nPostman-BDD is no longer necessary, because Postman now has its own BDD and fluent syntax built-in!\n\nI recommend that you start using Postman's new test syntax instead of Postman-BDD.  However, if you want to continue using Postman-BDD, then you can find the [original ReadMe here](OLD_README.md).\n\n### Docs\n* [Test Scripts](https://www.getpostman.com/docs/v5/postman/scripts/test_scripts)\n* [Test Examples](https://www.getpostman.com/docs/v5/postman/scripts/test_examples)\n\n### Example\n```javascript\n// example using pm.response.to.have\npm.test(\"response is ok\", () =\u003e {\n    pm.response.to.have.status(200);\n});\n\n// example using pm.expect()\npm.test(\"environment to be production\", () =\u003e {\n    pm.expect(pm.environment.get(\"env\")).to.equal(\"production\");\n});\n\n// example using response assertions\npm.test(\"response should be okay to process\", () =\u003e {\n    pm.response.to.not.be.error;\n    pm.response.to.have.jsonBody(\"\");\n    pm.response.to.not.have.jsonBody(\"error\");\n});\n\n// example using pm.response.to.be*\npm.test(\"response must be valid and have a body\", () =\u003e {\n     // assert that the status code is 200\n     pm.response.to.be.ok; // info, success, redirection, clientError,  serverError, are other variants\n     // assert that the response has a valid JSON body\n     pm.response.to.be.withBody;\n     pm.response.to.be.json; // this assertion also checks if a body  exists, so the above check is not needed\n});\n```\n\n### Migration Guide\nPostman's new BDD and fluent syntax are a bit different from Postman-BDD.  Here are the changes you need to make to migrate your tests:\n\n#### Remove `describe` blocks\n`describe()` blocks were optional in Postman-BDD, and they don't exist at all in Postman's new syntax.  So just remove them.\n\n#### Replace `it` blocks with `pm.test`\nPostman-BDD used `it` blocks to define tests, such as:\n\n```javascript\nit('should return the correct customer', () =\u003e {\n  // assertions here\n});\n```\n\nPostman now has `pm.test` blocks, which work the same way.  For example:\n\n```javascript\npm.test('returns the correct customer', () =\u003e {\n  // assertions here\n});\n```\n\n#### Move hooks to folder/collection scripts\nPostman-BDD allowed you to define common assertions or setup/teardown logic in hooks, such as `before()`, `after()`, `beforeEach()` and `afterEach()`.  This is no longer necessary because Postman now allows you to [define test scripts for folders and collections](https://www.getpostman.com/docs/v6/postman/scripts/test_scripts#adding-a-test-script-to-a-collection-or-folder).\n\n#### Different assertion syntax\nPostman-BDD used the [Chai.js](http://www.chaijs.com/api/bdd/) and [Chai-HTTP](http://www.chaijs.com/plugins/chai-http/#assertions) assertion libraries, which let you write assertions using an intuitive, fluent, English-like syntax.\n\n```javascript\nit('should return a 200 response', () =\u003e {\n  response.should.have.status(200);\n});\n\nit('should set the Location header', () =\u003e {\n  response.should.have.header('Location');\n});\n\nit('should return a JSON response', () =\u003e {\n  response.should.be.json;\n});\n\nit('should return the correct customer', () =\u003e {\n  response.body.should.have.property('id', 12345);\n});\n```\n\nPostman now supports its own fluent assertion syntax, which is somewhat similar.\n\n```javascript\npm.test('returns a 200 response', () =\u003e {\n  pm.response.to.have.status(200);\n});\n\npm.test('sets the Location header', () =\u003e {\n  pm.response.to.have.header(\"Location\");\n});\n\npm.test('returns a JSON response', () =\u003e {\n  pm.response.to.be.json;\n});\n\npm.test('returns the correct customer', () =\u003e {\n  let jsonData = pm.response.json();\n  pm.expect(jsonData.id).to.eql(12345);\n});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJamesMessinger%2Fpostman-bdd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FJamesMessinger%2Fpostman-bdd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJamesMessinger%2Fpostman-bdd/lists"}