Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jest-snapshot

Package Overview
Dependencies
Maintainers
6
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 27.5.1 to 28.0.0-alpha.0

165

build/index.d.ts

@@ -7,29 +7,142 @@ /**

*/
import type { Config } from '@jest/types';
import type { FS as HasteFS } from 'jest-haste-map';
import { SnapshotResolver as JestSnapshotResolver } from './SnapshotResolver';
import SnapshotState from './State';
import type { Context, ExpectationResult } from './types';
import * as utils from './utils';
declare const JestSnapshot: {
EXTENSION: string;
SnapshotState: typeof SnapshotState;
addSerializer: (plugin: import("pretty-format").Plugin) => void;
buildSnapshotResolver: (config: Config.ProjectConfig, localRequire?: ((module: string) => unknown) | Promise<(module: string) => unknown>) => Promise<JestSnapshotResolver>;
cleanup: (hasteFS: HasteFS, update: Config.SnapshotUpdateState, snapshotResolver: JestSnapshotResolver, testPathIgnorePatterns?: string[] | undefined) => {
filesRemoved: number;
filesRemovedList: Array<string>;
};
getSerializers: () => import("pretty-format").Plugins;
isSnapshotPath: (path: string) => boolean;
toMatchInlineSnapshot: (this: Context, received: unknown, propertiesOrSnapshot?: string | object | undefined, inlineSnapshot?: string | undefined) => ExpectationResult;
toMatchSnapshot: (this: Context, received: unknown, propertiesOrHint?: string | object | undefined, hint?: string | undefined) => ExpectationResult;
toThrowErrorMatchingInlineSnapshot: (this: Context, received: unknown, inlineSnapshot?: string | undefined, fromPromise?: boolean | undefined) => ExpectationResult;
toThrowErrorMatchingSnapshot: (this: Context, received: unknown, hint: string | undefined, fromPromise: boolean) => ExpectationResult;
utils: typeof utils;
import type {Config} from '@jest/types';
import type {FS} from 'jest-haste-map';
import type {MatcherState} from 'expect';
import type {OptionsReceived} from 'pretty-format';
import {Plugin as Plugin_2} from 'pretty-format';
import {Plugins} from 'pretty-format';
export declare const addSerializer: (plugin: Plugin_2) => void;
export declare const buildSnapshotResolver: (
config: Config.ProjectConfig,
localRequire?: Promise<LocalRequire> | LocalRequire,
) => Promise<SnapshotResolver>;
export declare const cleanup: (
hasteFS: FS,
update: Config.SnapshotUpdateState,
snapshotResolver: SnapshotResolver,
testPathIgnorePatterns?: string[] | undefined,
) => {
filesRemoved: number;
filesRemovedList: Array<string>;
};
declare namespace JestSnapshot {
type SnapshotResolver = JestSnapshotResolver;
type SnapshotStateType = SnapshotState;
declare type Context = MatcherState & {
snapshotState: SnapshotState;
};
declare type ExpectationResult = {
pass: boolean;
message: () => string;
};
export declare const EXTENSION = 'snap';
export declare const getSerializers: () => Plugins;
export declare const isSnapshotPath: (path: string) => boolean;
declare type LocalRequire = (module: string) => unknown;
declare type SaveStatus = {
deleted: boolean;
saved: boolean;
};
declare type SnapshotMatchOptions = {
testName: string;
received: unknown;
key?: string;
inlineSnapshot?: string;
isInline: boolean;
error?: Error;
};
export declare type SnapshotResolver = {
testPathForConsistencyCheck: string;
resolveSnapshotPath(testPath: Config.Path, extension?: string): Config.Path;
resolveTestPath(snapshotPath: Config.Path, extension?: string): Config.Path;
};
declare type SnapshotReturnOptions = {
actual: string;
count: number;
expected?: string;
key: string;
pass: boolean;
};
export declare class SnapshotState {
private _counters;
private _dirty;
private _index;
private _updateSnapshot;
private _snapshotData;
private _initialData;
private _snapshotPath;
private _inlineSnapshots;
private _uncheckedKeys;
private _prettierPath;
private _snapshotFormat;
added: number;
expand: boolean;
matched: number;
unmatched: number;
updated: number;
constructor(snapshotPath: Config.Path, options: SnapshotStateOptions);
markSnapshotsAsCheckedForTest(testName: string): void;
private _addSnapshot;
clear(): void;
save(): SaveStatus;
getUncheckedCount(): number;
getUncheckedKeys(): Array<string>;
removeUncheckedKeys(): void;
match({
testName,
received,
key,
inlineSnapshot,
isInline,
error,
}: SnapshotMatchOptions): SnapshotReturnOptions;
fail(testName: string, _received: unknown, key?: string): string;
}
export = JestSnapshot;
declare type SnapshotStateOptions = {
updateSnapshot: Config.SnapshotUpdateState;
prettierPath: Config.Path;
expand?: boolean;
snapshotFormat: OptionsReceived;
};
export declare const toMatchInlineSnapshot: (
this: Context,
received: unknown,
propertiesOrSnapshot?: string | object | undefined,
inlineSnapshot?: string | undefined,
) => ExpectationResult;
export declare const toMatchSnapshot: (
this: Context,
received: unknown,
propertiesOrHint?: string | object | undefined,
hint?: string | undefined,
) => ExpectationResult;
export declare const toThrowErrorMatchingInlineSnapshot: (
this: Context,
received: unknown,
inlineSnapshot?: string | undefined,
fromPromise?: boolean | undefined,
) => ExpectationResult;
export declare const toThrowErrorMatchingSnapshot: (
this: Context,
received: unknown,
hint: string | undefined,
fromPromise: boolean,
) => ExpectationResult;
export {};

92

build/index.js
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
Object.defineProperty(exports, 'EXTENSION', {
enumerable: true,
get: function () {
return _SnapshotResolver.EXTENSION;
}
});
Object.defineProperty(exports, 'SnapshotState', {
enumerable: true,
get: function () {
return _State.default;
}
});
Object.defineProperty(exports, 'addSerializer', {
enumerable: true,
get: function () {
return _plugins.addSerializer;
}
});
Object.defineProperty(exports, 'buildSnapshotResolver', {
enumerable: true,
get: function () {
return _SnapshotResolver.buildSnapshotResolver;
}
});
exports.cleanup = void 0;
Object.defineProperty(exports, 'getSerializers', {
enumerable: true,
get: function () {
return _plugins.getSerializers;
}
});
Object.defineProperty(exports, 'isSnapshotPath', {
enumerable: true,
get: function () {
return _SnapshotResolver.isSnapshotPath;
}
});
exports.toThrowErrorMatchingSnapshot =
exports.toThrowErrorMatchingInlineSnapshot =
exports.toMatchSnapshot =
exports.toMatchInlineSnapshot =
void 0;
var fs = _interopRequireWildcard(require('graceful-fs'));

@@ -9,10 +55,10 @@

var _State = _interopRequireDefault(require('./State'));
var _printSnapshot = require('./printSnapshot');
var _utils = require('./utils');
var _plugins = require('./plugins');
var _printSnapshot = require('./printSnapshot');
var _State = _interopRequireDefault(require('./State'));
var utils = _interopRequireWildcard(require('./utils'));
function _interopRequireDefault(obj) {

@@ -124,6 +170,8 @@ return obj && obj.__esModule ? obj : {default: obj};

'Snapshot name: `' +
(hasNames ? utils.escapeBacktickString(concatenatedBlockNames) : '') +
(hasNames ? (0, _utils.escapeBacktickString)(concatenatedBlockNames) : '') +
(hasNames && hasHint ? ': ' : '') +
(hasHint
? (0, _jestMatcherUtils.BOLD_WEIGHT)(utils.escapeBacktickString(hint))
? (0, _jestMatcherUtils.BOLD_WEIGHT)(
(0, _utils.escapeBacktickString)(hint)
)
: '') +

@@ -213,2 +261,4 @@ ' ' +

exports.cleanup = cleanup;
const toMatchSnapshot = function (received, propertiesOrHint, hint) {

@@ -273,2 +323,4 @@ const matcherName = 'toMatchSnapshot';

exports.toMatchSnapshot = toMatchSnapshot;
const toMatchInlineSnapshot = function (

@@ -333,3 +385,3 @@ received,

inlineSnapshot,
utils.serialize
_utils.serialize
)

@@ -356,2 +408,4 @@ )

exports.toMatchInlineSnapshot = toMatchInlineSnapshot;
const _toMatchSnapshot = config => {

@@ -440,3 +494,3 @@ const {context, hint, inlineSnapshot, isInline, matcherName, properties} =

} else {
received = utils.deepMerge(received, properties);
received = (0, _utils.deepMerge)(received, properties);
}

@@ -519,2 +573,4 @@ }

exports.toThrowErrorMatchingSnapshot = toThrowErrorMatchingSnapshot;
const toThrowErrorMatchingInlineSnapshot = function (

@@ -545,3 +601,3 @@ received,

inlineSnapshot,
utils.serialize
_utils.serialize
)

@@ -567,2 +623,4 @@ )

exports.toThrowErrorMatchingInlineSnapshot = toThrowErrorMatchingInlineSnapshot;
const _toThrowErrorMatchingSnapshot = (config, fromPromise) => {

@@ -640,17 +698,1 @@ const {context, hint, inlineSnapshot, isInline, matcherName, received} =

};
const JestSnapshot = {
EXTENSION: _SnapshotResolver.EXTENSION,
SnapshotState: _State.default,
addSerializer: _plugins.addSerializer,
buildSnapshotResolver: _SnapshotResolver.buildSnapshotResolver,
cleanup,
getSerializers: _plugins.getSerializers,
isSnapshotPath: _SnapshotResolver.isSnapshotPath,
toMatchInlineSnapshot,
toMatchSnapshot,
toThrowErrorMatchingInlineSnapshot,
toThrowErrorMatchingSnapshot,
utils
};
module.exports = JestSnapshot;

@@ -23,3 +23,3 @@ 'use strict';

var _utils = require('expect/build/utils');
var _expectUtils = require('@jest/expect-utils');

@@ -38,3 +38,3 @@ var _jestDiff = require('jest-diff');

var _utils2 = require('./utils');
var _utils = require('./utils');

@@ -51,8 +51,2 @@ function _interopRequireDefault(obj) {

*/
/* eslint-disable local/ban-types-eventually */
// Temporary hack because getObjectSubset has known limitations,
// is not in the public interface of the expect package,
// and the long-term goal is to use a non-serialization diff.
// Make sure to remove file from `exports` in `expect/package.json`.
const getSnapshotColorForChalkInstance = chalkInstance => {

@@ -233,3 +227,3 @@ const level = chalkInstance.level;

const printExpected = val =>
(0, _jestMatcherUtils.EXPECTED_COLOR)((0, _utils2.minify)(val));
(0, _jestMatcherUtils.EXPECTED_COLOR)((0, _utils.minify)(val));

@@ -239,3 +233,3 @@ exports.printExpected = printExpected;

const printReceived = val =>
(0, _jestMatcherUtils.RECEIVED_COLOR)((0, _utils2.minify)(val));
(0, _jestMatcherUtils.RECEIVED_COLOR)((0, _utils.minify)(val));

@@ -254,5 +248,5 @@ exports.printReceived = printReceived;

return (0, _jestDiff.diffLinesUnified)(
(0, _utils2.serialize)(properties).split('\n'),
(0, _utils2.serialize)(
(0, _utils.getObjectSubset)(received, properties)
(0, _utils.serialize)(properties).split('\n'),
(0, _utils.serialize)(
(0, _expectUtils.getObjectSubset)(received, properties)
).split('\n'),

@@ -359,3 +353,3 @@ {

a = (0, _utils2.deserializeString)(a); // hypothetical expected string
a = (0, _utils.deserializeString)(a); // hypothetical expected string

@@ -377,3 +371,3 @@ b = received; // not serialized

const b0 = (0, _utils2.serialize)(received, 0);
const b0 = (0, _utils.serialize)(received, 0);

@@ -380,0 +374,0 @@ if (b0 !== b) {

'use strict';
var global = (function () {
if (typeof globalThis !== 'undefined') {
return globalThis;
} else if (typeof global !== 'undefined') {
return global;
} else if (typeof self !== 'undefined') {
return self;
} else if (typeof window !== 'undefined') {
return window;
} else {
return Function('return this')();
}
})();
var Symbol = global['jest-symbol-do-not-touch'] || global.Symbol;
Object.defineProperty(exports, '__esModule', {

@@ -103,54 +88,41 @@ value: true

var jestExistsFile =
global[Symbol.for('jest-native-exists-file')] || fs.existsSync;
var Symbol = global['jest-symbol-do-not-touch'] || global.Symbol;
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
var global = (function () {
if (typeof globalThis !== 'undefined') {
return globalThis;
} else if (typeof global !== 'undefined') {
return global;
} else if (typeof self !== 'undefined') {
return self;
} else if (typeof window !== 'undefined') {
return window;
} else {
obj[key] = value;
return Function('return this')();
}
return obj;
}
})();
var jestExistsFile =
global[Symbol.for('jest-native-exists-file')] || fs.existsSync;
class SnapshotState {
// @ts-expect-error
constructor(snapshotPath, options) {
_defineProperty(this, '_counters', void 0);
_counters;
_dirty; // @ts-expect-error
_defineProperty(this, '_dirty', void 0);
_index;
_updateSnapshot;
_snapshotData;
_initialData;
_snapshotPath;
_inlineSnapshots;
_uncheckedKeys;
_prettierPath;
_snapshotFormat;
added;
expand;
matched;
unmatched;
updated;
_defineProperty(this, '_index', void 0);
_defineProperty(this, '_updateSnapshot', void 0);
_defineProperty(this, '_snapshotData', void 0);
_defineProperty(this, '_initialData', void 0);
_defineProperty(this, '_snapshotPath', void 0);
_defineProperty(this, '_inlineSnapshots', void 0);
_defineProperty(this, '_uncheckedKeys', void 0);
_defineProperty(this, '_prettierPath', void 0);
_defineProperty(this, '_snapshotFormat', void 0);
_defineProperty(this, 'added', void 0);
_defineProperty(this, 'expand', void 0);
_defineProperty(this, 'matched', void 0);
_defineProperty(this, 'unmatched', void 0);
_defineProperty(this, 'updated', void 0);
constructor(snapshotPath, options) {
this._snapshotPath = snapshotPath;

@@ -157,0 +129,0 @@ const {data, dirty} = (0, _utils.getSnapshotData)(

{
"name": "jest-snapshot",
"version": "27.5.1",
"version": "28.0.0-alpha.0",
"repository": {

@@ -25,4 +25,5 @@ "type": "git",

"@babel/types": "^7.0.0",
"@jest/transform": "^27.5.1",
"@jest/types": "^27.5.1",
"@jest/expect-utils": "^28.0.0-alpha.0",
"@jest/transform": "^28.0.0-alpha.0",
"@jest/types": "^28.0.0-alpha.0",
"@types/babel__traverse": "^7.0.4",

@@ -32,12 +33,12 @@ "@types/prettier": "^2.1.5",

"chalk": "^4.0.0",
"expect": "^27.5.1",
"expect": "^28.0.0-alpha.0",
"graceful-fs": "^4.2.9",
"jest-diff": "^27.5.1",
"jest-get-type": "^27.5.1",
"jest-haste-map": "^27.5.1",
"jest-matcher-utils": "^27.5.1",
"jest-message-util": "^27.5.1",
"jest-util": "^27.5.1",
"jest-diff": "^28.0.0-alpha.0",
"jest-get-type": "^28.0.0-alpha.0",
"jest-haste-map": "^28.0.0-alpha.0",
"jest-matcher-utils": "^28.0.0-alpha.0",
"jest-message-util": "^28.0.0-alpha.0",
"jest-util": "^28.0.0-alpha.0",
"natural-compare": "^1.4.0",
"pretty-format": "^27.5.1",
"pretty-format": "^28.0.0-alpha.0",
"semver": "^7.3.2"

@@ -48,3 +49,3 @@ },

"@babel/preset-react": "^7.7.2",
"@jest/test-utils": "^27.5.1",
"@jest/test-utils": "^28.0.0-alpha.0",
"@types/graceful-fs": "^4.1.3",

@@ -58,3 +59,3 @@ "@types/natural-compare": "^1.4.0",

"engines": {
"node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0"
"node": "^12.13.0 || ^14.15.0 || ^16.13.0 || >=17.0.0"
},

@@ -64,3 +65,3 @@ "publishConfig": {

},
"gitHead": "67c1aa20c5fec31366d733e901fee2b981cb1850"
"gitHead": "89275b08977065d98e42ad71fcf223f4ad169f09"
}
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