{"action":"created","issue":{"url":"https://api.github.com/repos/chaijs/chai/issues/443","labels_url":"https://api.github.com/repos/chaijs/chai/issues/443/labels{/name}","comments_url":"https://api.github.com/repos/chaijs/chai/issues/443/comments","events_url":"https://api.github.com/repos/chaijs/chai/issues/443/events","html_url":"https://github.com/chaijs/chai/issues/443","id":75369939,"number":443,"title":"chained property tests fail","user":{"login":"cappslock","id":2079125,"avatar_url":"https://avatars.githubusercontent.com/u/2079125?v=3","gravatar_id":"","url":"https://api.github.com/users/cappslock","html_url":"https://github.com/cappslock","followers_url":"https://api.github.com/users/cappslock/followers","following_url":"https://api.github.com/users/cappslock/following{/other_user}","gists_url":"https://api.github.com/users/cappslock/gists{/gist_id}","starred_url":"https://api.github.com/users/cappslock/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cappslock/subscriptions","organizations_url":"https://api.github.com/users/cappslock/orgs","repos_url":"https://api.github.com/users/cappslock/repos","events_url":"https://api.github.com/users/cappslock/events{/privacy}","received_events_url":"https://api.github.com/users/cappslock/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-05-11T21:46:55Z","updated_at":"2015-05-12T21:45:02Z","closed_at":"2015-05-12T21:45:02Z","body":"If I do this:\r\n```js\r\nvar expect = require('chai').expect;\r\n\r\nvar dogs = {\r\n    cat: 'a',\r\n    rat: 'b'\r\n};\r\n\r\nexpect(dogs).to.be.an('object')\r\n    .and.have.property('cat')\r\n    .and.have.property('rat');\r\n```\r\nThis happens:\r\n```\r\nAssertionError: expected 'a' to have a property 'rat'\r\n```"},"comment":{"url":"https://api.github.com/repos/chaijs/chai/issues/comments/101430635","html_url":"https://github.com/chaijs/chai/issues/443#issuecomment-101430635","issue_url":"https://api.github.com/repos/chaijs/chai/issues/443","id":101430635,"user":{"login":"keithamus","id":118266,"avatar_url":"https://avatars.githubusercontent.com/u/118266?v=3","gravatar_id":"","url":"https://api.github.com/users/keithamus","html_url":"https://github.com/keithamus","followers_url":"https://api.github.com/users/keithamus/followers","following_url":"https://api.github.com/users/keithamus/following{/other_user}","gists_url":"https://api.github.com/users/keithamus/gists{/gist_id}","starred_url":"https://api.github.com/users/keithamus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/keithamus/subscriptions","organizations_url":"https://api.github.com/users/keithamus/orgs","repos_url":"https://api.github.com/users/keithamus/repos","events_url":"https://api.github.com/users/keithamus/events{/privacy}","received_events_url":"https://api.github.com/users/keithamus/received_events","type":"User","site_admin":false},"created_at":"2015-05-12T21:45:02Z","updated_at":"2015-05-12T21:45:02Z","body":"Hi @cappslock thanks for the issue.\r\n\r\n`.property()` changes the subject of the assertion, so you can make additional assertions on the property - [as described by the documentation](http://chaijs.com/api/bdd/#-property-name-value-); to quote:\r\n\r\n> Furthermore, property changes the subject of the assertion to be the value of that property from the original object. This permits for further chainable assertions on that property.\r\n\r\n>  ```js\r\nexpect(obj).to.have.property('foo')\r\n  .that.is.a('string');\r\nexpect(deepObj).to.have.property('green')\r\n  .that.is.an('object')\r\n  .that.deep.equals({ tea: 'matcha' });\r\nexpect(deepObj).to.have.property('teas')\r\n  .that.is.an('array')\r\n  .with.deep.property('[2]')\r\n    .that.deep.equals({ tea: 'konacha' });\r\n  ```\r\n\r\nSo this is expected behaviour. You want to have the following instead:\r\n\r\n```js\r\nvar expect = require('chai').expect;\r\n\r\nvar dogs = {\r\n    cat: 'a',\r\n    rat: 'b'\r\n};\r\n\r\nexpect(dogs).to.be.an('object')\r\n    .and.have.property('cat');\r\nexpect(dogs)\r\n    .and.have.property('rat');\r\n\r\n//alternatively:\r\n\r\nexpect(dogs).to.be.an('object');\r\n    .and.include.keys('cat', 'rat');\r\n```\r\n\r\nI'm going to close this issue - but let me know if your problem isn't resolved and we'll re-open it and discuss it more. Otherwise feel free to file a new issue."}}