Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(diff-snapshot): make recievedDir optional #306

Merged
merged 1 commit into from
Aug 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions __tests__/__snapshots__/index.spec.js.snap
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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