File tree 3 files changed +73
-0
lines changed 3 files changed +73
-0
lines changed Original file line number Diff line number Diff line change
1
+ /* global page */
2
+
3
+ const port = process . env . PORT || '8080' ;
4
+ jest . setTimeout ( 15 * 1000 ) ;
5
+
6
+ const sleep = ms => new Promise ( r => setTimeout ( r , ms ) ) ;
7
+
8
+ // this test is not very stable because of timer
9
+ describe ( '13_saga' , ( ) => {
10
+ it ( 'should work with recorded events' , async ( ) => {
11
+ await page . goto ( `http://localhost:${ port } /` ) ;
12
+
13
+ await page . waitForSelector ( 'body > #app > div > div:nth-child(3) > button' ) ;
14
+ await page . click ( 'body > #app > div > div:nth-child(3) > button' ) ;
15
+ expect ( await page . evaluate ( ( ) => document . body . innerHTML ) ) . toMatchSnapshot ( ) ;
16
+
17
+ await sleep ( 3000 ) ;
18
+ expect ( await page . evaluate ( ( ) => document . body . innerHTML ) ) . toMatchSnapshot ( ) ;
19
+
20
+ await page . waitForSelector ( 'body > #app > div > div:nth-child(4) > button:nth-child(2)' ) ;
21
+ await page . click ( 'body > #app > div > div:nth-child(4) > button:nth-child(2)' ) ;
22
+ expect ( await page . evaluate ( ( ) => document . body . innerHTML ) ) . toMatchSnapshot ( ) ;
23
+
24
+ await page . waitForSelector ( 'body > #app > div > div > button:nth-child(3)' ) ;
25
+ await page . click ( 'body > #app > div > div > button:nth-child(3)' ) ;
26
+ expect ( await page . evaluate ( ( ) => document . body . innerHTML ) ) . toMatchSnapshot ( ) ;
27
+
28
+ await sleep ( 1000 ) ;
29
+ expect ( await page . evaluate ( ( ) => document . body . innerHTML ) ) . toMatchSnapshot ( ) ;
30
+ } ) ;
31
+ } ) ;
Original file line number Diff line number Diff line change
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports [` 13_saga should work with recorded events 1` ] = `
4
+ "
5
+ <div id =\\"app\\"><div><h1>Person</h1><div>User ID:<input value =\\"3\\"></div><span>connecting...</span><div><h1>Counter</h1>Count: 0<button type =\\"button\\">+1</button><button type =\\"button\\">-1 (Delayed)</button></div></div></div>
6
+ <script type =\\"text/javascript\\" src =\\"main.js\\"></script>
7
+
8
+ "
9
+ `;
10
+
11
+ exports[`13_saga should work with recorded events 2`] = `
12
+ "
13
+ <div id =\\"app\\"><div><h1>Person</h1><div>User ID:<input value =\\"3\\"></div><div>First Name: Emma<button type =\\"button\\">Fetch User</button><button type =\\"button\\">Clear</button></div><div><h1>Counter</h1>Count: 0<button type =\\"button\\">+1</button><button type =\\"button\\">-1 (Delayed)</button></div></div></div>
14
+ <script type =\\"text/javascript\\" src =\\"main.js\\"></script>
15
+
16
+ "
17
+ `;
18
+
19
+ exports[`13_saga should work with recorded events 3`] = `
20
+ "
21
+ <div id =\\"app\\"><div><h1>Person</h1><div>User ID:<input value =\\"3\\"></div><div>First Name: Emma<button type =\\"button\\">Fetch User</button><button type =\\"button\\">Clear</button></div><div><h1>Counter</h1>Count: 1<button type =\\"button\\">+1</button><button type =\\"button\\">-1 (Delayed)</button></div></div></div>
22
+ <script type =\\"text/javascript\\" src =\\"main.js\\"></script>
23
+
24
+ "
25
+ `;
26
+
27
+ exports[`13_saga should work with recorded events 4`] = `
28
+ "
29
+ <div id =\\"app\\"><div><h1>Person</h1><div>User ID:<input value =\\"3\\"></div><div>First Name: Emma<button type =\\"button\\">Fetch User</button><button type =\\"button\\">Clear</button></div><div><h1>Counter</h1>Count: 1<button type =\\"button\\">+1</button><button type =\\"button\\">-1 (Delayed)</button></div></div></div>
30
+ <script type =\\"text/javascript\\" src =\\"main.js\\"></script>
31
+
32
+ "
33
+ `;
34
+
35
+ exports[`13_saga should work with recorded events 5`] = `
36
+ "
37
+ <div id =\\"app\\"><div><h1>Person</h1><div>User ID:<input value =\\"3\\"></div><div>First Name: Emma<button type =\\"button\\">Fetch User</button><button type =\\"button\\">Clear</button></div><div><h1>Counter</h1>Count: 0<button type =\\"button\\">+1</button><button type =\\"button\\">-1 (Delayed)</button></div></div></div>
38
+ <script type =\\"text/javascript\\" src =\\"main.js\\"></script>
39
+
40
+ "
41
+ `;
Original file line number Diff line number Diff line change 33
33
"e2e-test:10_untracked" : " server-test examples:10_untracked 8080 'jest --preset jest-puppeteer __tests__/e2e/10_untracked.js'" ,
34
34
"e2e-test:11_form" : " server-test examples:11_form 8080 'jest --preset jest-puppeteer __tests__/e2e/11_form.js'" ,
35
35
"e2e-test:12_async" : " server-test examples:12_async 8080 'jest --preset jest-puppeteer __tests__/e2e/12_async.js'" ,
36
+ "e2e-test:13_saga" : " server-test examples:13_saga 8080 'jest --preset jest-puppeteer __tests__/e2e/13_saga.js'" ,
36
37
"examples:01_minimal" : " DIR=01_minimal EXT=js webpack-dev-server" ,
37
38
"examples:02_typescript" : " DIR=02_typescript webpack-dev-server" ,
38
39
"examples:03_usestate" : " DIR=03_usestate webpack-dev-server" ,
You can’t perform that action at this time.
0 commit comments