-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtesting.txt
46 lines (39 loc) · 1.27 KB
/
testing.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
Unit testing:
Assert that one piece of your app is working the way you expect.
Integration testing:
Make sure that multiple 'units' work together correctly.
flow:
start react and express apps
->
run 'npm run test'
->
start Jest test suite
->
|=>Boot up a 'headless' version of Chromium
r|->
e|Programmatically instruc Chromium to visit 'localhost:3000'
p|->
e|Programmatically instruc Chromium to click elements on the screen
a|->
t|=>Make assertion about content on screen
puppeteer:
repeat:
-launch Chromium
-navigate to app
-click on stuff on screen
-use a DOM selector to retrieve the content of an element
-write assertion to make sure content is correct
possible solution for moving login functionality by patching Puppeteer's Page class
//------login.js:
const Page = require('puppeteer'/lig/Page);
...
Page.prototype.login = async function() {
const user = await userFactory();
const { session, sig } = sessionFactory(user);
await this.setCookie({ name: 'session', value: session });
await this.setCookie({ name: 'session.sig', value: sig });
await this.goto('localhost:3000'); // need to reload the page to "activate" the cookies
await this.waitFor('a[href="/auth/logout"]'); // need to tell puppeteer to wait for the given element appears on screen
...
}
//-------end