Skip to content

Commit 7c125ac

Browse files
committed
add e2e 13
1 parent a9be85b commit 7c125ac

File tree

3 files changed

+73
-0
lines changed

3 files changed

+73
-0
lines changed

__tests__/e2e/13_saga.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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+
});
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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+
`;

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"e2e-test:10_untracked": "server-test examples:10_untracked 8080 'jest --preset jest-puppeteer __tests__/e2e/10_untracked.js'",
3434
"e2e-test:11_form": "server-test examples:11_form 8080 'jest --preset jest-puppeteer __tests__/e2e/11_form.js'",
3535
"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'",
3637
"examples:01_minimal": "DIR=01_minimal EXT=js webpack-dev-server",
3738
"examples:02_typescript": "DIR=02_typescript webpack-dev-server",
3839
"examples:03_usestate": "DIR=03_usestate webpack-dev-server",

0 commit comments

Comments
 (0)