Skip to content

Commit

Permalink
fix(diff-snapshot): make recievedDir optional (#306)
Browse files Browse the repository at this point in the history
fixes #300
  • Loading branch information
10xLaCroixDrinker committed Aug 25, 2022
1 parent 63dc4b5 commit cd4fa73
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 12 deletions.
4 changes: 2 additions & 2 deletions __tests__/__snapshots__/index.spec.js.snap
Expand Up @@ -43,11 +43,11 @@ Object {
"blur": 0,
"comparisonMethod": "pixelmatch",
"customDiffConfig": Object {},
"diffDir": "path/to/__image_snapshots__/__diff_output__",
"diffDir": undefined,
"diffDirection": "horizontal",
"failureThreshold": 0,
"failureThresholdType": "pixel",
"receivedDir": "path/to/__image_snapshots__/__received_output__",
"receivedDir": undefined,
"receivedImageBuffer": "pretendthisisanimagebuffer",
"snapshotIdentifier": "test-spec-js-test-1",
"snapshotsDir": "path/to/__image_snapshots__",
Expand Down
1 change: 0 additions & 1 deletion __tests__/diff-snapshot.spec.js
Expand Up @@ -458,7 +458,6 @@ describe('diff-snapshot', () => {
receivedImageBuffer: mockImageBuffer,
snapshotIdentifier: mockSnapshotIdentifier,
snapshotsDir: mockSnapshotsDir,
receivedDir: mockReceivedDir,
diffDir: mockDiffDir,
updateSnapshot: false,
failureThreshold: 0,
Expand Down
6 changes: 1 addition & 5 deletions __tests__/index.spec.js
Expand Up @@ -250,9 +250,7 @@ describe('toMatchImageSnapshot', () => {

const dataArg = runDiffImageToSnapshot.mock.calls[0][0];
// This is to make the test work on windows
['snapshotsDir', 'diffDir'].forEach((key) => {
dataArg[key] = dataArg[key].replace(/\\/g, '/');
});
dataArg.snapshotsDir = dataArg.snapshotsDir.replace(/\\/g, '/');

expect(dataArg).toMatchSnapshot();
});
Expand Down Expand Up @@ -448,11 +446,9 @@ describe('toMatchImageSnapshot', () => {
blur: 0,
comparisonMethod: 'pixelmatch',
customDiffConfig: {},
diffDir: 'path/to/__image_snapshots__/__diff_output__',
diffDirection: 'horizontal',
failureThreshold: 0,
failureThresholdType: 'pixel',
receivedDir: 'path/to/__image_snapshots__/__received_output__',
receivedImageBuffer: undefined,
snapshotIdentifier: 'test-spec-js-test-1-1',
snapshotsDir: 'path/to/__image_snapshots__',
Expand Down
4 changes: 2 additions & 2 deletions src/diff-snapshot.js
Expand Up @@ -190,8 +190,8 @@ function diffImageToSnapshot(options) {
snapshotIdentifier,
snapshotsDir,
storeReceivedOnFailure,
receivedDir,
diffDir,
receivedDir = path.join(options.snapshotsDir, '__received_output__'),
diffDir = path.join(options.snapshotsDir, '__diff_output__'),
diffDirection,
updateSnapshot = false,
updatePassedSnapshot = false,
Expand Down
4 changes: 2 additions & 2 deletions src/index.js
Expand Up @@ -193,8 +193,8 @@ function configureToMatchImageSnapshot({
});

const snapshotsDir = customSnapshotsDir || path.join(path.dirname(testPath), SNAPSHOTS_DIR);
const receivedDir = customReceivedDir || path.join(snapshotsDir, '__received_output__');
const diffDir = customDiffDir || path.join(snapshotsDir, '__diff_output__');
const receivedDir = customReceivedDir;
const diffDir = customDiffDir;
const baselineSnapshotPath = path.join(snapshotsDir, `${snapshotIdentifier}-snap.png`);
OutdatedSnapshotReporter.markTouchedFile(baselineSnapshotPath);

Expand Down

0 comments on commit cd4fa73

Please sign in to comment.