Skip to content
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

feat: Attach Screenshots to Reports #239

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
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
29 changes: 29 additions & 0 deletions cypress/plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,35 @@ module.exports = async (on, config) => {
checkFileExists(filePath) {
return fs.existsSync(filePath);
},
downloadAndSaveImage({ imageUrl, fileName, downloadPath }) {
const filePath = path.join(downloadPath, fileName);

return new Promise((resolve, reject) => {
// Create directory if it doesn't exist
fs.mkdir(path.dirname(filePath), { recursive: true }, (err) => {
if (err) {
reject(err);
} else {
fetch(imageUrl)
.then((response) => {
const dest = fs.createWriteStream(filePath, { flags: 'w' });
response.body.pipe(dest);
dest.on('finish', () => {
dest.close(() => {
resolve(true); // Resolve with true on success
});
});
dest.on('error', (err) => {
reject(err);
});
})
.catch((err) => {
reject(err);
});
}
});
});
},
});

on('before:run', async () => {
Expand Down
5 changes: 4 additions & 1 deletion cypress/support/cypress-support/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,10 @@ function checkForSecondaryAppId(appId) {
if (appId === CONSTANTS.SECONDARY_THIRD_PARTY_APP) {
envAppIdKey = CONSTANTS.SECONDARY_THIRD_PARTY_APP_ID;
return getEnvVariable(CONSTANTS.SECONDARY_THIRD_PARTY_APP_ID);
} else if (getEnvVariable(appId) !== null && getEnvVariable(appId) !== undefined) {
} else if (
getEnvVariable(appId, false) !== null &&
getEnvVariable(appId, false) !== undefined
) {
envAppIdKey = appId;
return getEnvVariable(appId);
} else {
Expand Down
Loading