Socket
Socket
Sign inDemoInstall

@vitest/expect

Package Overview
Dependencies
Maintainers
4
Versions
95
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.1.0-beta.6 to 2.1.0-beta.7

168

dist/index.js

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

});
const assertIsMock = (assertion) => {
function assertIsMock(assertion) {
if (!isMockFunction(assertion._obj)) {

@@ -1326,85 +1326,7 @@ throw new TypeError(

}
};
const getSpy = (assertion) => {
}
function getSpy(assertion) {
assertIsMock(assertion);
return assertion._obj;
};
const ordinalOf = (i) => {
const j = i % 10;
const k = i % 100;
if (j === 1 && k !== 11) {
return `${i}st`;
}
if (j === 2 && k !== 12) {
return `${i}nd`;
}
if (j === 3 && k !== 13) {
return `${i}rd`;
}
return `${i}th`;
};
const formatCalls = (spy, msg, showActualCall) => {
if (spy.mock.calls) {
msg += c.gray(
`
Received:
${spy.mock.calls.map((callArg, i) => {
let methodCall = c.bold(
` ${ordinalOf(i + 1)} ${spy.getMockName()} call:
`
);
if (showActualCall) {
methodCall += diff(showActualCall, callArg, {
omitAnnotationLines: true
});
} else {
methodCall += stringify(callArg).split("\n").map((line) => ` ${line}`).join("\n");
}
methodCall += "\n";
return methodCall;
}).join("\n")}`
);
}
msg += c.gray(
`
Number of calls: ${c.bold(spy.mock.calls.length)}
`
);
return msg;
};
const formatReturns = (spy, results, msg, showActualReturn) => {
msg += c.gray(
`
Received:
${results.map((callReturn, i) => {
let methodCall = c.bold(
` ${ordinalOf(i + 1)} ${spy.getMockName()} call return:
`
);
if (showActualReturn) {
methodCall += diff(showActualReturn, callReturn.value, {
omitAnnotationLines: true
});
} else {
methodCall += stringify(callReturn).split("\n").map((line) => ` ${line}`).join("\n");
}
methodCall += "\n";
return methodCall;
}).join("\n")}`
);
msg += c.gray(
`
Number of calls: ${c.bold(spy.mock.calls.length)}
`
);
return msg;
};
}
def(["toHaveBeenCalledTimes", "toBeCalledTimes"], function(number) {

@@ -1772,3 +1694,3 @@ const spy = getSpy(this);

}
return async (...args) => {
return (...args) => {
const promise = obj.then(

@@ -1827,3 +1749,3 @@ (value) => {

}
return async (...args) => {
return (...args) => {
const promise = wrapper.then(

@@ -1860,3 +1782,81 @@ (value) => {

};
function ordinalOf(i) {
const j = i % 10;
const k = i % 100;
if (j === 1 && k !== 11) {
return `${i}st`;
}
if (j === 2 && k !== 12) {
return `${i}nd`;
}
if (j === 3 && k !== 13) {
return `${i}rd`;
}
return `${i}th`;
}
function formatCalls(spy, msg, showActualCall) {
if (spy.mock.calls) {
msg += c.gray(
`
Received:
${spy.mock.calls.map((callArg, i) => {
let methodCall = c.bold(
` ${ordinalOf(i + 1)} ${spy.getMockName()} call:
`
);
if (showActualCall) {
methodCall += diff(showActualCall, callArg, {
omitAnnotationLines: true
});
} else {
methodCall += stringify(callArg).split("\n").map((line) => ` ${line}`).join("\n");
}
methodCall += "\n";
return methodCall;
}).join("\n")}`
);
}
msg += c.gray(
`
Number of calls: ${c.bold(spy.mock.calls.length)}
`
);
return msg;
}
function formatReturns(spy, results, msg, showActualReturn) {
msg += c.gray(
`
Received:
${results.map((callReturn, i) => {
let methodCall = c.bold(
` ${ordinalOf(i + 1)} ${spy.getMockName()} call return:
`
);
if (showActualReturn) {
methodCall += diff(showActualReturn, callReturn.value, {
omitAnnotationLines: true
});
} else {
methodCall += stringify(callReturn).split("\n").map((line) => ` ${line}`).join("\n");
}
methodCall += "\n";
return methodCall;
}).join("\n")}`
);
msg += c.gray(
`
Number of calls: ${c.bold(spy.mock.calls.length)}
`
);
return msg;
}
function getMatcherState(assertion, expect) {

@@ -1863,0 +1863,0 @@ const obj = assertion._obj;

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

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

"tinyrainbow": "^1.2.0",
"@vitest/utils": "2.1.0-beta.6",
"@vitest/spy": "2.1.0-beta.6"
"@vitest/utils": "2.1.0-beta.7",
"@vitest/spy": "2.1.0-beta.7"
},

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

"rollup-plugin-copy": "^3.5.0",
"@vitest/runner": "2.1.0-beta.6"
"@vitest/runner": "2.1.0-beta.7"
},

@@ -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