Skip to content

Commit c2c67ce

Browse files
authored
Merge pull request #183 from asad9711/MLE-10219
create support file on init command & bump version to next major version
2 parents f9962f5 + e984cd7 commit c2c67ce

File tree

5 files changed

+1466
-28
lines changed

5 files changed

+1466
-28
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
const addContext = require('mochawesome/addContext')
2+
3+
// NOTE: import this file in cypress/support/e2e.js
4+
Cypress.on('test:after:run', (test, runnable) => {
5+
if (test.state === 'failed') {
6+
let item = runnable
7+
const nameParts = [runnable.title]
8+
9+
// Iterate through all parents and grab the titles
10+
while (item.parent) {
11+
nameParts.unshift(item.parent.title)
12+
item = item.parent
13+
}
14+
15+
if(runnable.hookName) {
16+
nameParts.push(`${runnable.hookName} hook`)
17+
}
18+
const fullTestName = nameParts
19+
.filter(Boolean)
20+
.join(' -- ') // this is how cypress joins the test title fragments
21+
22+
const imageUrl = `${fullTestName} (failed).png`
23+
24+
addContext({ test }, imageUrl)
25+
26+
27+
}
28+
})

commands/init.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,21 @@ function create_base_reporter_config_file(args) {
5151
}
5252
};
5353

54+
function create_custom_support_file(args){
55+
const pathToFile = path.join(__dirname, "default_custom_support_file.js");
56+
const pathToNewDestination = constants.LT_BASE_CUSTOM_SUPPORT_FILE_NAME;
57+
fs.copyFile(pathToFile, pathToNewDestination, (err) => {
58+
if (err) {
59+
console.log("Error while copying custom support file", err);
60+
}
61+
else {
62+
console.log("Successfully saved custom support file at - ", pathToNewDestination);
63+
}
64+
});
65+
}
66+
5467
module.exports = function (args) {
55-
5668
create_ltconfig_file(args);
5769
create_base_reporter_config_file(args);
58-
70+
create_custom_support_file(args);
5971
};

commands/utils/constants.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ module.exports = {
66
CLI: "/cy/versions",
77
LT_CONFIG_NAME: "lambdatest-config.json",
88
LT_BASE_REPORTER_CONFIG_FILE_NAME: "base_reporter_config.json",
9+
LT_BASE_CUSTOM_SUPPORT_FILE_NAME: "custom_support_file.js",
910
CYPRESS_CONFIG_NAME: "cypress.json",
1011
DEFAULT_TEST_PATH: ".",
1112
LAMBDA_CONFIG: "./lambdatest-config.json",

0 commit comments

Comments
 (0)