Skip to content

Commit

Permalink
fix: only replace specName in cypress run mode, fixes #54
Browse files Browse the repository at this point in the history
  • Loading branch information
oxdev03 authored and simonsmith committed May 6, 2024
1 parent 3bb65e7 commit fab282d
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,24 @@ const runImageDiffAfterScreenshot = async (
} = options

let snapshotName = path.basename(screenshotConfig.path, PNG_EXT)
const dirName = path.dirname(
screenshotConfig.path
// remove the screenshots path and just leave folders to be created in
// the snapshots folder
.replace(path.normalize(screenshotConfig.specName), '')
// remove specName here because in run mode it's added and duplicated.
// In open mode it's an empty string so is ignored
.replace(screenshotsFolder, ''),
)

let cleanedScreenshotPath = screenshotConfig.path

// In open mode it's an empty string so its skipped.
if (screenshotConfig.specName) {
// remove specName here because in run mode it's added and duplicated.
cleanedScreenshotPath = cleanedScreenshotPath.replace(
path.normalize(screenshotConfig.specName),
'',
)
}

// remove the screenshots path and just leave folders to be created in
// the snapshots folder
cleanedScreenshotPath = cleanedScreenshotPath.replace(screenshotsFolder, '')

const dirName = path.dirname(cleanedScreenshotPath)

snapshotName = path
.join(dirName, snapshotName)
.replace(/ \(attempt [0-9]+\)/, '')
Expand Down

0 comments on commit fab282d

Please sign in to comment.