@vitest/expect 0.32.2 → 0.32.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 +14 -10
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -164,8 +164,11 @@ function eq(a, b, aStack, bStack, customTesters, hasKey2) {
164
164
  } else {
165
165
  return Object.is(a.valueOf(), b.valueOf());
166
166
  }
167
- case "[object Date]":
168
- return isNaN(a) && isNaN(b) || +a === +b;
167
+ case "[object Date]": {
168
+ const numA = +a;
169
+ const numB = +b;
170
+ return numA === numB || Number.isNaN(numA) && Number.isNaN(numB);
171
+ }
169
172
  case "[object RegExp]":
170
173
  return a.source === b.source && a.flags === b.flags;
171
174
  }
@@ -403,9 +406,9 @@ class AsymmetricMatcher {
403
406
  constructor(sample, inverse = false) {
404
407
  this.sample = sample;
405
408
  this.inverse = inverse;
406
- // should have "jest" to be compatible with its ecosystem
407
- this.$$typeof = Symbol.for("jest.asymmetricMatcher");
408
409
  }
410
+ // should have "jest" to be compatible with its ecosystem
411
+ $$typeof = Symbol.for("jest.asymmetricMatcher");
409
412
  getMatcherContext(expect) {
410
413
  return {
411
414
  ...getState(expect || globalThis[GLOBAL_EXPECT]),
@@ -929,9 +932,9 @@ const JestChaiExpect = (chai, utils) => {
929
932
  let pass = false;
930
933
  let expectedDiff = 0;
931
934
  let receivedDiff = 0;
932
- if (received === Infinity && expected === Infinity) {
935
+ if (received === Number.POSITIVE_INFINITY && expected === Number.POSITIVE_INFINITY) {
933
936
  pass = true;
934
- } else if (received === -Infinity && expected === -Infinity) {
937
+ } else if (received === Number.NEGATIVE_INFINITY && expected === Number.NEGATIVE_INFINITY) {
935
938
  pass = true;
936
939
  } else {
937
940
  expectedDiff = 10 ** -precision / 2;
@@ -1018,7 +1021,7 @@ Number of calls: ${c().bold(spy.mock.calls.length)}
1018
1021
  const callCount = spy.mock.calls.length;
1019
1022
  return this.assert(
1020
1023
  callCount === number,
1021
- `expected "${spyName}" to be called #{exp} times`,
1024
+ `expected "${spyName}" to be called #{exp} times, but got ${callCount} times`,
1022
1025
  `expected "${spyName}" to not be called #{exp} times`,
1023
1026
  number,
1024
1027
  callCount,
@@ -1031,7 +1034,7 @@ Number of calls: ${c().bold(spy.mock.calls.length)}
1031
1034
  const callCount = spy.mock.calls.length;
1032
1035
  return this.assert(
1033
1036
  callCount === 1,
1034
- `expected "${spyName}" to be called once`,
1037
+ `expected "${spyName}" to be called once, but got ${callCount} times`,
1035
1038
  `expected "${spyName}" to not be called once`,
1036
1039
  1,
1037
1040
  callCount,
@@ -1041,14 +1044,15 @@ Number of calls: ${c().bold(spy.mock.calls.length)}
1041
1044
  def(["toHaveBeenCalled", "toBeCalled"], function() {
1042
1045
  const spy = getSpy(this);
1043
1046
  const spyName = spy.getMockName();
1044
- const called = spy.mock.calls.length > 0;
1047
+ const callCount = spy.mock.calls.length;
1048
+ const called = callCount > 0;
1045
1049
  const isNot = utils.flag(this, "negate");
1046
1050
  let msg = utils.getMessage(
1047
1051
  this,
1048
1052
  [
1049
1053
  called,
1050
1054
  `expected "${spyName}" to be called at least once`,
1051
- `expected "${spyName}" to not be called at all`,
1055
+ `expected "${spyName}" to not be called at all, but actually been called ${callCount} times`,
1052
1056
  true,
1053
1057
  called
1054
1058
  ]
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vitest/expect",
3
3
  "type": "module",
4
- "version": "0.32.2",
4
+ "version": "0.32.3",
5
5
  "description": "Jest's expect matchers as a Chai plugin",
6
6
  "license": "MIT",
7
7
  "funding": "https://opencollective.com/vitest",
@@ -30,12 +30,12 @@
30
30
  ],
31
31
  "dependencies": {
32
32
  "chai": "^4.3.7",
33
- "@vitest/utils": "0.32.2",
34
- "@vitest/spy": "0.32.2"
33
+ "@vitest/spy": "0.32.3",
34
+ "@vitest/utils": "0.32.3"
35
35
  },
36
36
  "devDependencies": {
37
37
  "picocolors": "^1.0.0",
38
- "@vitest/runner": "0.32.2"
38
+ "@vitest/runner": "0.32.3"
39
39
  },
40
40
  "scripts": {
41
41
  "build": "rimraf dist && rollup -c",