New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

jest-snapshot

Package Overview
Dependencies
Maintainers
3
Versions
280
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jest-snapshot - npm Package Compare versions

Comparing version 19.0.2 to 19.1.0-alpha.eed82034

yarn.lock

38

build/index.js

@@ -16,3 +16,2 @@ /**

const diff = require('jest-diff');
const fileExists = require('jest-file-exists');
const fs = require('fs');

@@ -31,2 +30,5 @@ const path = require('path');

const fileExists = (filePath, hasteFS) =>
hasteFS.exists(filePath) || fs.existsSync(filePath);
const cleanup = (hasteFS, update) => {

@@ -36,3 +38,5 @@ const pattern = '\\.' + SNAPSHOT_EXTENSION + '$';

const filesRemoved = files.
filter(snapshotFile => !fileExists(
filter(
snapshotFile =>
!fileExists(
path.resolve(

@@ -45,2 +49,3 @@ path.dirname(snapshotFile),

map(snapshotFile => {

@@ -50,4 +55,3 @@ if (update) {

}
}).
length;
}).length;

@@ -72,5 +76,3 @@ return {

if (isNot) {
throw new Error(
'Jest: `.not` cannot be used with `.toMatchSnapshot()`.');
throw new Error('Jest: `.not` cannot be used with `.toMatchSnapshot()`.');
}

@@ -92,6 +94,3 @@

const actualString = actual.trim();
const diffMessage = diff(
expectedString,
actualString,
{
const diffMessage = diff(expectedString, actualString, {
aAnnotation: 'Snapshot',

@@ -102,15 +101,13 @@ bAnnotation: 'Received',

const report =
() => `${RECEIVED_COLOR('Received value')} does not match ` +
const report = () =>
`${RECEIVED_COLOR('Received value')} does not match ` +
`${EXPECTED_COLOR('stored snapshot ' + count)}.\n\n` + (
diffMessage ||
RECEIVED_COLOR('- ' + expectedString) + '\n' +
RECEIVED_COLOR('- ' + expectedString) +
'\n' +
EXPECTED_COLOR('+ ' + actualString));
const message = () =>
matcherHint('.toMatchSnapshot', 'value', '') + '\n\n' + report();
const message =
() => matcherHint('.toMatchSnapshot', 'value', '') + '\n\n' +
report();
// Passing the the actual and expected objects so that a custom reporter

@@ -152,3 +149,4 @@ // could access them, for example in order to display a custom visual diff,

throw new Error(
matcherHint('.toThrowErrorMatchingSnapshot', '() => {}', '') + '\n\n' +
matcherHint('.toThrowErrorMatchingSnapshot', '() => {}', '') +
'\n\n' +
`Expected the function to throw an error.\n` +

@@ -155,0 +153,0 @@ `But it didn't throw anything.`);

@@ -14,5 +14,8 @@ /**

const ReactTestComponentPlugin = require('pretty-format/build/plugins/ReactTestComponent');
const ImmutablePlugins = require('pretty-format/build/plugins/ImmutablePlugins');
let PLUGINS = [ReactElementPlugin, ReactTestComponentPlugin];
let PLUGINS = [ReactElementPlugin, ReactTestComponentPlugin].concat(
ImmutablePlugins);
// Prepend to list so the last added is the first tested.

@@ -19,0 +22,0 @@ exports.addSerializer = plugin => {

@@ -24,3 +24,2 @@ /**

require('./utils');const saveSnapshotFile = _require.saveSnapshotFile,getSnapshotData = _require.getSnapshotData,getSnapshotPath = _require.getSnapshotPath,keyToTestName = _require.keyToTestName,serialize = _require.serialize,testNameToKey = _require.testNameToKey,unescape = _require.unescape;
const fileExists = require('jest-file-exists');
const fs = require('fs');

@@ -91,3 +90,3 @@

status.saved = true;
} else if (isEmpty && fileExists(this._snapshotPath)) {
} else if (isEmpty && fs.existsSync(this._snapshotPath)) {
if (update) {

@@ -140,3 +139,3 @@ fs.unlinkSync(this._snapshotPath);

if (
!fileExists(this._snapshotPath) || // there's no snapshot file
!fs.existsSync(this._snapshotPath) || // there's no snapshot file
hasSnapshot && this.update || // there is a file, but we're updating

@@ -143,0 +142,0 @@ !hasSnapshot // there is a file, but it doesn't have this snaphsot

@@ -17,3 +17,2 @@ /**

const createDirectory = require('jest-util').createDirectory;
const fileExists = require('jest-file-exists');
const path = require('path');

@@ -46,6 +45,5 @@ const prettyFormat = require('pretty-format');

`${chalk.bold('Outdated snapshot')}: No snapshot header found. ` +
`Jest 19 introduced versioned snapshots to ensure all developers on ` +
`a project are using the same version of Jest. ` +
`Jest 19 introduced versioned snapshots to ensure all developers ` +
`on a project are using the same version of Jest. ` +
`Please update all snapshots during this upgrade of Jest.\n\n`) +
SNAPSHOT_VERSION_WARNING);

@@ -75,6 +73,5 @@

`snapshot file indicates that this project is meant to be used ` +
`with a newer version of Jest. ` +
`The snapshot file version ensures that all developers on a project ` +
`are using the same version of Jest. ` +
`Please update your version of Jest and re-run the tests.\n\n`) +
`with a newer version of Jest. The snapshot file version ensures ` +
`that all developers on a project are using the same version of ` +
`Jest. Please update your version of Jest and re-run the tests.\n\n`) +

@@ -100,3 +97,4 @@ `Expected: v${SNAPSHOT_VERSION}\n` +

const getSnapshotPath = testPath => path.join(
const getSnapshotPath = testPath =>
path.join(
path.join(path.dirname(testPath), '__snapshots__'),

@@ -111,3 +109,3 @@ path.basename(testPath) + '.' + SNAPSHOT_EXTENSION);

if (fileExists(snapshotPath)) {
if (fs.existsSync(snapshotPath)) {
try {

@@ -137,15 +135,19 @@ snapshotContents = fs.readFileSync(snapshotPath, 'utf8');

// to make the content of the snapshot easier to read
const addExtraLineBreaks =
string => string.includes('\n') ? `\n${string}\n` : string;
const addExtraLineBreaks = string =>
string.includes('\n') ? `\n${string}\n` : string;
const serialize = data => {
return addExtraLineBreaks(prettyFormat(data, {
return addExtraLineBreaks(
normalizeNewlines(
prettyFormat(data, {
escapeRegex: true,
plugins: getSerializers(),
printFunctionName: false }));
printFunctionName: false })));
};
const unescape = data =>
data.replace(/\\(")/g, '$1'); // unescape double quotes
// unescape double quotes
const unescape = data => data.replace(/\\(")/g, '$1');

@@ -162,4 +164,3 @@ const printBacktickString = str => {

const normalizeNewlines =
string => string.replace(/\r\n|\r/g, '\n');
const normalizeNewlines = string => string.replace(/\r\n|\r/g, '\n');

@@ -170,6 +171,11 @@ const saveSnapshotFile = (

{
const snapshots = Object.keys(snapshotData).sort(naturalCompare).
map(key =>
'exports[' + printBacktickString(key) + '] = ' +
printBacktickString(normalizeNewlines(snapshotData[key])) + ';');
const snapshots = Object.keys(snapshotData).
sort(naturalCompare).
map(
key =>
'exports[' +
printBacktickString(key) +
'] = ' +
printBacktickString(normalizeNewlines(snapshotData[key])) +
';');

@@ -176,0 +182,0 @@

{
"name": "jest-snapshot",
"version": "19.0.2",
"version": "19.1.0-alpha.eed82034",
"repository": {

@@ -12,9 +12,8 @@ "type": "git",

"chalk": "^1.1.3",
"jest-diff": "^19.0.0",
"jest-file-exists": "^19.0.0",
"jest-matcher-utils": "^19.0.0",
"jest-util": "^19.0.2",
"jest-diff": "^19.1.0-alpha.eed82034",
"jest-matcher-utils": "^19.1.0-alpha.eed82034",
"jest-util": "^19.1.0-alpha.eed82034",
"natural-compare": "^1.4.0",
"pretty-format": "^19.0.0"
"pretty-format": "^19.1.0-alpha.eed82034"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc