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

expect

Package Overview
Dependencies
Maintainers
5
Versions
237
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

expect - npm Package Compare versions

Comparing version 27.2.4 to 27.2.5

12

build/asymmetricMatchers.d.ts

@@ -8,7 +8,13 @@ /**

*/
export declare class AsymmetricMatcher<T> {
import type { AsymmetricMatcher as AsymmetricMatcherInterface, MatcherState } from './types';
export declare abstract class AsymmetricMatcher<T, State extends MatcherState = MatcherState> implements AsymmetricMatcherInterface {
protected sample: T;
protected inverse: boolean;
$$typeof: symbol;
inverse?: boolean;
constructor(sample: T);
constructor(sample: T, inverse?: boolean);
protected getMatcherContext(): State;
abstract asymmetricMatch(other: unknown): boolean;
abstract toString(): string;
getExpectedType?(): string;
toAsymmetricMatcher?(): string;
}

@@ -15,0 +21,0 @@ declare class Any extends AsymmetricMatcher<any> {

@@ -19,4 +19,52 @@ 'use strict';

var matcherUtils = _interopRequireWildcard(require('jest-matcher-utils'));
var _jasmineUtils = require('./jasmineUtils');
var _jestMatchersObject = require('./jestMatchersObject');
var _utils = require('./utils');
function _getRequireWildcardCache(nodeInterop) {
if (typeof WeakMap !== 'function') return null;
var cacheBabelInterop = new WeakMap();
var cacheNodeInterop = new WeakMap();
return (_getRequireWildcardCache = function (nodeInterop) {
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
})(nodeInterop);
}
function _interopRequireWildcard(obj, nodeInterop) {
if (!nodeInterop && obj && obj.__esModule) {
return obj;
}
if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) {
return {default: obj};
}
var cache = _getRequireWildcardCache(nodeInterop);
if (cache && cache.has(obj)) {
return cache.get(obj);
}
var newObj = {};
var hasPropertyDescriptor =
Object.defineProperty && Object.getOwnPropertyDescriptor;
for (var key in obj) {
if (key !== 'default' && Object.prototype.hasOwnProperty.call(obj, key)) {
var desc = hasPropertyDescriptor
? Object.getOwnPropertyDescriptor(obj, key)
: null;
if (desc && (desc.get || desc.set)) {
Object.defineProperty(newObj, key, desc);
} else {
newObj[key] = obj[key];
}
}
}
newObj.default = obj;
if (cache) {
cache.set(obj, newObj);
}
return newObj;
}
var global = (function () {

@@ -52,12 +100,23 @@ if (typeof globalThis !== 'undefined') {

const utils = Object.freeze({
...matcherUtils,
iterableEquality: _utils.iterableEquality,
subsetEquality: _utils.subsetEquality
});
class AsymmetricMatcher {
constructor(sample) {
_defineProperty(this, 'sample', void 0);
constructor(sample, inverse = false) {
this.sample = sample;
this.inverse = inverse;
_defineProperty(this, '$$typeof', void 0);
_defineProperty(this, '$$typeof', Symbol.for('jest.asymmetricMatcher'));
}
_defineProperty(this, 'inverse', void 0);
this.$$typeof = Symbol.for('jest.asymmetricMatcher');
this.sample = sample;
getMatcherContext() {
return {
...(0, _jestMatchersObject.getState)(),
equals: _jasmineUtils.equals,
isNot: this.inverse,
utils
};
}

@@ -162,4 +221,3 @@ }

constructor(sample, inverse = false) {
super(sample);
this.inverse = inverse;
super(sample, inverse);
}

@@ -196,4 +254,3 @@

constructor(sample, inverse = false) {
super(sample);
this.inverse = inverse;
super(sample, inverse);
}

@@ -240,4 +297,3 @@

super(sample);
this.inverse = inverse;
super(sample, inverse);
}

@@ -269,4 +325,3 @@

super(new RegExp(sample));
this.inverse = inverse;
super(new RegExp(sample), inverse);
}

@@ -273,0 +328,0 @@

@@ -9,3 +9,3 @@ /**

import type { Expect, MatcherState as JestMatcherState, Matchers as MatcherInterface } from './types';
declare const expectExport: Expect;
declare const expectExport: Expect<JestMatcherState>;
declare namespace expectExport {

@@ -12,0 +12,0 @@ type MatcherState = JestMatcherState;

@@ -450,4 +450,6 @@ 'use strict';

(0, _jestMatchersObject.getState)().expectedAssertionsNumber = expected;
(0, _jestMatchersObject.getState)().expectedAssertionsNumberError = error;
(0, _jestMatchersObject.setState)({
expectedAssertionsNumber: expected,
expectedAssertionsNumberError: error
});
}

@@ -463,4 +465,6 @@

matcherUtils.ensureNoExpected(args[0], '.hasAssertions');
(0, _jestMatchersObject.getState)().isExpectingAssertions = true;
(0, _jestMatchersObject.getState)().isExpectingAssertionsError = error;
(0, _jestMatchersObject.setState)({
isExpectingAssertions: true,
isExpectingAssertionsError: error
});
} // add default jest matchers

@@ -467,0 +471,0 @@

@@ -10,5 +10,5 @@ /**

export declare const INTERNAL_MATCHER_FLAG: unique symbol;
export declare const getState: () => MatcherState;
export declare const setState: (state: Partial<MatcherState>) => void;
export declare const getMatchers: () => MatchersObject;
export declare const setMatchers: (matchers: MatchersObject, isInternal: boolean, expect: Expect) => void;
export declare const getState: <State extends MatcherState = MatcherState>() => State;
export declare const setState: <State extends MatcherState = MatcherState>(state: Partial<State>) => void;
export declare const getMatchers: <State extends MatcherState = MatcherState>() => MatchersObject<State>;
export declare const setMatchers: <State extends MatcherState = MatcherState>(matchers: MatchersObject<State>, isInternal: boolean, expect: Expect) => void;

@@ -78,8 +78,11 @@ 'use strict';

constructor(inverse = false, ...sample) {
super(sample);
this.inverse = inverse;
super(sample, inverse);
}
asymmetricMatch(other) {
const {pass} = matcher(other, ...this.sample);
const {pass} = matcher.call(
this.getMatcherContext(),
other,
...this.sample
);
return this.inverse ? !pass : pass;

@@ -104,3 +107,5 @@ }

if (!expect.not) {
expect.not = {};
throw new Error(
'`expect.not` is not defined - please report this bug to https://github.com/facebook/jest'
);
}

@@ -107,0 +112,0 @@

@@ -17,4 +17,4 @@ /**

export declare type ExpectationResult = SyncExpectationResult | AsyncExpectationResult;
export declare type RawMatcherFn = {
(received: any, expected: any, options?: any): ExpectationResult;
export declare type RawMatcherFn<T extends MatcherState = MatcherState> = {
(this: T, received: any, expected: any, options?: any): ExpectationResult;
[INTERNAL_MATCHER_FLAG]?: boolean;

@@ -45,5 +45,10 @@ };

};
export declare type AsymmetricMatcher = Record<string, any>;
export declare type MatchersObject = {
[id: string]: RawMatcherFn;
export interface AsymmetricMatcher {
asymmetricMatch(other: unknown): boolean;
toString(): string;
getExpectedType?(): string;
toAsymmetricMatcher?(): string;
}
export declare type MatchersObject<T extends MatcherState = MatcherState> = {
[id: string]: RawMatcherFn<T>;
};

@@ -55,13 +60,3 @@ export declare type ExpectedAssertionsErrors = Array<{

}>;
export declare type Expect = {
<T = unknown>(actual: T): Matchers<T>;
addSnapshotSerializer(arg0: any): void;
assertions(arg0: number): void;
extend(arg0: any): void;
extractExpectedAssertionsErrors: () => ExpectedAssertionsErrors;
getState(): MatcherState;
hasAssertions(): void;
setState(state: Partial<MatcherState>): void;
any(expectedObject: any): AsymmetricMatcher;
anything(): AsymmetricMatcher;
interface InverseAsymmetricMatchers {
arrayContaining(sample: Array<unknown>): AsymmetricMatcher;

@@ -71,10 +66,22 @@ objectContaining(sample: Record<string, unknown>): AsymmetricMatcher;

stringMatching(expected: string | RegExp): AsymmetricMatcher;
[id: string]: AsymmetricMatcher;
not: {
[id: string]: AsymmetricMatcher;
};
}
interface AsymmetricMatchers extends InverseAsymmetricMatchers {
any(expectedObject: unknown): AsymmetricMatcher;
anything(): AsymmetricMatcher;
}
interface ExtraAsymmetricMatchers {
[id: string]: (...sample: [unknown, ...Array<unknown>]) => AsymmetricMatcher;
}
export declare type Expect<State extends MatcherState = MatcherState> = {
<T = unknown>(actual: T): Matchers<void>;
addSnapshotSerializer(serializer: unknown): void;
assertions(numberOfAssertions: number): void;
extend<T extends MatcherState = State>(matchers: MatchersObject<T>): void;
extractExpectedAssertionsErrors: () => ExpectedAssertionsErrors;
getState(): State;
hasAssertions(): void;
setState(state: Partial<State>): void;
} & AsymmetricMatchers & ExtraAsymmetricMatchers & {
not: InverseAsymmetricMatchers & ExtraAsymmetricMatchers;
};
interface Constructable {
new (...args: Array<unknown>): unknown;
}
export interface Matchers<R> {

@@ -291,7 +298,7 @@ /**

*/
toThrow(error?: string | Constructable | RegExp | Error): R;
toThrow(error?: unknown): R;
/**
* If you want to test that a specific error is thrown inside a function.
*/
toThrowError(error?: string | Constructable | RegExp | Error): R;
toThrowError(error?: unknown): R;
/**

@@ -298,0 +305,0 @@ * This ensures that a value matches the most recent snapshot with property matchers.

{
"name": "expect",
"version": "27.2.4",
"version": "27.2.5",
"repository": {

@@ -15,14 +15,15 @@ "type": "git",

"./package.json": "./package.json",
"./build/utils": "./build/utils.js"
"./build/utils": "./build/utils.js",
"./build/matchers": "./build/matchers.js"
},
"dependencies": {
"@jest/types": "^27.2.4",
"@jest/types": "^27.2.5",
"ansi-styles": "^5.0.0",
"jest-get-type": "^27.0.6",
"jest-matcher-utils": "^27.2.4",
"jest-message-util": "^27.2.4",
"jest-matcher-utils": "^27.2.5",
"jest-message-util": "^27.2.5",
"jest-regex-util": "^27.0.6"
},
"devDependencies": {
"@jest/test-utils": "^27.2.4",
"@jest/test-utils": "^27.2.5",
"chalk": "^4.0.0",

@@ -38,3 +39,3 @@ "fast-check": "^2.0.0",

},
"gitHead": "5886f6c4d681aa9fc9bfc2517efd2b7f6035a4cd"
"gitHead": "251b8014e8e3ac8da2fca88b5a1bc401f3b92326"
}
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