comparadise-utils 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -37,12 +37,16 @@ function matchScreenshot(subject, args) {
37
37
  const testPath = Cypress.spec.relative;
38
38
  const lastSlashIndex = testPath.lastIndexOf('/');
39
39
  const testPathWithoutFileName = testPath.substring(0, lastSlashIndex);
40
- const screenshotPath = `${screenshotsFolder}/${testPathWithoutFileName}/${rawName}`;
40
+ const testFileName = testPath.substring(lastSlashIndex + 1);
41
+ const testFileNameWithoutExtension = testFileName.split('.')[0];
42
+ const testName = rawName || testFileNameWithoutExtension;
43
+ const screenshotPath = `${screenshotsFolder}/${testPathWithoutFileName}/${testName}`;
41
44
  cy.task('baseExists', screenshotPath).then(hasBase => {
42
45
  if (typeof hasBase !== 'boolean')
43
46
  throw new Error('Result of baseExists task was not a boolean.');
44
47
  const target = subject ? cy.wrap(subject) : cy;
45
- target.screenshot(`${testPathWithoutFileName}/${rawName}/new`, { ...options, overwrite: true });
48
+ // Cypress prepends the configured screenshotsFolder automatically here, so we must omit it
49
+ target.screenshot(`${testPathWithoutFileName}/${testName}/new`, { ...options, overwrite: true });
46
50
  if (!hasBase) {
47
51
  cy.task('log', `❌ A new base image was created at ${screenshotPath}. Add this as a new base image via Comparadise!`);
48
52
  return;
package/package.json CHANGED
@@ -29,5 +29,5 @@
29
29
  "build": "tsc",
30
30
  "postbuild": "echo \"require('./dist/match-screenshot');\" > commands.js"
31
31
  },
32
- "version": "0.0.4"
32
+ "version": "0.0.5"
33
33
  }