Skip to content

Commit

Permalink
chore: fix tests, add debug logs
Browse files Browse the repository at this point in the history
  • Loading branch information
Shelex committed Nov 22, 2021
1 parent 741ca7c commit 7733542
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
"semantic-release": "semantic-release",
"test": "yarn cypress run --config integrationFolder=cypress/integration/results,testFiles=**/*.spec.js,video=false",
"test:debug": "yarn cypress open --config integrationFolder=cypress/integration/results,testFiles=**/*.test.js,video=false",
"test:prepare:basic": "node cypress/scripts/runner basic",
"test:prepare:cucumber": "node cypress/scripts/runner cucumber",
"test:prepare:basic": "DEBUG=allure-plugin* node cypress/scripts/runner basic",
"test:prepare:cucumber": "DEBUG=allure-plugin* node cypress/scripts/runner cucumber",
"fixtures:clear": "rm -r cypress/fixtures/*",
"lint": "yarn eslint ."
},
Expand Down
4 changes: 2 additions & 2 deletions writer.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ const { shouldUseAfterSpec } = require('./writer/useAfterSpec');
const { handleCrash } = require('./writer/handleCrash');

function allureWriter(on, config) {
allurePropertiesToEnvVars(config.env);

// pass allure config from Cypress.env to process.env
// to get access from node context
process.env.allure = config.env.allure;

process.env.allureResultsPath =
config.env.allureResultsPath || 'allure-results';

allurePropertiesToEnvVars(config.env);

let allureMapping = null;

if (shouldUseAfterSpec(config)) {
Expand Down
9 changes: 6 additions & 3 deletions writer/attachments.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,17 @@ const attachScreenshotsAndVideo = (allureMapping, results) => {
return;
}

const videoPath = `${uuid.v4()}-attachment${path.extname(results.video)}`;
const videoPath =
results.video &&
`${uuid.v4()}-attachment${path.extname(results.video)}`;

const needVideo = results.tests.filter((test) => {
const allureId = allureMapping[test.testId];
if (!allureId) {
return false;
}

logger.writer('going to attach video to "%s"', allureId);
logger.writer('going to check attachments for "%s"', allureId);

const fileName = `${allureId}-result.json`;

Expand Down Expand Up @@ -71,6 +73,7 @@ const attachScreenshotsAndVideo = (allureMapping, results) => {
});

if (results.video) {
logger.writer('going to attach video for "%s"', allureId);
const existingVideoIndex = allureTest.attachments.findIndex(
(attach) => attach.type === videoContentType
);
Expand All @@ -86,7 +89,7 @@ const attachScreenshotsAndVideo = (allureMapping, results) => {
}

fs.writeFileSync(testFilePath, JSON.stringify(allureTest));
return true;
return results.video;
});

if (needVideo.length) {
Expand Down

0 comments on commit 7733542

Please sign in to comment.