Skip to content

Commit 3d461a9

Browse files
authored
Merge pull request #188 from asad9711/CYP-402
update validations for reporter config file
2 parents 9fa3826 + 7a282c8 commit 3d461a9

File tree

5 files changed

+31
-12
lines changed

5 files changed

+31
-12
lines changed

commands/default_custom_support_file.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
const addContext = require('mochawesome/addContext')
22

33
// NOTE: import this file in cypress/support/e2e.js
4+
// import '../../custom_support_file';
5+
// require('../../custom_support_file');
6+
47
Cypress.on('test:after:run', (test, runnable) => {
58
if (test.state === 'failed') {
69
let item = runnable
@@ -20,9 +23,6 @@ Cypress.on('test:after:run', (test, runnable) => {
2023
.join(' -- ') // this is how cypress joins the test title fragments
2124

2225
const imageUrl = `${fullTestName} (failed).png`
23-
2426
addContext({ test }, imageUrl)
25-
26-
2727
}
2828
})

commands/utils/archive.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ function archive_batch(lt_config, batch) {
233233
} else if (!lt_config["run_settings"]["cypress_config_file"]) {
234234
archive.append("{}", { name: constants.CYPRESS_CONFIG_NAME });
235235
}
236-
if (lt_config["run_settings"]["reporter_config_file"]) {
236+
if (lt_config["run_settings"]["reporter_config_file"] && lt_config["run_settings"]["reporter_config_file"] !="") {
237237
if (fs.existsSync(lt_config["run_settings"]["reporter_config_file"])) {
238238
let rawdata = fs.readFileSync(
239239
lt_config["run_settings"]["reporter_config_file"]
@@ -244,9 +244,16 @@ function archive_batch(lt_config, batch) {
244244
),
245245
});
246246
} else {
247-
reject(
248-
"Provided reporter config file not found. Please check the provided the value of reporter_config_file in lambdatest-config.json"
249-
);
247+
// case 1: reporter_config_file param is missing
248+
// case 2: reporter_config_file = ""
249+
// case 3: reporter_config_file = <non existing file>
250+
// this shouldn't reject, instead just show a warning
251+
252+
253+
// This warning is not required, since we are already checking for the existence of file while validate()
254+
// console.log(
255+
// "Warning!! Provided reporter config file not found. Please check the provided value of reporter_config_file in lambdatest-config.json"
256+
// );
250257
}
251258
}
252259

commands/utils/default_config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ module.exports = {
2020
reporter_config_file: "base_reporter_config.json",
2121
build_name: "build-name",
2222
parallels: 1,
23-
specs: "./*.spec.js",
23+
specs: "<path_of_cypress_spec_files>",
2424
ignore_files: "",
2525
network: false,
2626
headless: false,

commands/utils/set_args.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,13 @@ function sync_args_from_cmd(args) {
224224

225225
// if reporter_config_file parameter, add it in lt config alongwith a warning on console
226226
if (!lt_config["run_settings"]["reporter_config_file"]) {
227+
228+
/* cypress 9 user
229+
case 1: new user (may or may not run init) ->
230+
case 2: old existing user (may or may not run init) ->
231+
*/
232+
233+
227234
console.log("Warning !! Value of reporter_config_file parameter missing. Proceeding with default reporter config");
228235
lt_config["run_settings"]["reporter_config_file"] = constants.LT_BASE_REPORTER_CONFIG_FILE_NAME;
229236
}

commands/utils/validate.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,16 +217,21 @@ module.exports = validate_config = function (lt_config, validation_configs) {
217217
if (!("project" in lt_config.run_settings.smart_ui)) {
218218
reject("Smart UI project name is missing");
219219
} else if (lt_config.run_settings.smart_ui.project == "") {
220-
reject("Smart UI porject name can not be blank");
220+
reject("Smart UI project name can not be blank");
221221
}
222222
}
223223
if (
224224
lt_config["run_settings"]["reporter_config_file"] &&
225225
lt_config["run_settings"]["reporter_config_file"] != ""
226226
) {
227+
// console.log("reporter_config_file present");
227228
if (!fs.existsSync(lt_config["run_settings"]["reporter_config_file"])) {
228-
reject(
229-
"Error!! Reporter Config File does not exist, Pass a valid path"
229+
230+
231+
// case 1: cypress 9 user ->
232+
// case 2: cypress >=10 user -> simply show warning that user may not get command logs section
233+
console.log(
234+
"Warning!! Reporter Config File does not exist, Commands section on dashboard may not get generated. Use lambdatest-cypress init command to generate."
230235
);
231236
} else {
232237
let rawdata = fs.readFileSync(
@@ -251,7 +256,7 @@ module.exports = validate_config = function (lt_config, validation_configs) {
251256
}
252257
}
253258
}else{
254-
console.log("Warning !! Value of reporter_config_file parameter missing. Proceeding with default reporter config")
259+
console.log("Warning!! Value of reporter_config_file parameter missing. Proceeding with default reporter config")
255260
}
256261

257262
if (

0 commit comments

Comments
 (0)