vitest 0.17.0 → 0.18.1

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 (31) hide show
  1. package/LICENSE.md +1 -1
  2. package/dist/{chunk-api-setup.5282c6cb.mjs → chunk-api-setup.9d3f7670.mjs} +18 -9
  3. package/dist/{chunk-constants.511c6e9b.mjs → chunk-constants.d4406290.mjs} +1 -1
  4. package/dist/{chunk-env-node.dc514f41.mjs → chunk-env-node.bbba78e5.mjs} +9 -3
  5. package/dist/{chunk-install-pkg.3fa50769.mjs → chunk-install-pkg.2dcb2c04.mjs} +1 -1
  6. package/dist/chunk-integrations-globals.00b6e1ad.mjs +23 -0
  7. package/dist/{chunk-runtime-chain.68f305d0.mjs → chunk-runtime-chain.b60d57da.mjs} +39 -60
  8. package/dist/{chunk-runtime-mocker.1c207219.mjs → chunk-runtime-mocker.1d853e3a.mjs} +77 -29
  9. package/dist/{chunk-runtime-rpc.5e78af38.mjs → chunk-runtime-rpc.9d1f4c48.mjs} +1 -1
  10. package/dist/{chunk-utils-global.79a8b1cc.mjs → chunk-utils-global.0a7416cf.mjs} +70 -6
  11. package/dist/{chunk-utils-source-map.f52527bc.mjs → chunk-utils-source-map.c03f8bc4.mjs} +2 -2
  12. package/dist/{chunk-vite-node-externalize.1efbe319.mjs → chunk-vite-node-externalize.6956d2d9.mjs} +2666 -2552
  13. package/dist/chunk-vite-node-utils.8077cd3c.mjs +1422 -0
  14. package/dist/cli.mjs +13 -13
  15. package/dist/config.cjs +6 -1
  16. package/dist/config.d.ts +1 -1
  17. package/dist/config.mjs +6 -1
  18. package/dist/entry.mjs +638 -11
  19. package/dist/index.d.ts +125 -52
  20. package/dist/index.mjs +8 -8
  21. package/dist/node.d.ts +126 -54
  22. package/dist/node.mjs +13 -13
  23. package/dist/spy.mjs +102 -2
  24. package/dist/{vendor-index.e5dc6622.mjs → vendor-index.4bf9c627.mjs} +405 -405
  25. package/dist/{vendor-index.98e769c1.mjs → vendor-index.de788b6a.mjs} +7 -7
  26. package/dist/worker.mjs +9 -9
  27. package/package.json +12 -12
  28. package/dist/chunk-integrations-globals.6bb781c7.mjs +0 -26
  29. package/dist/chunk-integrations-spy.674b628e.mjs +0 -102
  30. package/dist/chunk-vite-node-utils.4b58ae05.mjs +0 -9192
  31. package/dist/vendor-entry.2edaf3e0.mjs +0 -653
@@ -1,4 +1,4 @@
1
- import readline from 'readline';
1
+ import require$$0 from 'readline';
2
2
  import require$$2 from 'events';
3
3
 
