@@ -6,50 +6,52 @@ const mkdirp = require('mkdirp')
6
6
const _ = require ( 'lodash' )
7
7
const { setWorldConstructor } = require ( 'cucumber' )
8
8
9
- function World ( ) {
10
- this . proxy = require ( './proxy' )
11
- this . template = _ . template ( `process.env.CHROME_BIN = require('puppeteer').executablePath(); module.exports = function (config) {\n config.set(\n <%= content %>\n );\n};` )
9
+ class World {
10
+ constructor ( ) {
11
+ this . proxy = require ( './proxy' )
12
+ this . template = _ . template ( `process.env.CHROME_BIN = require('puppeteer').executablePath(); module.exports = function (config) {\n config.set(\n <%= content %>\n );\n};` )
12
13
13
- this . configFile = {
14
- singleRun : true ,
15
- reporters : [ 'dots' ] ,
16
- frameworks : [ 'jasmine' ] ,
17
- basePath : __dirname ,
18
- colors : false ,
19
- __dirname : __dirname ,
20
- _resolve : function ( name ) {
21
- return path . resolve ( __dirname , '..' , 'support' , name )
14
+ this . configFile = {
15
+ singleRun : true ,
16
+ reporters : [ 'dots' ] ,
17
+ frameworks : [ 'jasmine' ] ,
18
+ basePath : __dirname ,
19
+ colors : false ,
20
+ __dirname : __dirname ,
21
+ _resolve : ( name ) => path . resolve ( __dirname , '..' , 'support' , name )
22
+ }
23
+
24
+ this . lastRun = {
25
+ error : null ,
26
+ stdout : '' ,
27
+ stderr : ''
22
28
}
23
29
}
24
30
25
- this . addConfigContent = ( function ( _this ) {
26
- return function ( content ) {
27
- if ( content == null ) {
28
- content = ''
29
- }
30
- return vm . runInNewContext ( content , _this . configFile )
31
+ addConfigContent ( content ) {
32
+ if ( content == null ) {
33
+ content = ''
31
34
}
32
- } ) ( this )
35
+ return vm . runInNewContext ( content , this . configFile )
36
+ }
33
37
34
- this . writeConfigFile = ( function ( _this ) {
35
- return function ( dir , file , done ) {
36
- return mkdirp ( dir , 0x1ed , function ( err ) {
37
- let content , hash
38
- if ( err ) {
39
- return done ( err )
40
- }
38
+ writeConfigFile ( dir , file , done ) {
39
+ return mkdirp ( dir , 0x1ed , ( err ) => {
40
+ let content , hash
41
+ if ( err ) {
42
+ return done ( err )
43
+ }
41
44
42
- delete _this . configFile . __dirname
43
- content = _this . generateJS ( _this . configFile )
44
- hash = hasher ( 'md5' ) . update ( content + Math . random ( ) ) . digest ( 'hex' )
45
- fs . writeFile ( path . join ( dir , hash + '.' + file ) , content , function ( err ) {
46
- done ( err , hash )
47
- } )
45
+ delete this . configFile . __dirname
46
+ content = this . generateJS ( this . configFile )
47
+ hash = hasher ( 'md5' ) . update ( content + Math . random ( ) ) . digest ( 'hex' )
48
+ fs . writeFile ( path . join ( dir , hash + '.' + file ) , content , ( err ) => {
49
+ done ( err , hash )
48
50
} )
49
- }
50
- } ) ( this )
51
+ } )
52
+ }
51
53
52
- this . generateJS = function ( config ) {
54
+ generateJS ( config ) {
53
55
return this . template ( {
54
56
content : JSON . stringify ( Object . assign ( { } , config , {
55
57
customLaunchers : Object . assign ( {
@@ -58,12 +60,6 @@ function World () {
58
60
} ) )
59
61
} )
60
62
}
61
-
62
- this . lastRun = {
63
- error : null ,
64
- stdout : '' ,
65
- stderr : ''
66
- }
67
63
}
68
64
69
65
setWorldConstructor ( World )
0 commit comments