@@ -8,7 +8,7 @@ const logger = require("../../../../bin/helpers/logger").winstonLogger;
8
8
9
9
const cp = require ( "child_process" ) ;
10
10
const fs = require ( "fs" ) ;
11
- const rewire = require ( "rewire " ) ;
11
+ const utils = require ( "../../../../bin/helpers/utils " ) ;
12
12
const readCypressConfigUtil = require ( "../../../../bin/helpers/readCypressConfigUtil" ) ;
13
13
14
14
logger . transports [ "console.info" ] . silent = true ;
@@ -134,5 +134,27 @@ describe("readCypressConfigUtil", () => {
134
134
135
135
expect ( result ) . to . eql ( { e2e : { } } ) ;
136
136
} ) ;
137
+
138
+ it ( 'should handle error if any error occurred' , ( ) => {
139
+ const bsConfig = {
140
+ run_settings : {
141
+ cypressConfigFilePath : 'path/to/cypress.config.js' ,
142
+ cypress_config_filename : 'cypress.config.js'
143
+ }
144
+ } ;
145
+ sandbox . stub ( readCypressConfigUtil , 'loadJsFile' ) . throws ( new Error ( "Some error" ) ) ;
146
+ const sendUsageReportStub = sandbox . stub ( utils , 'sendUsageReport' ) ;
147
+ sandbox . stub ( cp , 'execSync' ) ;
148
+
149
+ const result = readCypressConfigUtil . readCypressConfigFile ( bsConfig ) ;
150
+
151
+ expect ( result ) . to . eql ( undefined ) ;
152
+ sinon . assert . calledWithExactly ( sendUsageReportStub , {
153
+ run_settings : {
154
+ cypressConfigFilePath : 'path/to/cypress.config.js' ,
155
+ cypress_config_filename : 'cypress.config.js'
156
+ }
157
+ } , null , 'Error while reading cypress config: Some error' , 'warning' , 'cypress_config_file_read_failed' , null , null )
158
+ } ) ;
137
159
} ) ;
138
160
} ) ;
0 commit comments