You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+48-5Lines changed: 48 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,10 +2,6 @@
2
2
3
3
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.
4
4
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
-
9
5
###Install
10
6
11
7
`npm install legit-tests --save`
@@ -14,6 +10,9 @@ In 0.4.0 there is a breaking change where `this.component` is now the component
14
10
15
11
~~~js
16
12
importTestfrom'legit-tests'
13
+
//or
14
+
importTestfrom'legit-tests/no-dom'//don't include jsdom
15
+
17
16
import { expect } from'chai'
18
17
importsinonfrom'sinon'
19
18
importTestComponentfrom'./TestComponent'
@@ -51,6 +50,9 @@ You can write middleware to do anything you repeatedly use. You can pass `.use`
51
50
-`helpers` - an array you can add on to with data for the end function
52
51
53
52
**Example**:
53
+
54
+
- See `mixin` below, this syntax may soon be deprecated
55
+
54
56
This is the setState function used above.
55
57
~~~js
56
58
@@ -69,12 +71,53 @@ export default function setState(state){
69
71
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:
70
72
71
73
~~~js
72
-
.test(({helpers, component}) => { ... })
74
+
.test(({helpers, instance}) => { ... })
73
75
.test(function() {
74
76
//this.instance, this.helpers
75
77
})
76
78
~~~
77
79
80
+
##element
81
+
82
+
Use `.element` if you're just testing an element you found with the `.find` method. The syntax is a little smaller:
0 commit comments