Socket
Socket
Sign inDemoInstall

expect

Package Overview
Dependencies
39
Maintainers
5
Versions
236
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 27.2.5 to 27.3.0

2

build/index.d.ts

@@ -12,5 +12,5 @@ /**

type MatcherState = JestMatcherState;
interface Matchers<R> extends MatcherInterface<R> {
interface Matchers<R, T> extends MatcherInterface<R, T> {
}
}
export = expectExport;

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

expect[key] = (...sample) => new CustomMatcher(false, ...sample);
if (!expect.not) {
throw new Error(
'`expect.not` is not defined - please report this bug to https://github.com/facebook/jest'
);
}
expect.not[key] = (...sample) => new CustomMatcher(true, ...sample);
Object.defineProperty(expect, key, {
value: (...sample) => new CustomMatcher(false, ...sample)
});
Object.defineProperty(expect.not, key, {
value: (...sample) => new CustomMatcher(true, ...sample)
});
}

@@ -114,0 +111,0 @@ });

@@ -58,17 +58,12 @@ /**

}>;
interface InverseAsymmetricMatchers {
interface AsymmetricMatchers {
any(sample: unknown): AsymmetricMatcher;
anything(): AsymmetricMatcher;
arrayContaining(sample: Array<unknown>): AsymmetricMatcher;
objectContaining(sample: Record<string, unknown>): AsymmetricMatcher;
stringContaining(expected: string): AsymmetricMatcher;
stringMatching(expected: string | RegExp): AsymmetricMatcher;
stringContaining(sample: string): AsymmetricMatcher;
stringMatching(sample: string | RegExp): 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>;
<T = unknown>(actual: T): Matchers<void, T>;
addSnapshotSerializer(serializer: unknown): void;

@@ -81,26 +76,26 @@ assertions(numberOfAssertions: number): void;

setState(state: Partial<State>): void;
} & AsymmetricMatchers & ExtraAsymmetricMatchers & {
not: InverseAsymmetricMatchers & ExtraAsymmetricMatchers;
} & AsymmetricMatchers & {
not: Omit<AsymmetricMatchers, 'any' | 'anything'>;
};
export interface Matchers<R> {
export interface Matchers<R, T = unknown> {
/**
* Ensures the last call to a mock function was provided specific args.
*/
lastCalledWith(...args: Array<unknown>): R;
lastCalledWith(...expected: [unknown, ...Array<unknown>]): R;
/**
* Ensure that the last call to a mock function has returned a specified value.
*/
lastReturnedWith(value: unknown): R;
lastReturnedWith(expected: unknown): R;
/**
* If you know how to test something, `.not` lets you test its opposite.
*/
not: Matchers<R>;
not: Matchers<R, T>;
/**
* Ensure that a mock function is called with specific arguments on an Nth call.
*/
nthCalledWith(nthCall: number, ...args: Array<unknown>): R;
nthCalledWith(nth: number, ...expected: [unknown, ...Array<unknown>]): R;
/**
* Ensure that the nth call to a mock function has returned a specified value.
*/
nthReturnedWith(n: number, value: unknown): R;
nthReturnedWith(nth: number, expected: unknown): R;
/**

@@ -110,3 +105,3 @@ * Use resolves to unwrap the value of a fulfilled promise so any other

*/
resolves: Matchers<Promise<R>>;
resolves: Matchers<Promise<R>, T>;
/**

@@ -116,3 +111,3 @@ * Unwraps the reason of a rejected promise so any other matcher can be chained.

*/
rejects: Matchers<Promise<R>>;
rejects: Matchers<Promise<R>, T>;
/**

@@ -134,9 +129,9 @@ * Checks that a value is what you expect. It uses `===` to check strict equality.

*/
toBeCalledWith(...args: Array<unknown>): R;
toBeCalledWith(...expected: [unknown, ...Array<unknown>]): R;
/**
* Using exact equality with floating point numbers is a bad idea.
* Rounding means that intuitive things fail.
* The default for numDigits is 2.
* The default for `precision` is 2.
*/
toBeCloseTo(expected: number, numDigits?: number): R;
toBeCloseTo(expected: number, precision?: number): R;
/**

@@ -163,3 +158,3 @@ * Ensure that a variable is not undefined.

*/
toBeInstanceOf(expected: Function): R;
toBeInstanceOf(expected: unknown): R;
/**

@@ -219,7 +214,7 @@ * For comparing floating point numbers.

*/
toHaveBeenCalledWith(...args: Array<unknown>): R;
toHaveBeenCalledWith(...expected: [unknown, ...Array<unknown>]): R;
/**
* Ensure that a mock function is called with specific arguments on an Nth call.
*/
toHaveBeenNthCalledWith(nthCall: number, ...args: Array<unknown>): R;
toHaveBeenNthCalledWith(nth: number, ...expected: [unknown, ...Array<unknown>]): R;
/**

@@ -229,3 +224,3 @@ * If you have a mock function, you can use `.toHaveBeenLastCalledWith`

*/
toHaveBeenLastCalledWith(...args: Array<unknown>): R;
toHaveBeenLastCalledWith(...expected: [unknown, ...Array<unknown>]): R;
/**

@@ -247,3 +242,3 @@ * Use to test the specific value that a mock function last returned.

*/
toHaveNthReturnedWith(nthCall: number, expected: unknown): R;
toHaveNthReturnedWith(nth: number, expected: unknown): R;
/**

@@ -262,3 +257,3 @@ * Use to check if property at provided reference keyPath exists for an object.

*/
toHaveProperty(keyPath: string | Array<string>, value?: unknown): R;
toHaveProperty(expectedPath: string | Array<string>, expectedValue?: unknown): R;
/**

@@ -284,3 +279,3 @@ * Use to test that the mock function successfully returned (i.e., did not throw an error) at least one time

*/
toMatchObject(expected: Record<string, unknown> | Array<unknown>): R;
toMatchObject(expected: Record<string, unknown> | Array<Record<string, unknown>>): R;
/**

@@ -293,7 +288,7 @@ * Ensure that a mock function has returned (as opposed to thrown) at least once.

*/
toReturnTimes(count: number): R;
toReturnTimes(expected: number): R;
/**
* Ensure that a mock function has returned a specified value at least once.
*/
toReturnWith(value: unknown): R;
toReturnWith(expected: unknown): R;
/**

@@ -306,7 +301,7 @@ * Use to test that objects have the same types as well as structure.

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

@@ -316,5 +311,3 @@ * This ensures that a value matches the most recent snapshot with property matchers.

*/
toMatchSnapshot<T extends {
[P in keyof R]: unknown;
}>(propertyMatchers: Partial<T>, snapshotName?: string): R;
toMatchSnapshot(hint?: string): R;
/**

@@ -324,3 +317,3 @@ * This ensures that a value matches the most recent snapshot.

*/
toMatchSnapshot(snapshotName?: string): R;
toMatchSnapshot<U extends Record<keyof T, unknown>>(propertyMatchers: Partial<U>, hint?: string): R;
/**

@@ -331,5 +324,3 @@ * This ensures that a value matches the most recent snapshot with property matchers.

*/
toMatchInlineSnapshot<T extends {
[P in keyof R]: unknown;
}>(propertyMatchers: Partial<T>, snapshot?: string): R;
toMatchInlineSnapshot(snapshot?: string): R;
/**

@@ -340,7 +331,7 @@ * This ensures that a value matches the most recent snapshot with property matchers.

*/
toMatchInlineSnapshot(snapshot?: string): R;
toMatchInlineSnapshot<U extends Record<keyof T, unknown>>(propertyMatchers: Partial<U>, snapshot?: string): R;
/**
* Used to test that a function throws a error matching the most recent snapshot when it is called.
*/
toThrowErrorMatchingSnapshot(): R;
toThrowErrorMatchingSnapshot(hint?: string): R;
/**

@@ -347,0 +338,0 @@ * Used to test that a function throws a error matching the most recent snapshot when it is called.

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

@@ -22,8 +22,8 @@ "type": "git",

"jest-get-type": "^27.0.6",
"jest-matcher-utils": "^27.2.5",
"jest-message-util": "^27.2.5",
"jest-matcher-utils": "^27.3.0",
"jest-message-util": "^27.3.0",
"jest-regex-util": "^27.0.6"
},
"devDependencies": {
"@jest/test-utils": "^27.2.5",
"@jest/test-utils": "^27.3.0",
"chalk": "^4.0.0",

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

},
"gitHead": "251b8014e8e3ac8da2fca88b5a1bc401f3b92326"
"gitHead": "14b0c2c1d6f81b64adf8b827649ece80a4448cfc"
}
SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc