@vitest/expect 2.0.1 → 2.0.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.
package/dist/index.d.ts CHANGED
@@ -1,17 +1,15 @@
1
- import * as _vitest_utils from '@vitest/utils';
1
+ import * as tinyrainbow from 'tinyrainbow';
2
+ import { Formatter } from 'tinyrainbow';
2
3
  import { stringify, Constructable } from '@vitest/utils';
3
- export { setupColors } from '@vitest/utils';
4
4
  import { diff } from '@vitest/utils/diff';
5
5
  export { DiffOptions } from '@vitest/utils/diff';
6
6
 
7
- type Formatter = (input: string | number | null | undefined) => string;
8
-
9
7
  declare function getMatcherUtils(): {
10
- EXPECTED_COLOR: _vitest_utils.ColorMethod;
11
- RECEIVED_COLOR: _vitest_utils.ColorMethod;
12
- INVERTED_COLOR: _vitest_utils.ColorMethod;
13
- BOLD_WEIGHT: _vitest_utils.ColorMethod;
14
- DIM_COLOR: _vitest_utils.ColorMethod;
8
+ EXPECTED_COLOR: tinyrainbow.Formatter;
9
+ RECEIVED_COLOR: tinyrainbow.Formatter;
10
+ INVERTED_COLOR: tinyrainbow.Formatter;
11
+ BOLD_WEIGHT: tinyrainbow.Formatter;
12
+ DIM_COLOR: tinyrainbow.Formatter;
15
13
  matcherHint: (matcherName: string, received?: string, expected?: string, options?: MatcherHintOptions) => string;
16
14
  printReceived: (object: unknown) => string;
17
15
  printExpected: (value: unknown) => string;
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { getType, getColors, stringify, isObject, assertTypes } from '@vitest/utils';
2
- export { setupColors } from '@vitest/utils';
1
+ import { getType, stringify, isObject, assertTypes } from '@vitest/utils';
2
+ import c from 'tinyrainbow';
3
3
  import { diff } from '@vitest/utils/diff';
4
4
  import { isMockFunction } from '@vitest/spy';
5
5
  import { processError } from '@vitest/utils/error';
@@ -43,12 +43,11 @@ function setState(state, expect) {
43
43
  }
44
44
 
45
45
  function getMatcherUtils() {
46
- const c = () => getColors();
47
- const EXPECTED_COLOR = c().green;
48
- const RECEIVED_COLOR = c().red;
49
- const INVERTED_COLOR = c().inverse;
50
- const BOLD_WEIGHT = c().bold;
51
- const DIM_COLOR = c().dim;
46
+ const EXPECTED_COLOR = c.green;
47
+ const RECEIVED_COLOR = c.red;
48
+ const INVERTED_COLOR = c.inverse;
49
+ const BOLD_WEIGHT = c.bold;
50
+ const DIM_COLOR = c.dim;
52
51
  function matcherHint(matcherName, received = "received", expected = "expected", options = {}) {
53
52
  const {
54
53
  comment = "",
@@ -929,7 +928,6 @@ function wrapSoft(utils, fn) {
929
928
 
930
929
  const JestChaiExpect = (chai, utils) => {
931
930
  const { AssertionError } = chai;
932
- const c = () => getColors();
933
931
  const customTesters = getCustomEqualityTesters();
934
932
  function def(name, fn) {
935
933
  const addMethod = (n) => {
@@ -1337,13 +1335,13 @@ const JestChaiExpect = (chai, utils) => {
1337
1335
  };
1338
1336
  const formatCalls = (spy, msg, showActualCall) => {
1339
1337
  if (spy.mock.calls) {
1340
- msg += c().gray(
1338
+ msg += c.gray(
1341
1339
  `
1342
1340
 
1343
1341
  Received:
1344
1342
 
1345
1343
  ${spy.mock.calls.map((callArg, i) => {
1346
- let methodCall = c().bold(
1344
+ let methodCall = c.bold(
1347
1345
  ` ${ordinalOf(i + 1)} ${spy.getMockName()} call:
1348
1346
 
1349
1347
  `
@@ -1360,22 +1358,22 @@ ${spy.mock.calls.map((callArg, i) => {
1360
1358
  }).join("\n")}`
1361
1359
  );
1362
1360
  }
1363
- msg += c().gray(
1361
+ msg += c.gray(
1364
1362
  `
1365
1363
 
1366
- Number of calls: ${c().bold(spy.mock.calls.length)}
1364
+ Number of calls: ${c.bold(spy.mock.calls.length)}
1367
1365
  `
1368
1366
  );
1369
1367
  return msg;
1370
1368
  };
1371
1369
  const formatReturns = (spy, results, msg, showActualReturn) => {
1372
- msg += c().gray(
1370
+ msg += c.gray(
1373
1371
  `
1374
1372
 
1375
1373
  Received:
1376
1374
 
1377
1375
  ${results.map((callReturn, i) => {
1378
- let methodCall = c().bold(
1376
+ let methodCall = c.bold(
1379
1377
  ` ${ordinalOf(i + 1)} ${spy.getMockName()} call return:
1380
1378
 
1381
1379
  `
@@ -1391,10 +1389,10 @@ ${results.map((callReturn, i) => {
1391
1389
  return methodCall;
1392
1390
  }).join("\n")}`
1393
1391
  );
1394
- msg += c().gray(
1392
+ msg += c.gray(
1395
1393
  `
1396
1394
 
1397
- Number of calls: ${c().bold(spy.mock.calls.length)}
1395
+ Number of calls: ${c.bold(spy.mock.calls.length)}
1398
1396
  `
1399
1397
  );
1400
1398
  return msg;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vitest/expect",
3
3
  "type": "module",
4
- "version": "2.0.1",
4
+ "version": "2.0.2",
5
5
  "description": "Jest's expect matchers as a Chai plugin",
6
6
  "license": "MIT",
7
7
  "funding": "https://opencollective.com/vitest",
@@ -31,14 +31,14 @@
31
31
  ],
32
32
  "dependencies": {
33
33
  "chai": "^5.1.1",
34
- "@vitest/spy": "2.0.1",
35
- "@vitest/utils": "2.0.1"
34
+ "tinyrainbow": "^1.2.0",
35
+ "@vitest/spy": "2.0.2",
36
+ "@vitest/utils": "2.0.2"
36
37
  },
37
38
  "devDependencies": {
38
39
  "@types/chai": "4.3.6",
39
- "picocolors": "^1.0.1",
40
40
  "rollup-plugin-copy": "^3.5.0",
41
- "@vitest/runner": "2.0.1"
41
+ "@vitest/runner": "2.0.2"
42
42
  },
43
43
  "scripts": {
44
44
  "build": "rimraf dist && rollup -c",