Skip to content
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
1 change: 1 addition & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ type DiffOptions = {
expand?: boolean
colors?: boolean
contextLines?: number
stablePatchmarks?: boolean
aAnnotation?: string
bAnnotation?: string
}
Expand Down
7 changes: 4 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ const prettyFormat = require('pretty-format');
const { ReactElement } = prettyFormat.plugins;
const reactElement = Symbol.for('react.element');

type Options = {
type Options = {|
expand?: boolean,
colors?: boolean,
contextLines?: number,
stablePatchmarks?: boolean,
aAnnotation?: string,
bAnnotation?: string,
};
|};

const defaultOptions = {
expand: false,
Expand All @@ -30,7 +31,7 @@ const SNAPSHOT_TITLE = 'Snapshot Diff:\n';

const snapshotDiff = (valueA: any, valueB: any, options?: Options): string => {
let difference;
const mergedOptions = Object.assign({}, defaultOptions, options);
const mergedOptions = { ...defaultOptions, ...options };

if (isReactComponent(valueA) && isReactComponent(valueB)) {
difference = diffReactComponents(valueA, valueB, mergedOptions);
Expand Down