Skip to content

Commit 838a447

Browse files
committed
updated readme for 0.4.2
1 parent 10a7381 commit 838a447

1 file changed

Lines changed: 21 additions & 5 deletions

File tree

README.md

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22

33
This is a super friendly testing library for React, inspired by express middleware, it's easily extendable. Why did I make this when you can use [React's Test Utils](https://facebook.github.io/react/docs/test-utils.html)? Because who likes typing out `scryRenderedDOMComponentsWithTag` and the other method names on there. Not only that, but setting up the render process is also a hassle.
44

5-
###0.4.0
6-
7-
In 0.4.0 there is a breaking change where `this.component` is now the component itself and the rendered instance is `this.instance`. This makes much more sense but sadly means tests need to be changed in order to update to the latest version.
8-
95
###Install
106

117
`npm install legit-tests --save`
@@ -69,10 +65,30 @@ export default function setState(state){
6965
The `.test` function will be given the component instance and the helpers array. You can use a regular function to reference `this` or an arrow function:
7066

7167
~~~js
72-
.test(({helpers, component}) => { ... })
68+
.test(({helpers, instance}) => { ... })
7369
.test(function() {
7470
//this.instance, this.helpers
7571
})
7672
~~~
7773

74+
##element
75+
76+
Use `.element` if you're just testing an element you found with the `.find` method. The syntax is a little smaller:
77+
78+
~~~js
79+
Test(<TestComponent/>)
80+
.find('.box')
81+
.element(box => {
82+
expect(box.props.children).to.be.equal('found me!')
83+
})
84+
//or specify the element
85+
86+
.find('.box')
87+
.find('div')
88+
.element('box', box => {
89+
expect(box.props.children).to.be.equal('found me!')
90+
})
91+
92+
~~~
93+
7894
You can see more examples in the tests directory.

0 commit comments

Comments
 (0)