Skip to content

Commit

Permalink
[fix] not rename screenshots if allure disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleksandr Shevtsov committed Apr 14, 2020
1 parent 0f81206 commit 7ff767a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 11 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [1.4.1] - 2020-04-14

### Fixed

- not rename screenshots if allure is disabled

## [1.4.0] - 2020-04-14

### Changed
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@shelex/cypress-allure-plugin",
"version": "1.4.0",
"version": "1.4.1",
"description": "allure reporting plugin for cypress",
"main": "reporter/index.js",
"types": "reporter/index.d.ts",
Expand Down
25 changes: 15 additions & 10 deletions writer.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,22 @@ module.exports = function (on) {
}
});
on('after:screenshot', (details) => {
const resultsDir = `allure-results`;
!fs.existsSync(resultsDir) && fs.mkdirSync(resultsDir);
const allurePath = path.join(resultsDir, `${uuid.v4()}-attachment.png`);
return new Promise((resolve, reject) => {
fs.copyFile(details.path, allurePath, (err) => {
if (err) {
return reject(err);
}
resolve({ path: allurePath });
if (Cypress.env('allure') === true) {
const resultsDir = `allure-results`;
!fs.existsSync(resultsDir) && fs.mkdirSync(resultsDir);
const allurePath = path.join(
resultsDir,
`${uuid.v4()}-attachment.png`
);
return new Promise((resolve, reject) => {
fs.copyFile(details.path, allurePath, (err) => {
if (err) {
return reject(err);
}
resolve({ path: allurePath });
});
});
});
}
});
};

Expand Down

0 comments on commit 7ff767a

Please sign in to comment.