@vitest/expect 0.31.1 → 0.31.3

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 +12 -10
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -625,7 +625,7 @@ const JestAsymmetricMatchers = (chai, utils) => {
625
625
  };
626
626
 
627
627
  function recordAsyncExpect(test, promise) {
628
- if (test) {
628
+ if (test && promise instanceof Promise) {
629
629
  promise = promise.finally(() => {
630
630
  const index = test.promises.indexOf(promise);
631
631
  if (index !== -1)
@@ -944,20 +944,22 @@ const JestChaiExpect = (chai, utils) => {
944
944
  return `${i}th`;
945
945
  };
946
946
  const formatCalls = (spy, msg, actualCall) => {
947
- msg += c().gray(`
947
+ if (spy.mock.calls) {
948
+ msg += c().gray(`
948
949
 
949
950
  Received:
950
951
  ${spy.mock.calls.map((callArg, i) => {
951
- let methodCall = c().bold(` ${ordinalOf(i + 1)} ${spy.getMockName()} call:
952
+ let methodCall = c().bold(` ${ordinalOf(i + 1)} ${spy.getMockName()} call:
952
953
 
953
954
  `);
954
- if (actualCall)
955
- methodCall += diff(actualCall, callArg, { showLegend: false });
956
- else
957
- methodCall += stringify(callArg).split("\n").map((line) => ` ${line}`).join("\n");
958
- methodCall += "\n";
959
- return methodCall;
960
- }).join("\n")}`);
955
+ if (actualCall)
956
+ methodCall += diff(actualCall, callArg, { showLegend: false });
957
+ else
958
+ methodCall += stringify(callArg).split("\n").map((line) => ` ${line}`).join("\n");
959
+ methodCall += "\n";
960
+ return methodCall;
961
+ }).join("\n")}`);
962
+ }
961
963
  msg += c().gray(`
962
964
 
963
965
  Number of calls: ${c().bold(spy.mock.calls.length)}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vitest/expect",
3
3
  "type": "module",
4
- "version": "0.31.1",
4
+ "version": "0.31.3",
5
5
  "description": "Jest's expect matchers as a Chai plugin",
6
6
  "license": "MIT",
7
7
  "funding": "https://opencollective.com/vitest",
@@ -30,8 +30,8 @@
30
30
  ],
31
31
  "dependencies": {
32
32
  "chai": "^4.3.7",
33
- "@vitest/utils": "0.31.1",
34
- "@vitest/spy": "0.31.1"
33
+ "@vitest/utils": "0.31.3",
34
+ "@vitest/spy": "0.31.3"
35
35
  },
36
36
  "devDependencies": {
37
37
  "picocolors": "^1.0.0"