File tree Expand file tree Collapse file tree 6 files changed +92
-3
lines changed Expand file tree Collapse file tree 6 files changed +92
-3
lines changed Original file line number Diff line number Diff line change 4
4
npm-debug.log
5
5
.logs
6
6
logs
7
- * .swp
7
+ * .sw *
8
8
run
9
9
* -run
10
10
.idea
@@ -19,4 +19,6 @@ assets-with-umi/config/manifest.json
19
19
.umi
20
20
.umi-production
21
21
dist
22
+ screenshots
23
+ reports
22
24
.history
Original file line number Diff line number Diff line change 6
6
},
7
7
"devDependencies" : {
8
8
"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"
10
12
},
11
13
"scripts" : {
12
14
"dev" : " egg-bin dev" ,
13
15
"test" : " egg-bin test" ,
16
+ "test:ui" : " macaca run -d ./uitest --reporter macaca-reporter" ,
14
17
"cov" : " egg-bin cov"
15
18
},
16
19
"private" : true
Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
2
3
-
4
3
const mm = require ( 'egg-mock' ) ;
5
4
6
5
describe ( '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