vitest 0.0.114 → 0.0.118

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/utils.js CHANGED
@@ -1,4 +1,4 @@
1
- export { e as ensurePackageInstalled, g as getFullName, q as getNames, a as getSuites, y as getTasks, f as getTests, h as hasFailed, w as hasTests, u as interpretOnlyMode, x as isWindows, o as mergeSlashes, n as noop, m as notNullish, v as partitionSuiteChildren, j as resolvePath, s as slash, k as toArray, t as toFilePath } from './index-ea5153a0.js';
1
+ export { l as deepMerge, e as ensurePackageInstalled, g as getFullName, u as getNames, f as getSuites, y as getTasks, j as getTests, h as hasFailed, w as hasTests, i as isObject, x as isWindows, p as mergeSlashes, n as noop, o as notNullish, v as partitionSuiteChildren, k as resolvePath, s as slash, t as toArray, m as toFilePath } from './index-80671389.js';
2
2
  import 'url';
3
3
  import 'tty';
4
4
  import 'local-pkg';
@@ -1,18 +1,7 @@
1
- import { n as noop } from './index-ea5153a0.js';
1
+ import { n as noop, i as isObject } from './index-80671389.js';
2
2
  import { c as commonjsGlobal, g as getDefaultExportFromCjs } from './_commonjsHelpers-c9e3b764.js';
3
3
  import { a as spyOn, f as fn, s as spies } from './jest-mock-4a754991.js';
4
4
 
5
- let urlAlphabet =
6
- 'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict';
7
- let nanoid = (size = 21) => {
8
- let id = '';
9
- let i = size;
10
- while (i--) {
11
- id += urlAlphabet[(Math.random() * 64) | 0];
12
- }
13
- return id
14
- };
15
-
16
5
  var __defProp = Object.defineProperty;
17
6
  var __defProps = Object.defineProperties;
18
7
  var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
