Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
output.forEach(({ isAsset, name, code }) => {
if(isAsset) {
return;
}
chunks.set(name, `\n${code}`);
});
const out = Object.create(null);
// Ensure out object is in a consistent order
[ ...chunks.keys() ].sort().forEach((key) => {
out[key] = chunks.get(key);
});
return toMatchSnapshot.call(
this,
out,
);
},
});
output.forEach(({ isAsset, fileName, source }) => {
if(!isAsset) {
return;
}
assets.set(fileName, `\n${source}`);
});
const out = Object.create(null);
// Ensure out object is in a consistent order
[ ...assets.keys() ].sort().forEach((key) => {
out[key] = assets.get(key);
});
return toMatchSnapshot.call(
this,
out,
);
},
});
toMatchRollupSnapshot({ output }, name = "") {
const things = new Map();
output.forEach(({ code, isAsset, fileName, source }) => {
// Leading newline to make diffs easier to read
things.set(fileName, `\n${isAsset ? source : code}`);
});
const out = Object.create(null);
// Ensure out object is in a consistent order
[ ...things.keys() ].sort().forEach((key) => {
out[key] = things.get(key);
});
return toMatchSnapshot.call(
this,
out,
name,
);
},
});
function toMatchStyledComponentsSnapshot(received) {
const result = toMatchSnapshot.call(this, received)
let message
if (!result.pass) {
message = diff(result.expected, result.actual, {
aAnnotation: 'Snapshot',
bAnnotation: 'Received',
})
message = stripAnsi(message)
message = colorize(message)
}
return { pass: result.pass, message }
}