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

@vitest/expect

Package Overview
Dependencies
Maintainers
3
Versions
98
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vitest/expect - npm Package Compare versions

Comparing version 0.30.1 to 0.31.0

6

./dist/index.js

@@ -228,3 +228,3 @@ import { getColors, stringify, isObject, assertTypes } from '@vitest/utils';

function isDomNode(obj) {
return obj !== null && typeof obj === "object" && typeof obj.nodeType === "number" && typeof obj.nodeName === "string" && typeof obj.isEqualNode === "function";
return obj !== null && typeof obj === "object" && "nodeType" in obj && typeof obj.nodeType === "number" && "nodeName" in obj && typeof obj.nodeName === "string" && "isEqualNode" in obj && typeof obj.isEqualNode === "function";
}

@@ -956,3 +956,3 @@ function fnNameFor(func) {

if (actualCall)
methodCall += diff(callArg, actualCall, { showLegend: false });
methodCall += diff(actualCall, callArg, { showLegend: false });
else

@@ -978,3 +978,3 @@ methodCall += stringify(callArg).split("\n").map((line) => ` ${line}`).join("\n");

if (actualReturn)
methodCall += diff(callReturn.value, actualReturn, { showLegend: false });
methodCall += diff(actualReturn, callReturn.value, { showLegend: false });
else

@@ -981,0 +981,0 @@ methodCall += stringify(callReturn).split("\n").map((line) => ` ${line}`).join("\n");

import { use } from 'chai';
import { stringify } from '@vitest/utils';
import { stringify, Constructable } from '@vitest/utils';
export { setupColors } from '@vitest/utils';

@@ -107,2 +107,83 @@

type MatchersObject<T extends MatcherState = MatcherState> = Record<string, RawMatcherFn<T>>;
interface ExpectStatic extends Chai.ExpectStatic, AsymmetricMatchersContaining {
<T>(actual: T, message?: string): Assertion<T>;
extend(expects: MatchersObject): void;
assertions(expected: number): void;
hasAssertions(): void;
anything(): any;
any(constructor: unknown): any;
getState(): MatcherState;
setState(state: Partial<MatcherState>): void;
not: AsymmetricMatchersContaining;
}
interface AsymmetricMatchersContaining {
stringContaining(expected: string): any;
objectContaining<T = any>(expected: T): any;
arrayContaining<T = unknown>(expected: Array<T>): any;
stringMatching(expected: string | RegExp): any;
}
interface JestAssertion<T = any> extends jest.Matchers<void, T> {
toEqual<E>(expected: E): void;
toStrictEqual<E>(expected: E): void;
toBe<E>(expected: E): void;
toMatch(expected: string | RegExp): void;
toMatchObject<E extends {} | any[]>(expected: E): void;
toContain<E>(item: E): void;
toContainEqual<E>(item: E): void;
toBeTruthy(): void;
toBeFalsy(): void;
toBeGreaterThan(num: number | bigint): void;
toBeGreaterThanOrEqual(num: number | bigint): void;
toBeLessThan(num: number | bigint): void;
toBeLessThanOrEqual(num: number | bigint): void;
toBeNaN(): void;
toBeUndefined(): void;
toBeNull(): void;
toBeDefined(): void;
toBeInstanceOf<E>(expected: E): void;
toBeCalledTimes(times: number): void;
toHaveLength(length: number): void;
toHaveProperty<E>(property: string | (string | number)[], value?: E): void;
toBeCloseTo(number: number, numDigits?: number): void;
toHaveBeenCalledTimes(times: number): void;
toHaveBeenCalled(): void;
toBeCalled(): void;
toHaveBeenCalledWith<E extends any[]>(...args: E): void;
toBeCalledWith<E extends any[]>(...args: E): void;
toHaveBeenNthCalledWith<E extends any[]>(n: number, ...args: E): void;
nthCalledWith<E extends any[]>(nthCall: number, ...args: E): void;
toHaveBeenLastCalledWith<E extends any[]>(...args: E): void;
lastCalledWith<E extends any[]>(...args: E): void;
toThrow(expected?: string | Constructable | RegExp | Error): void;
toThrowError(expected?: string | Constructable | RegExp | Error): void;
toReturn(): void;
toHaveReturned(): void;
toReturnTimes(times: number): void;
toHaveReturnedTimes(times: number): void;
toReturnWith<E>(value: E): void;
toHaveReturnedWith<E>(value: E): void;
toHaveLastReturnedWith<E>(value: E): void;
lastReturnedWith<E>(value: E): void;
toHaveNthReturnedWith<E>(nthCall: number, value: E): void;
nthReturnedWith<E>(nthCall: number, value: E): void;
}
type VitestAssertion<A, T> = {
[K in keyof A]: A[K] extends Chai.Assertion ? Assertion<T> : A[K] extends (...args: any[]) => any ? A[K] : VitestAssertion<A[K], T>;
} & ((type: string, message?: string) => Assertion);
type Promisify<O> = {
[K in keyof O]: O[K] extends (...args: infer A) => infer R ? O extends R ? Promisify<O[K]> : (...args: A) => Promise<R> : O[K];
};
interface Assertion<T = any> extends VitestAssertion<Chai.Assertion, T>, JestAssertion<T> {
toBeTypeOf(expected: 'bigint' | 'boolean' | 'function' | 'number' | 'object' | 'string' | 'symbol' | 'undefined'): void;
toHaveBeenCalledOnce(): void;
toSatisfy<E>(matcher: (value: E) => boolean, message?: string): void;
resolves: Promisify<Assertion<T>>;
rejects: Promisify<Assertion<T>>;
}
declare global {
namespace jest {
interface Matchers<R, T = {}> {
}
}
}

@@ -120,3 +201,3 @@ interface AsymmetricMatcherInterface {

constructor(sample: T, inverse?: boolean);
protected getMatcherContext(expect?: Vi.ExpectStatic): State;
protected getMatcherContext(expect?: Chai.ExpectStatic): State;
abstract asymmetricMatch(other: unknown): boolean;

@@ -187,4 +268,4 @@ abstract toString(): string;

declare function getState<State extends MatcherState = MatcherState>(expect: Vi.ExpectStatic): State;
declare function setState<State extends MatcherState = MatcherState>(state: Partial<State>, expect: Vi.ExpectStatic): void;
declare function getState<State extends MatcherState = MatcherState>(expect: ExpectStatic): State;
declare function setState<State extends MatcherState = MatcherState>(state: Partial<State>, expect: ExpectStatic): void;

@@ -195,2 +276,2 @@ declare const JestChaiExpect: ChaiPlugin;

export { Any, Anything, ArrayContaining, AsymmetricMatcher, AsymmetricMatcherInterface, AsyncExpectationResult, ChaiPlugin, DiffOptions, ExpectationResult, FirstFunctionArgument, GLOBAL_EXPECT, JEST_MATCHERS_OBJECT, JestAsymmetricMatchers, JestChaiExpect, JestExtend, MATCHERS_OBJECT, MatcherHintOptions, MatcherState, MatchersObject, ObjectContaining, RawMatcherFn, StringContaining, StringMatching, SyncExpectationResult, Tester, arrayBufferEquality, equals, fnNameFor, generateToBeMessage, getState, hasAsymmetric, hasProperty, isA, isAsymmetric, isImmutableUnorderedKeyed, isImmutableUnorderedSet, iterableEquality, setState, sparseArrayEquality, subsetEquality, typeEquality };
export { Any, Anything, ArrayContaining, Assertion, AsymmetricMatcher, AsymmetricMatcherInterface, AsymmetricMatchersContaining, AsyncExpectationResult, ChaiPlugin, DiffOptions, ExpectStatic, ExpectationResult, FirstFunctionArgument, GLOBAL_EXPECT, JEST_MATCHERS_OBJECT, JestAssertion, JestAsymmetricMatchers, JestChaiExpect, JestExtend, MATCHERS_OBJECT, MatcherHintOptions, MatcherState, MatchersObject, ObjectContaining, RawMatcherFn, StringContaining, StringMatching, SyncExpectationResult, Tester, arrayBufferEquality, equals, fnNameFor, generateToBeMessage, getState, hasAsymmetric, hasProperty, isA, isAsymmetric, isImmutableUnorderedKeyed, isImmutableUnorderedSet, iterableEquality, setState, sparseArrayEquality, subsetEquality, typeEquality };

@@ -228,3 +228,3 @@ import { getColors, stringify, isObject, assertTypes } from '@vitest/utils';

function isDomNode(obj) {
return obj !== null && typeof obj === "object" && typeof obj.nodeType === "number" && typeof obj.nodeName === "string" && typeof obj.isEqualNode === "function";
return obj !== null && typeof obj === "object" && "nodeType" in obj && typeof obj.nodeType === "number" && "nodeName" in obj && typeof obj.nodeName === "string" && "isEqualNode" in obj && typeof obj.isEqualNode === "function";
}

@@ -956,3 +956,3 @@ function fnNameFor(func) {

if (actualCall)
methodCall += diff(callArg, actualCall, { showLegend: false });
methodCall += diff(actualCall, callArg, { showLegend: false });
else

@@ -978,3 +978,3 @@ methodCall += stringify(callArg).split("\n").map((line) => ` ${line}`).join("\n");

if (actualReturn)
methodCall += diff(callReturn.value, actualReturn, { showLegend: false });
methodCall += diff(actualReturn, callReturn.value, { showLegend: false });
else

@@ -981,0 +981,0 @@ methodCall += stringify(callReturn).split("\n").map((line) => ` ${line}`).join("\n");

{
"name": "@vitest/expect",
"type": "module",
"version": "0.30.1",
"version": "0.31.0",
"description": "Jest's expect matchers as a Chai plugin",
"license": "MIT",
"funding": "https://opencollective.com/vitest",
"homepage": "https://github.com/vitest-dev/vitest/tree/main/packages/expect#readme",
"repository": {

@@ -12,2 +14,5 @@ "type": "git",

},
"bugs": {
"url": "https://github.com/vitest-dev/vitest/issues"
},
"sideEffects": false,

@@ -29,4 +34,4 @@ "exports": {

"chai": "^4.3.7",
"@vitest/spy": "0.30.1",
"@vitest/utils": "0.30.1"
"@vitest/spy": "0.31.0",
"@vitest/utils": "0.31.0"
},

@@ -33,0 +38,0 @@ "devDependencies": {

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