4
4
  function _mergeNamespaces(n, m) {
@@ -508,7 +508,7 @@ function requirePrompt$1 () {
508
508
  if (hasRequiredPrompt$1) return prompt$1;
509
509
  hasRequiredPrompt$1 = 1;
510
510
 
511
- const readline$1 = readline;
511
+ const readline = require$$0;
512
512
 
513
513
  const _require = requireUtil$1(),
514
514
  action = _require.action;
@@ -536,11 +536,11 @@ function requirePrompt$1 () {
536
536
 
537
537
  this.onRender = (opts.onRender || (() => void 0)).bind(this);
538
538
 
539
- const rl = readline$1.createInterface({
539
+ const rl = readline.createInterface({
540
540
  input: this.in,
541
541
  escapeCodeTimeout: 50
542
542
  });
543
- readline$1.emitKeypressEvents(this.in, rl);
543
+ readline.emitKeypressEvents(this.in, rl);
544
544
  if (this.in.isTTY) this.in.setRawMode(true);
545
545
  const isSelect = ['SelectPrompt', 'MultiselectPrompt'].indexOf(this.constructor.name) > -1;
546
546
 
@@ -3673,7 +3673,7 @@ function requirePrompt () {
3673
3673
  if (hasRequiredPrompt) return prompt;
3674
3674
  hasRequiredPrompt = 1;
3675
3675
 
3676
- const readline$1 = readline;
3676
+ const readline = require$$0;
3677
3677
  const { action } = requireUtil();
3678
3678
  const EventEmitter = require$$2;
3679
3679
  const { beep, cursor } = requireSrc();
@@ -3692,8 +3692,8 @@ function requirePrompt () {
3692
3692
  this.in = opts.stdin || process.stdin;
3693
3693
  this.out = opts.stdout || process.stdout;
3694
3694
  this.onRender = (opts.onRender || (() => void 0)).bind(this);
3695
- const rl = readline$1.createInterface({ input:this.in, escapeCodeTimeout:50 });
3696
- readline$1.emitKeypressEvents(this.in, rl);
3695
+ const rl = readline.createInterface({ input:this.in, escapeCodeTimeout:50 });
3696
+ readline.emitKeypressEvents(this.in, rl);
3697
3697
 
3698
3698
  if (this.in.isTTY) this.in.setRawMode(true);
3699
3699
  const isSelect = [ 'SelectPrompt', 'MultiselectPrompt' ].indexOf(this.constructor.name) > -1;
package/dist/worker.mjs CHANGED
@@ -1,12 +1,12 @@
1
- import { m as resolve, a as getWorkerState } from './chunk-utils-global.79a8b1cc.mjs';
2
- import { c as createBirpc, M as ModuleCacheMap } from './chunk-vite-node-utils.4b58ae05.mjs';
1
+ import { q as resolve, a as getWorkerState } from './chunk-utils-global.0a7416cf.mjs';
2
+ import { c as createBirpc, M as ModuleCacheMap } from './chunk-vite-node-utils.8077cd3c.mjs';
3
3
  import { workerId } from 'tinypool';
4
- import { d as distDir } from './chunk-constants.511c6e9b.mjs';
5
- import { e as executeInViteNode } from './chunk-runtime-mocker.1c207219.mjs';
6
- import { r as rpc } from './chunk-runtime-rpc.5e78af38.mjs';
4
+ import { d as distDir } from './chunk-constants.d4406290.mjs';
5
+ import { e as executeInViteNode } from './chunk-runtime-mocker.1d853e3a.mjs';
6
+ import { r as rpc } from './chunk-runtime-rpc.9d1f4c48.mjs';
7
+ import 'path';
7
8
  import 'tty';
8
9
  import 'local-pkg';
9
- import 'path';
10
10
  import 'module';
11
11
  import 'url';
12
12
  import 'vm';
@@ -75,9 +75,9 @@ function init(ctx) {
75
75
  })
76
76
  };
77
77
  if (ctx.invalidates) {
78
- ctx.invalidates.forEach((i) => {
79
- moduleCache.delete(i);
80
- moduleCache.delete(`${i}__mock`);
78
+ ctx.invalidates.forEach((fsPath) => {
79
+ moduleCache.delete(fsPath);
80
+ moduleCache.delete(`${fsPath}__mock`);
81
81
  });
82
82
  }
83
83
  ctx.files.forEach((i) => moduleCache.delete(i));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vitest",
3
- "version": "0.17.0",
3
+ "version": "0.18.1",
4
4
  "description": "A blazing fast unit test framework powered by Vite",
5
5
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
6
6
  "license": "MIT",
@@ -86,14 +86,14 @@
86
86
  "@types/node": "*",
87
87
  "chai": "^4.3.6",
88
88
  "debug": "^4.3.4",
89
- "local-pkg": "^0.4.1",
90
- "tinypool": "^0.2.1",
91
- "tinyspy": "^0.3.3",
89
+ "local-pkg": "^0.4.2",
90
+ "tinypool": "^0.2.4",
91
+ "tinyspy": "^1.0.0",
92
92
  "vite": "^2.9.12 || ^3.0.0-0"
93
93
  },
94
94
  "devDependencies": {
95
95
  "@antfu/install-pkg": "^0.1.0",
96
- "@edge-runtime/vm": "1.1.0-beta.10",
96
+ "@edge-runtime/vm": "1.1.0-beta.11",
97
97
  "@sinonjs/fake-timers": "^9.1.2",
98
98
  "@types/diff": "^5.0.2",
99
99
  "@types/jsdom": "^16.2.14",
@@ -101,7 +101,7 @@
101
101
  "@types/natural-compare": "^1.4.1",
102
102
  "@types/prompts": "^2.4.0",
103
103
  "@types/sinonjs__fake-timers": "^8.1.2",
104
- "@vitest/ui": "0.17.0",
104
+ "@vitest/ui": "0.18.1",
105
105
  "birpc": "^0.2.3",
106
106
  "c8": "^7.11.3",
107
107
  "cac": "^6.7.12",
@@ -111,13 +111,13 @@
111
111
  "execa": "^6.1.0",
112
112
  "fast-glob": "^3.2.11",
113
113
  "find-up": "^6.3.0",
114
- "flatted": "^3.2.5",
115
- "happy-dom": "^4.1.0",
114
+ "flatted": "^3.2.6",
115
+ "happy-dom": "^6.0.3",
116
116
  "jsdom": "^19.0.0",
117
117
  "log-update": "^5.0.1",
118
118
  "magic-string": "^0.26.2",
119
119
  "micromatch": "^4.0.5",
120
- "mlly": "^0.5.3",
120
+ "mlly": "^0.5.4",
121
121
  "natural-compare": "^1.4.0",
122
122
  "p-limit": "^4.0.0",
123
123
  "pathe": "^0.2.0",
@@ -125,12 +125,12 @@
125
125
  "pkg-types": "^0.3.3",
126
126
  "pretty-format": "^27.5.1",
127
127
  "prompts": "^2.4.2",
128
- "rollup": "^2.75.7",
128
+ "rollup": "^2.77.0",
129
129
  "source-map-js": "^1.0.2",
130
130
  "strip-ansi": "^7.0.1",
131
131
  "typescript": "^4.7.4",
132
- "vite-node": "0.17.0",
133
- "ws": "^8.8.0"
132
+ "vite-node": "0.18.1",
133
+ "ws": "^8.8.1"
134
134
  },
135
135
  "scripts": {
136
136
  "build": "rimraf dist && rollup -c",
@@ -1,26 +0,0 @@
1
- import { g as globalApis } from './chunk-constants.511c6e9b.mjs';
2
- import { i as index } from './vendor-entry.2edaf3e0.mjs';
3
- import 'url';
4
- import './chunk-utils-global.79a8b1cc.mjs';
5
- import 'tty';
6
- import 'local-pkg';
7
- import 'path';
8
- import 'fs';
9
- import './chunk-env-node.dc514f41.mjs';
10
- import 'module';
11
- import './chunk-runtime-chain.68f305d0.mjs';
12
- import 'chai';
13
- import './vendor-_commonjsHelpers.4da45ef5.mjs';
14
- import './chunk-runtime-rpc.5e78af38.mjs';
15
- import './chunk-utils-source-map.f52527bc.mjs';
16
- import './chunk-integrations-spy.674b628e.mjs';
17
- import 'tinyspy';
18
- import 'util';
19
-
20
- function registerApiGlobally() {
21
- globalApis.forEach((api) => {
22
- globalThis[api] = index[api];
23
- });
24
- }
25
-
26
- export { registerApiGlobally };
@@ -1,102 +0,0 @@
1
- import * as tinyspy from 'tinyspy';
2
-
3
- const spies = /* @__PURE__ */ new Set();
4
- function isMockFunction(fn2) {
5
- return typeof fn2 === "function" && "_isMockFunction" in fn2 && fn2._isMockFunction;
6
- }
7
- function spyOn(obj, method, accessType) {
8
- const dictionary = {
9
- get: "getter",
10
- set: "setter"
11
- };
12
- const objMethod = accessType ? { [dictionary[accessType]]: method } : method;
13
- const stub = tinyspy.spyOn(obj, objMethod);
14
- return enhanceSpy(stub);
15
- }
16
- let callOrder = 0;
17
- function enhanceSpy(spy) {
18
- const stub = spy;
19
- let implementation;
20
- let instances = [];
21
- let invocations = [];
22
- const mockContext = {
23
- get calls() {
24
- return stub.calls;
25
- },
26
- get instances() {
27
- return instances;
28
- },
29
- get invocationCallOrder() {
30
- return invocations;
31
- },
32
- get results() {
33
- return stub.results.map(([callType, value]) => {
34
- const type = callType === "error" ? "throw" : "return";
35
- return { type, value };
36
- });
37
- },
38
- get lastCall() {
39
- return stub.calls[stub.calls.length - 1];
40
- }
41
- };
42
- let onceImplementations = [];
43
- let name = stub.name;
44
- stub.getMockName = () => name || "vi.fn()";
45
- stub.mockName = (n) => {
46
- name = n;
47
- return stub;
48
- };
49
- stub.mockClear = () => {
50
- stub.reset();
51
- instances = [];
52
- invocations = [];
53
- return stub;
54
- };
55
- stub.mockReset = () => {
56
- stub.mockClear();
57
- implementation = () => void 0;
58
- onceImplementations = [];
59
- return stub;
60
- };
61
- stub.mockRestore = () => {
62
- stub.mockReset();
63
- implementation = void 0;
64
- return stub;
65
- };
66
- stub.getMockImplementation = () => implementation;
67
- stub.mockImplementation = (fn2) => {
68
- implementation = fn2;
69
- return stub;
70
- };
71
- stub.mockImplementationOnce = (fn2) => {
72
- onceImplementations.push(fn2);
73
- return stub;
74
- };
75
- stub.mockReturnThis = () => stub.mockImplementation(function() {
76
- return this;
77
- });
78
- stub.mockReturnValue = (val) => stub.mockImplementation(() => val);
79
- stub.mockReturnValueOnce = (val) => stub.mockImplementationOnce(() => val);
80
- stub.mockResolvedValue = (val) => stub.mockImplementation(() => Promise.resolve(val));
81
- stub.mockResolvedValueOnce = (val) => stub.mockImplementationOnce(() => Promise.resolve(val));
82
- stub.mockRejectedValue = (val) => stub.mockImplementation(() => Promise.reject(val));
83
- stub.mockRejectedValueOnce = (val) => stub.mockImplementationOnce(() => Promise.reject(val));
84
- Object.defineProperty(stub, "mock", {
85
- get: () => mockContext
86
- });
87
- stub.willCall(function(...args) {
88
- instances.push(this);
89
- invocations.push(++callOrder);
90
- const impl = onceImplementations.shift() || implementation || stub.getOriginal() || (() => {
91
- });
92
- return impl.apply(this, args);
93
- });
94
- spies.add(stub);
95
- return stub;
96
- }
97
- function fn(implementation) {
98
- return enhanceSpy(tinyspy.spyOn({ fn: implementation || (() => {
99
- }) }, "fn"));
100
- }
101
-
102
- export { spies as a, fn as f, isMockFunction as i, spyOn as s };