@vitest/expect 3.1.0 → 3.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +13 -11
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -1570,7 +1570,7 @@ function ordinalOf(i) {
1570
1570
  return `${i}th`;
1571
1571
  }
1572
1572
  function formatCalls(spy, msg, showActualCall) {
1573
- if (spy.mock.calls) {
1573
+ if (spy.mock.calls.length) {
1574
1574
  msg += c.gray(`\n\nReceived: \n\n${spy.mock.calls.map((callArg, i) => {
1575
1575
  let methodCall = c.bold(` ${ordinalOf(i + 1)} ${spy.getMockName()} call:\n\n`);
1576
1576
  if (showActualCall) {
@@ -1586,16 +1586,18 @@ function formatCalls(spy, msg, showActualCall) {
1586
1586
  return msg;
1587
1587
  }
1588
1588
  function formatReturns(spy, results, msg, showActualReturn) {
1589
- msg += c.gray(`\n\nReceived: \n\n${results.map((callReturn, i) => {
1590
- let methodCall = c.bold(` ${ordinalOf(i + 1)} ${spy.getMockName()} call return:\n\n`);
1591
- if (showActualReturn) {
1592
- methodCall += diff(showActualReturn, callReturn.value, { omitAnnotationLines: true });
1593
- } else {
1594
- methodCall += stringify(callReturn).split("\n").map((line) => ` ${line}`).join("\n");
1595
- }
1596
- methodCall += "\n";
1597
- return methodCall;
1598
- }).join("\n")}`);
1589
+ if (results.length) {
1590
+ msg += c.gray(`\n\nReceived: \n\n${results.map((callReturn, i) => {
1591
+ let methodCall = c.bold(` ${ordinalOf(i + 1)} ${spy.getMockName()} call return:\n\n`);
1592
+ if (showActualReturn) {
1593
+ methodCall += diff(showActualReturn, callReturn.value, { omitAnnotationLines: true });
1594
+ } else {
1595
+ methodCall += stringify(callReturn).split("\n").map((line) => ` ${line}`).join("\n");
1596
+ }
1597
+ methodCall += "\n";
1598
+ return methodCall;
1599
+ }).join("\n")}`);
1600
+ }
1599
1601
  msg += c.gray(`\n\nNumber of calls: ${c.bold(spy.mock.calls.length)}\n`);
1600
1602
  return msg;
1601
1603
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vitest/expect",
3
3
  "type": "module",
4
- "version": "3.1.0",
4
+ "version": "3.1.2",
5
5
  "description": "Jest's expect matchers as a Chai plugin",
6
6
  "license": "MIT",
7
7
  "funding": "https://opencollective.com/vitest",
@@ -32,13 +32,13 @@
32
32
  "dependencies": {
33
33
  "chai": "^5.2.0",
34
34
  "tinyrainbow": "^2.0.0",
35
- "@vitest/spy": "3.1.0",
36
- "@vitest/utils": "3.1.0"
35
+ "@vitest/spy": "3.1.2",
36
+ "@vitest/utils": "3.1.2"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@types/chai": "5.0.1",
40
40
  "rollup-plugin-copy": "^3.5.0",
41
- "@vitest/runner": "3.1.0"
41
+ "@vitest/runner": "3.1.2"
42
42
  },
43
43
  "scripts": {
44
44
  "build": "rimraf dist && rollup -c",