1+ const puppeteer = require ( 'puppeteer' ) ;
2+
3+ let browser ;
4+ let page ;
5+
6+ beforeAll ( async ( ) => {
7+ browser = await puppeteer . launch ( ) ;
8+ page = await browser . newPage ( ) ;
9+ await page . goto ( 'http://localhost:5000/full-stack-lifecycle' ) ;
10+ } ) ;
11+
12+ describe ( 'FullStackLifecycle' , ( ) => {
13+
14+ test ( 'prepare should run' , async ( ) => {
15+ await page . waitForSelector ( '[data-prepared]' ) ;
16+ const element = await page . $ ( '[data-prepared]' ) ;
17+ expect ( element ) . toBeTruthy ( ) ;
18+ } ) ;
19+
20+ test ( 'initiate should run' , async ( ) => {
21+ await page . waitForSelector ( '[data-initiated]' ) ;
22+ const element = await page . $ ( '[data-initiated]' ) ;
23+ expect ( element ) . toBeTruthy ( ) ;
24+ } ) ;
25+
26+ test ( 'hydrate should run' , async ( ) => {
27+ await page . waitForSelector ( '[data-hydrated]' ) ;
28+ const element = await page . $ ( '[data-hydrated]' ) ;
29+ expect ( element ) . toBeTruthy ( ) ;
30+ } ) ;
31+
32+ test ( 'update should run' , async ( ) => {
33+ await page . waitForSelector ( '[data-updated]' ) ;
34+ const element = await page . $ ( '[data-updated]' ) ;
35+ expect ( element ) . toBeTruthy ( ) ;
36+ } ) ;
37+
38+ test ( 'terminate should run' , async ( ) => {
39+ await page . click ( 'a[href="/"]' ) ;
40+ await page . waitForFunction ( ( ) => location . search == '?terminated=true' ) ;
41+ const element = await page . $ ( '.FullStackLifecycle' ) ;
42+ expect ( element ) . toBeFalsy ( ) ;
43+ } ) ;
44+
45+ } ) ;
46+
47+ afterAll ( async ( ) => {
48+ browser . close ( ) ;
49+ } ) ;
0 commit comments