Socket
Socket
Sign inDemoInstall

@vitest/expect

Package Overview
Dependencies
Maintainers
4
Versions
97
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 2.0.0-beta.2 to 2.0.0-beta.3

13

dist/index.d.ts

@@ -68,2 +68,3 @@ import * as _vitest_utils from '@vitest/utils';

soft?: boolean;
poll?: boolean;
}

@@ -84,8 +85,3 @@ interface SyncExpectationResult {

<T>(actual: T, message?: string): Assertion<T>;
unreachable: (message?: string) => never;
soft: <T>(actual: T, message?: string) => Assertion<T>;
extend: (expects: MatchersObject) => void;
addEqualityTesters: (testers: Array<Tester>) => void;
assertions: (expected: number) => void;
hasAssertions: () => void;
anything: () => any;

@@ -155,2 +151,3 @@ any: (constructor: unknown) => any;

};
type PromisifyAssertion<T> = Promisify<Assertion<T>>;
interface Assertion<T = any> extends VitestAssertion<Chai.Assertion, T>, JestAssertion<T> {

@@ -160,4 +157,4 @@ toBeTypeOf: (expected: 'bigint' | 'boolean' | 'function' | 'number' | 'object' | 'string' | 'symbol' | 'undefined') => void;

toSatisfy: <E>(matcher: (value: E) => boolean, message?: string) => void;
resolves: Promisify<Assertion<T>>;
rejects: Promisify<Assertion<T>>;
resolves: PromisifyAssertion<T>;
rejects: PromisifyAssertion<T>;
}

@@ -262,2 +259,2 @@ declare global {

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

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

return func.name;
const matches = functionToString.call(func).match(/^(?:async)?\s*function\s*\*?\s*([\w$]+)\s*\(/);
const matches = functionToString.call(func).match(/^(?:async)?\s*function\s*(?:\*\s*)?([\w$]+)\s*\(/);
return matches ? matches[1] : "<anonymous>";

@@ -665,3 +665,3 @@ }

const functionToString = Function.prototype.toString;
const matches = functionToString.call(func).match(/^(?:async)?\s*function\s*\*?\s*([\w$]+)\s*\(/);
const matches = functionToString.call(func).match(/^(?:async)?\s*function\s*(?:\*\s*)?([\w$]+)\s*\(/);
return matches ? matches[1] : "<anonymous>";

@@ -822,6 +822,5 @@ }

var _a;
if (!utils.flag(this, "soft"))
return fn.apply(this, args);
const test = utils.flag(this, "vitest-test");
const state = (test == null ? void 0 : test.context._local) ? test.context.expect.getState() : getState(globalThis[GLOBAL_EXPECT]);
if (!state.soft)
return fn.apply(this, args);
if (!test)

@@ -1490,2 +1489,7 @@ throw new Error("expect.soft() can only be used inside a test");

});
def("withContext", function(context) {
for (const key in context)
utils.flag(this, key, context[key]);
return this;
});
utils.addProperty(chai.Assertion.prototype, "resolves", function __VITEST_RESOLVES__() {

@@ -1497,2 +1501,4 @@ const error = new Error("resolves");

const obj = utils.flag(this, "object");
if (utils.flag(this, "poll"))
throw new SyntaxError(`expect.poll() is not supported in combination with .resolves`);
if (typeof (obj == null ? void 0 : obj.then) !== "function")

@@ -1534,2 +1540,4 @@ throw new TypeError(`You must provide a Promise to expect() when using .resolves, not '${typeof obj}'.`);

const wrapper = typeof obj === "function" ? obj() : obj;
if (utils.flag(this, "poll"))
throw new SyntaxError(`expect.poll() is not supported in combination with .rejects`);
if (typeof (wrapper == null ? void 0 : wrapper.then) !== "function")

@@ -1584,3 +1592,5 @@ throw new TypeError(`You must provide a Promise to expect() when using .rejects, not '${typeof wrapper}'.`);

// needed for built-in jest-snapshots, but we don't use it
suppressedErrors: []
suppressedErrors: [],
soft: util.flag(assertion, "soft"),
poll: util.flag(assertion, "poll")
};

@@ -1587,0 +1597,0 @@ return {

{
"name": "@vitest/expect",
"type": "module",
"version": "2.0.0-beta.2",
"version": "2.0.0-beta.3",
"description": "Jest's expect matchers as a Chai plugin",

@@ -34,4 +34,4 @@ "license": "MIT",

"chai": "^5.1.1",
"@vitest/utils": "2.0.0-beta.2",
"@vitest/spy": "2.0.0-beta.2"
"@vitest/spy": "2.0.0-beta.3",
"@vitest/utils": "2.0.0-beta.3"
},

@@ -42,3 +42,3 @@ "devDependencies": {

"rollup-plugin-copy": "^3.5.0",
"@vitest/runner": "2.0.0-beta.2"
"@vitest/runner": "2.0.0-beta.3"
},

@@ -45,0 +45,0 @@ "scripts": {

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