File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44npm-debug.log
55.logs
66logs
7- * .swp
7+ * .sw *
88run
99* -run
1010.idea
@@ -19,4 +19,6 @@ assets-with-umi/config/manifest.json
1919.umi
2020.umi-production
2121dist
22+ screenshots
23+ reports
2224.history
Original file line number Diff line number Diff line change 66 },
77 "devDependencies" : {
88 "egg-bin" : " ^4.3.5" ,
9- "egg-mock" : " ^3.13.1"
9+ "egg-mock" : " ^3.13.1" ,
10+ "macaca-electron" : " ^1.1.19" ,
11+ "macaca-wd" : " ^1.0.37"
1012 },
1113 "scripts" : {
1214 "dev" : " egg-bin dev" ,
1315 "test" : " egg-bin test" ,
16+ "test:ui" : " macaca run -d ./uitest --reporter macaca-reporter" ,
1417 "cov" : " egg-bin cov"
1518 },
1619 "private" : true
Original file line number Diff line number Diff line change 11'use strict' ;
22
3-
43const mm = require ( 'egg-mock' ) ;
54
65describe ( 'example view-nunjucks test' , ( ) => {
Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+
3+ const wd = require ( 'macaca-wd' ) ;
4+ const {
5+ extendsMixIn,
6+ } = require ( 'macaca-wd/lib/helper' ) ;
7+
8+ extendsMixIn ( wd ) ;
9+
10+ const port = 7001 ;
11+
12+ const BASE_URL = `http://127.0.0.1:${ port } ` ;
13+
14+ wd . addPromiseChainMethod ( 'initWindow' , function ( options = { } ) {
15+ return this
16+ . init ( Object . assign ( {
17+ platformName : 'desktop' ,
18+ browserName : 'electron' ,
19+ deviceScaleFactor : 2 ,
20+ } , options ) )
21+ . setWindowSize ( options . width , options . height ) ;
22+ } ) ;
23+
24+ const driver = wd . promiseChainRemote ( {
25+ host : 'localhost' ,
26+ port : process . env . MACACA_SERVER_PORT || 3456 ,
27+ } ) ;
28+
29+ exports . driver = driver ;
30+ exports . BASE_URL = BASE_URL ;
Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+
3+ const assert = require ( 'assert' ) ;
4+
5+ const {
6+ driver,
7+ BASE_URL ,
8+ } = require ( './helper' ) ;
9+
10+ describe ( 'test/homepage.test.js' , ( ) => {
11+ describe ( 'home page UI testing' , ( ) => {
12+
13+ before ( function ( ) {
14+ this . timeout ( 5 * 1000 ) ;
15+ return driver
16+ . initWindow ( {
17+ width : 800 ,
18+ height : 600 ,
19+ deviceScaleFactor : 2 ,
20+ } ) ;
21+ } ) ;
22+
23+ beforeEach ( ( ) => {
24+ return driver
25+ . getUrl ( `${ BASE_URL } ` ) ;
26+ } ) ;
27+
28+ afterEach ( function ( ) {
29+ return driver
30+ . saveScreenshots ( this ) ;
31+ } ) ;
32+
33+ after ( ( ) => {
34+ return driver
35+ . openReporter ( false )
36+ . quit ( ) ;
37+ } ) ;
38+
39+ it ( 'page render success' , ( ) => {
40+ return driver
41+ . setWindowSize ( 800 , 600 )
42+ . title ( )
43+ . then ( title => {
44+ assert . equal ( title , 'egg view example' ) ;
45+ } )
46+ . source ( )
47+ . then ( html => {
48+ assert . ok ( html . includes ( 'egg view example here, welcome foobar' ) ) ;
49+ } ) ;
50+ } ) ;
51+ } ) ;
52+ } ) ;
Original file line number Diff line number Diff line change 1+ --require babel-register
2+ --recursive
3+ --timeout 60000
You can’t perform that action at this time.
0 commit comments