enzymejs / enzyme-matchers

Jasmine/Jest assertions for enzyme
MIT License
892 stars 116 forks source link

Fixing messaging for toHaveState and toHaveProp #294

Closed GreenGremlin closed 5 years ago

GreenGremlin commented 5 years ago

I found some copy/paste remnants from toHaveProp in toHaveState, which are causing toHaveState failures to print toHaveProp messaging. This change fixes those messages and also cleans up the messaging for toHaveState and toHaveProp to be more clear and consistent.

Also the current "Expected props/state" messaging offers little value and is misleading for the negated variation, when no expected value is given; so I removed it.

expect(wrapper).toHaveState('error')

Current Messaging

Expected <MyComponent> to have any value for the prop "error"
Actual props: error: undefined
Expected props: error: undefined

Updated Messaging

Expected the state for <MyComponent> to contain a value for key "error", but it did not.
Actual state: error: undefined

expect(wrapper).not.toHaveState('error')

Current Messaging

Expected <MyComponent> not to receive the prop "error"
Actual props: error: 'some-error'
Expected props: error: undefined

Updated Messaging:

Expected the state for <MyComponent> to not contain a value for key "error", but it did.
Actual state: error: 'some-error'
GreenGremlin commented 5 years ago

I've addressed all requested changes, please take another look, when you can.