@@ -145,7 +134,7 @@ function createSuiteCollector(name, factory = () => {
145
134
  const mode2 = this.only ? "only" : this.skip ? "skip" : this.todo ? "todo" : "run";
146
135
  const computeMode = this.concurrent ? "concurrent" : void 0;
147
136
  const test3 = {
148
- id: nanoid(),
137
+ id: "",
149
138
  type: "test",
150
139
  name: name2,
151
140
  mode: mode2,
@@ -171,7 +160,7 @@ function createSuiteCollector(name, factory = () => {
171
160
  }
172
161
  function initSuite() {
173
162
  suite2 = {
174
- id: nanoid(),
163
+ id: "",
175
164
  type: "suite",
176
165
  computeMode: "serial",
177
166
  name,
@@ -210,7 +199,6 @@ function createSuite() {
210
199
  });
211
200
  }
212
201
 
213
- const isObject = (val) => toString.call(val) === "[object Object]";
214
202
  function equals(a, b, customTesters, strictCheck) {
215
203
  customTesters = customTesters || [];
216
204
  return eq(a, b, [], [], customTesters, strictCheck ? hasKey : hasDefinedKey);
@@ -441,6 +429,31 @@ const subsetEquality = (object, subset) => {
441
429
  };
442
430
  return subsetEqualityWithContext()(object, subset);
443
431
  };
432
+ const typeEquality = (a, b) => {
433
+ if (a == null || b == null || a.constructor === b.constructor)
434
+ return void 0;
435
+ return false;
436
+ };
437
+ const arrayBufferEquality = (a, b) => {
438
+ if (!(a instanceof ArrayBuffer) || !(b instanceof ArrayBuffer))
439
+ return void 0;
440
+ const dataViewA = new DataView(a);
441
+ const dataViewB = new DataView(b);
442
+ if (dataViewA.byteLength !== dataViewB.byteLength)
443
+ return false;
444
+ for (let i = 0; i < dataViewA.byteLength; i++) {
445
+ if (dataViewA.getUint8(i) !== dataViewB.getUint8(i))
446
+ return false;
447
+ }
448
+ return true;
449
+ };
450
+ const sparseArrayEquality = (a, b) => {
451
+ if (!Array.isArray(a) || !Array.isArray(b))
452
+ return void 0;
453
+ const aKeys = Object.keys(a);
454
+ const bKeys = Object.keys(b);
455
+ return equals(a, b, [iterableEquality, typeEquality], true) && equals(aKeys, bKeys);
456
+ };
444
457
 
445
458
  const MATCHERS_OBJECT = Symbol.for("matchers-object");
446
459
  if (!Object.prototype.hasOwnProperty.call(global, MATCHERS_OBJECT)) {
@@ -499,7 +512,7 @@ const JestChaiExpect = (chai, utils) => {
499
512
  return this.eql(expected);
500
513
  });
501
514
  def("toStrictEqual", function(expected) {
502
- return this.chaiEqual(expected);
515
+ return iterableEquality(this, expected) ?? typeEquality(this, expected) ?? sparseArrayEquality(this, expected) ?? arrayBufferEquality(this, expected);
503
516
  });
504
517
  def("toBe", function(expected) {
505
518
  return this.equal(expected);
@@ -1026,4 +1039,4 @@ class VitestUtils {
1026
1039
  const vitest = new VitestUtils();
1027
1040
  const vi = vitest;
1028
1041
 
1029
- export { JestChaiExpect as J, getDefaultHookTimeout as a, getState as b, suite as c, describe as d, vi as e, equals as f, getCurrentSuite as g, iterableEquality as h, it as i, subsetEquality as j, isA as k, clearContext as l, defaultSuite as m, nanoid as n, setHooks as o, getHooks as p, context as q, getFn as r, setState as s, test as t, vitest as v, withTimeout as w };
1042
+ export { JestChaiExpect as J, getDefaultHookTimeout as a, getState as b, suite as c, describe as d, vi as e, equals as f, getCurrentSuite as g, iterableEquality as h, it as i, subsetEquality as j, isA as k, clearContext as l, defaultSuite as m, setHooks as n, getHooks as o, context as p, getFn as q, setState as s, test as t, vitest as v, withTimeout as w };
package/dist/worker.js CHANGED
@@ -1,6 +1,6 @@
1
- import { j as resolve, d as dirname$2, b as basename$2, o as mergeSlashes, s as slash, t as toFilePath } from './index-ea5153a0.js';
2
- import { c as createBirpc } from './index-7889832e.js';
3
- import { c as distDir } from './constants-9c7f06df.js';
1
+ import { k as resolve, d as dirname$2, b as basename$2, p as mergeSlashes, s as slash, m as toFilePath } from './index-80671389.js';
2
+ import { c as createBirpc } from './index-e909c175.js';
3
+ import { c as distDir } from './constants-56bfb5ab.js';
4
4
  import { builtinModules, createRequire } from 'module';
5
5
  import { pathToFileURL, fileURLToPath as fileURLToPath$2, URL as URL$1 } from 'url';
6
6
  import vm from 'vm';
@@ -9,7 +9,7 @@ import fs, { promises, realpathSync, statSync, Stats, existsSync, readdirSync }
9
9
  import assert from 'assert';
10
10
  import { format as format$2, inspect } from 'util';
11
11
  import { a as spyOn, s as spies } from './jest-mock-4a754991.js';
12
- import { s as send } from './rpc-85fe6402.js';
12
+ import { r as rpc } from './rpc-8c7cc374.js';
13
13
  import 'tty';
14
14
  import 'local-pkg';
15
15
  import 'chai';
@@ -9561,10 +9561,10 @@ async function startViteNode(ctx) {
9561
9561
  return _viteNode;
9562
9562
  const processExit = process.exit;
9563
9563
  process.on("beforeExit", (code) => {
9564
- send("processExit", code);
9564
+ rpc().onWorkerExit(code);
9565
9565
  });
9566
9566
  process.exit = (code = process.exitCode || 0) => {
9567
- send("processExit", code);
9567
+ rpc().onWorkerExit(code);
9568
9568
  return processExit(code);
9569
9569
  };
9570
9570
  const { config } = ctx;
@@ -9574,7 +9574,7 @@ async function startViteNode(ctx) {
9574
9574
  resolve(distDir, "entry.js")
9575
9575
  ],
9576
9576
  fetch(id) {
9577
- return process.__vitest_worker__.rpc.call("fetch", id);
9577
+ return rpc().fetch(id);
9578
9578
  },
9579
9579
  inline: config.depsInline,
9580
9580
  external: config.depsExternal,
@@ -9596,6 +9596,7 @@ function init(ctx) {
9596
9596
  config,
9597
9597
  rpc: createBirpc({
9598
9598
  functions: {},
9599
+ eventNames: ["onUserLog", "onCollected", "onWorkerExit"],
9599
9600
  post(v) {
9600
9601
  port.postMessage(v);
9601
9602
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vitest",
3
- "version": "0.0.114",
3
+ "version": "0.0.118",
4
4
  "description": "A blazing fast unit test framework powered by Vite",
5
5
  "keywords": [
6
6
  "vite",
@@ -60,14 +60,15 @@
60
60
  "@types/jsdom": "^16.2.14",
61
61
  "@types/micromatch": "^4.0.2",
62
62
  "@types/natural-compare": "^1.4.1",
63
- "@types/node": "^17.0.4",
63
+ "@types/node": "^17.0.5",
64
64
  "@types/prompts": "^2.4.0",
65
- "birpc": "^0.0.0",
65
+ "birpc": "^0.0.2",
66
66
  "c8": "^7.10.0",
67
67
  "cac": "^6.7.12",
68
68
  "chai-subset": "^1.6.0",
69
69
  "cli-truncate": "^3.1.0",
70
70
  "diff": "^5.0.0",
71
+ "execa": "^6.0.0",
71
72
  "fast-glob": "^3.2.7",
72
73
  "find-up": "^6.2.0",
73
74
  "flatted": "^3.2.4",
@@ -78,7 +79,6 @@
78
79
  "micromatch": "^4.0.4",
79
80
  "mlly": "^0.3.16",
80
81
  "mockdate": "^3.0.5",
81
- "nanoid": "^3.1.30",
82
82
  "natural-compare": "^1.4.0",
83
83
  "pathe": "^0.2.0",
84
84
  "picocolors": "^1.0.0",
@@ -88,7 +88,8 @@
88
88
  "rollup": "^2.62.0",
89
89
  "source-map-js": "^1.0.1",
90
90
  "strip-ansi": "^7.0.1",
91
- "typescript": "^4.5.4"
91
+ "typescript": "^4.5.4",
92
+ "ws": "^8.4.0"
92
93
  },
93
94
  "peerDependencies": {
94
95
  "c8": "*",
@@ -112,8 +113,7 @@
112
113
  },
113
114
  "scripts": {
114
115
  "build": "rimraf dist && rollup -c",
115
- "dev": "rollup -c --watch src",
116
- "typecheck": "tsc --noEmit"
116
+ "dev": "rollup -c --watch src"
117
117
  },
118
118
  "readme": "# vitest\n\n[![NPM version](https://img.shields.io/npm/v/vitest?color=a1b858&label=)](https://www.npmjs.com/package/vitest)\n\nA blazing fast unit test framework powered by Vite.\n\n> **This project is currently in closed beta exclusively for Sponsors.**<br>\n> Become a Sponsor of [@patak-dev](https://github.com/sponsors/patak-dev) or [@antfu](https://github.com/sponsors/antfu) to access the source code and issues tracker.\n> Learn more at [vitest.dev](https://vitest.dev)\n"
119
119
  }
package/vitest.mjs CHANGED
@@ -1,21 +1,2 @@
1
1
  #!/usr/bin/env node
2
-
3
- import { fileURLToPath } from 'url'
4
- import { ensurePackageInstalled, resolvePath } from './dist/utils.js'
5
-
6
- const argv = process.argv.slice(2)
7
-
8
- if (!await ensurePackageInstalled('vite'))
9
- process.exit(1)
10
-
11
- if (argv.includes('--coverage')) {
12
- if (!await ensurePackageInstalled('c8'))
13
- process.exit(1)
14
- const filename = fileURLToPath(import.meta.url)
15
- const entry = resolvePath(filename, '../dist/cli.js')
16
- process.argv.splice(2, 0, process.argv[0], entry)
17
- await import('c8/bin/c8.js')
18
- }
19
- else {
20
- await import('./dist/cli.js')
21
- }
2
+ import('./dist/cli.js')
@@ -1,81 +0,0 @@
1
- import { A as API_PATH } from './constants-9c7f06df.js';
2
- import 'url';
3
- import './index-ea5153a0.js';
4
- import 'tty';
5
- import 'local-pkg';
6
- import 'path';
7
-
8
- /*! (c) 2020 Andrea Giammarchi */
9
-
10
- const {parse: $parse, stringify: $stringify} = JSON;
11
-
12
- const Primitive = String; // it could be Number
13
- const primitive = 'string'; // it could be 'number'
14
- const object = 'object';
15
-
16
- const noop = (_, value) => value;
17
-
18
- const set = (known, input, value) => {
19
- const index = Primitive(input.push(value) - 1);
20
- known.set(value, index);
21
- return index;
22
- };
23
-
24
- const stringify = (value, replacer, space) => {
25
- const $ = replacer && typeof replacer === object ?
26
- (k, v) => (k === '' || -1 < replacer.indexOf(k) ? v : void 0) :
27
- (replacer || noop);
28
- const known = new Map;
29
- const input = [];
30
- const output = [];
31
- let i = +set(known, input, $.call({'': value}, '', value));
32
- let firstRun = !i;
33
- while (i < input.length) {
34
- firstRun = true;
35
- output[i] = $stringify(input[i++], replace, space);
36
- }
37
- return '[' + output.join(',') + ']';
38
- function replace(key, value) {
39
- if (firstRun) {
40
- firstRun = !firstRun;
41
- return value;
42
- }
43
- const after = $.call(this, key, value);
44
- switch (typeof after) {
45
- case object:
46
- if (after === null) return after;
47
- case primitive:
48
- return known.get(after) || set(known, input, after);
49
- }
50
- return after;
51
- }
52
- };
53
-
54
- function sendFlatted(res, data) {
55
- res.setHeader("Content-Type", "application/json");
56
- res.write(stringify(data));
57
- res.statusCode = 200;
58
- res.end();
59
- }
60
- function middlewareAPI(ctx) {
61
- return (req, res, next) => {
62
- var _a;
63
- if (!((_a = req.url) == null ? void 0 : _a.startsWith(API_PATH)))
64
- return next();
65
- const url = req.url.slice(API_PATH.length);
66
- if (url === "/") {
67
- return sendFlatted(res, {
68
- files: ctx.state.filesMap
69
- });
70
- }
71
- if (url === "/files") {
72
- return sendFlatted(res, {
73
- files: Object.keys(ctx.state.filesMap)
74
- });
75
- }
76
- res.statusCode = 404;
77
- res.end();
78
- };
79
- }
80
-
81
- export { middlewareAPI as default, sendFlatted };
@@ -1,10 +0,0 @@
1
- const rpc = (method, ...args) => {
2
- var _a;
3
- return (_a = process.__vitest_worker__) == null ? void 0 : _a.rpc.call(method, ...args);
4
- };
5
- const send = (method, ...args) => {
6
- var _a;
7
- return (_a = process.__vitest_worker__) == null ? void 0 : _a.rpc.send(method, ...args);
8
- };
9
-
10
- export { rpc as r, send as s };