File tree 6 files changed +33
-41
lines changed
6 files changed +33
-41
lines changed Original file line number Diff line number Diff line change
1
+ {
2
+ "presets" : [" next/babel" ]
3
+ }
Original file line number Diff line number Diff line change
1
+ exports [` With Snapshot Testing App shows "Hello world!" 1` ] = `
2
+ <div >
3
+ <p >
4
+ Hello World!
5
+ </p >
6
+ </div >
7
+ ` ;
Original file line number Diff line number Diff line change 1
- /* global it, expect */
1
+ /* global it, expect, describe */
2
+
2
3
import React from 'react'
3
4
import { shallow } from 'enzyme'
5
+ import renderer from 'react-test-renderer'
4
6
import App from '../pages/index.js'
5
7
6
- it ( 'App shows "Hello world!"' , ( ) => {
7
- const app = shallow (
8
- < App />
9
- )
8
+ describe ( 'With Enzyme' , ( ) => {
9
+ it ( 'App shows "Hello world!"' , ( ) => {
10
+ const app = shallow (
11
+ < App />
12
+ )
13
+
14
+ expect ( app . find ( 'p' ) . text ( ) ) . toEqual ( 'Hello World!' )
15
+ } )
16
+ } )
10
17
11
- expect ( app . find ( 'p' ) . text ( ) ) . toEqual ( 'Hello world!' )
18
+ describe ( 'With Snapshot Testing' , ( ) => {
19
+ it ( 'App shows "Hello world!"' , ( ) => {
20
+ const component = renderer . create ( < App /> )
21
+ const tree = component . toJSON ( )
22
+ expect ( tree ) . toMatchSnapshot ( )
23
+ } )
12
24
} )
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " my-app" ,
3
3
"dependencies" : {
4
- "next" : " ^1.0.0"
4
+ "next" : " ^2.0.0-beta" ,
5
+ "react-test-renderer" : " ^15.4.1"
5
6
},
6
7
"scripts" : {
7
8
"test" : " jest" ,
10
11
"start" : " next start"
11
12
},
12
13
"devDependencies" : {
13
- "babel-jest" : " ^16 .0.0" ,
14
+ "babel-jest" : " ^18 .0.0" ,
14
15
"enzyme" : " ^2.5.1" ,
15
- "jest" : " ^16 .0.2 " ,
16
+ "jest-cli " : " ^18 .0.0 " ,
16
17
"react" : " ^15.3.2" ,
17
18
"react-addons-test-utils" : " ^15.3.2" ,
18
19
"react-dom" : " ^15.3.2"
19
- },
20
- "babel" : {
21
- "presets" : [
22
- " es2015" ,
23
- " react"
24
- ]
25
20
}
26
21
}
Original file line number Diff line number Diff line change 1
1
export default ( ) => (
2
2
< div >
3
- < p > Hello world !</ p >
3
+ < p > Hello World !</ p >
4
4
</ div >
5
5
)
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments