Skip to content

Commit

Permalink
copy images to screenshots folders to upload in test results
Browse files Browse the repository at this point in the history
  • Loading branch information
dc-pm committed Mar 4, 2021
1 parent a2d733a commit 4826b7d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/utils/tasks/imageSnapshots.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,21 @@ const { merge } = require('lodash');
const rimraf = require('rimraf').sync;
const getSnapshotFilename = require('../image/getSnapshotFilename');
const getImageData = require('../image/getImageData');
const { IMAGE_TYPE_ACTUAL } = require('../../constants');
const { IMAGE_TYPE_ACTUAL, IMAGE_TYPE_DIFF } = require('../../constants');
const { DEFAULT_IMAGE_CONFIG } = require('../../config');

function moveActualImageToSnapshotsDirectory({image, snapshotTitle, testFile} = {}) {
if (image && image.path) {
const filename = getSnapshotFilename(testFile, snapshotTitle, IMAGE_TYPE_ACTUAL);
rimraf(filename);
if (fs.existsSync(image.path)) {
fs.moveSync(image.path, filename);
fs.copyFileSync(image.path, filename);
}
if (fs.existsSync(getSnapshotFilename(testFile, snapshotTitle, IMAGE_TYPE_DIFF))) {
fs.copyFileSync(getSnapshotFilename(testFile, snapshotTitle, IMAGE_TYPE_DIFF), `${image.path}.diff.png`);
}
if (fs.existsSync(getSnapshotFilename(testFile, snapshotTitle))) {
fs.copyFileSync(getSnapshotFilename(testFile, snapshotTitle), `${image.path}.spec.png`);
}
image.path = filename;
}
Expand Down

0 comments on commit 4826b7d

Please sign in to comment.