Skip to content

create support file on init command & bump version to next major version #183

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions commands/default_custom_support_file.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const addContext = require('mochawesome/addContext')

// NOTE: import this file in cypress/support/e2e.js
Cypress.on('test:after:run', (test, runnable) => {
if (test.state === 'failed') {
let item = runnable
const nameParts = [runnable.title]

// Iterate through all parents and grab the titles
while (item.parent) {
nameParts.unshift(item.parent.title)
item = item.parent
}

if(runnable.hookName) {
nameParts.push(`${runnable.hookName} hook`)
}
const fullTestName = nameParts
.filter(Boolean)
.join(' -- ') // this is how cypress joins the test title fragments

const imageUrl = `${fullTestName} (failed).png`

addContext({ test }, imageUrl)


}
})
16 changes: 14 additions & 2 deletions commands/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,21 @@ function create_base_reporter_config_file(args) {
}
};

function create_custom_support_file(args){
const pathToFile = path.join(__dirname, "default_custom_support_file.js");
const pathToNewDestination = constants.LT_BASE_CUSTOM_SUPPORT_FILE_NAME;
fs.copyFile(pathToFile, pathToNewDestination, (err) => {
if (err) {
console.log("Error while copying custom support file", err);
}
else {
console.log("Successfully saved custom support file at - ", pathToNewDestination);
}
});
}

module.exports = function (args) {

create_ltconfig_file(args);
create_base_reporter_config_file(args);

create_custom_support_file(args);
};
1 change: 1 addition & 0 deletions commands/utils/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module.exports = {
CLI: "/cy/versions",
LT_CONFIG_NAME: "lambdatest-config.json",
LT_BASE_REPORTER_CONFIG_FILE_NAME: "base_reporter_config.json",
LT_BASE_CUSTOM_SUPPORT_FILE_NAME: "custom_support_file.js",
CYPRESS_CONFIG_NAME: "cypress.json",
DEFAULT_TEST_PATH: ".",
LAMBDA_CONFIG: "./lambdatest-config.json",
Expand Down
Loading