vitest 0.0.66 → 0.0.70

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.
@@ -1,27 +1,13 @@
1
- import {
2
- slash
3
- } from "../chunk-5TNYWP3O.js";
4
- import {
5
- distDir
6
- } from "../chunk-XUIDSY4V.js";
7
- import {
8
- nanoid
9
- } from "../chunk-APGELTDH.js";
10
- import {
11
- init_esm_shims
12
- } from "../chunk-R2SMNEBL.js";
1
+ import { resolve, dirname } from 'path';
2
+ import { n as nanoid } from './index-6427e0f2.js';
3
+ import { b as distDir } from './constants-d4c70610.js';
4
+ import { builtinModules, createRequire } from 'module';
5
+ import { pathToFileURL, fileURLToPath } from 'url';
6
+ import vm from 'vm';
7
+ import { s as slash } from './utils-9dcc4050.js';
13
8
 
14
- // src/runtime/worker.ts
15
- init_esm_shims();
16
- import { resolve as resolve2 } from "path";
17
-
18
- // src/node/execute.ts
19
- init_esm_shims();
20
- import { builtinModules, createRequire } from "module";
21
- import { fileURLToPath, pathToFileURL } from "url";
22
- import { dirname, resolve } from "path";
23
- import vm from "vm";
24
- var defaultInline = [
9
+ const defaultInline = [
10
+ "vitest/dist",
25
11
  "@vue",
26
12
  "@vueuse",
27
13
  "vue-demi",
@@ -31,11 +17,11 @@ var defaultInline = [
31
17
  /\/esm\/.*\.js$/,
32
18
  /\.(es|esm|esm-browser|esm-bundler|es6).js$/
33
19
  ];
34
- var depsExternal = [
20
+ const depsExternal = [
35
21
  /\.cjs.js$/
36
22
  ];
37
- var isWindows = process.platform === "win32";
38
- var stubRequests = {
23
+ const isWindows = process.platform === "win32";
24
+ const stubRequests = {
39
25
  "/@vite/client": {
40
26
  injectQuery: (id) => id,
41
27
  createHotContext() {
@@ -68,7 +54,7 @@ async function interpretedImport(path, interpretDefault) {
68
54
  return mod;
69
55
  }
70
56
  async function executeInViteNode(options) {
71
- const { moduleCache: moduleCache2, root, files, fetch } = options;
57
+ const { moduleCache, root, files, fetch } = options;
72
58
  const externaled = new Set(builtinModules);
73
59
  const result = [];
74
60
  for (const file of files)
@@ -80,11 +66,11 @@ async function executeInViteNode(options) {
80
66
  var _a;
81
67
  if (callstack.includes(dep)) {
82
68
  const cacheKey = toFilePath(dep, root);
83
- if (!((_a = moduleCache2.get(cacheKey)) == null ? void 0 : _a.exports))
69
+ if (!((_a = moduleCache.get(cacheKey)) == null ? void 0 : _a.exports))
84
70
  throw new Error(`Circular dependency detected
85
71
  Stack:
86
72
  ${[...callstack, dep].reverse().map((p) => `- ${p}`).join("\n")}`);
87
- return moduleCache2.get(cacheKey).exports;
73
+ return moduleCache.get(cacheKey).exports;
88
74
  }
89
75
  return cachedRequest(dep, callstack);
90
76
  };
@@ -96,11 +82,11 @@ ${[...callstack, dep].reverse().map((p) => `- ${p}`).join("\n")}`);
96
82
  const url = pathToFileURL(fsPath).href;
97
83
  const exports = {};
98
84
  setCache(fsPath, { transformResult: result2, exports });
99
- const __filename2 = fileURLToPath(url);
85
+ const __filename = fileURLToPath(url);
100
86
  const context = {
101
87
  require: createRequire(url),
102
- __filename: __filename2,
103
- __dirname: dirname(__filename2),
88
+ __filename,
89
+ __dirname: dirname(__filename),
104
90
  __vite_ssr_import__: request,
105
91
  __vite_ssr_dynamic_import__: request,
106
92
  __vite_ssr_exports__: exports,
@@ -116,10 +102,10 @@ ${[...callstack, dep].reverse().map((p) => `- ${p}`).join("\n")}`);
116
102
  return exports;
117
103
  }
118
104
  function setCache(id, mod) {
119
- if (!moduleCache2.has(id))
120
- moduleCache2.set(id, mod);
105
+ if (!moduleCache.has(id))
106
+ moduleCache.set(id, mod);
121
107
  else
122
- Object.assign(moduleCache2.get(id), mod);
108
+ Object.assign(moduleCache.get(id), mod);
123
109
  }
124
110
  async function cachedRequest(rawId, callstack) {
125
111
  var _a, _b;
@@ -132,8 +118,8 @@ ${[...callstack, dep].reverse().map((p) => `- ${p}`).join("\n")}`);
132
118
  externaled.add(importPath);
133
119
  return interpretedImport(importPath, options.interpretDefault);
134
120
  }
135
- if ((_a = moduleCache2.get(fsPath)) == null ? void 0 : _a.promise)
136
- return (_b = moduleCache2.get(fsPath)) == null ? void 0 : _b.promise;
121
+ if ((_a = moduleCache.get(fsPath)) == null ? void 0 : _a.promise)
122
+ return (_b = moduleCache.get(fsPath)) == null ? void 0 : _b.promise;
137
123
  const promise = directRequest(id, fsPath, callstack);
138
124
  setCache(fsPath, { promise });
139
125
  return await promise;
@@ -203,9 +189,8 @@ function patchWindowsImportPath(path) {
203
189
  return path;
204
190
  }
205
191
 
206
- // src/runtime/worker.ts
207
- var _run;
208
- var moduleCache = /* @__PURE__ */ new Map();
192
+ let _run;
193
+ const moduleCache = new Map();
209
194
  async function init(ctx) {
210
195
  if (_run)
211
196
  return _run;
@@ -213,7 +198,7 @@ async function init(ctx) {
213
198
  _run = (await executeInViteNode({
214
199
  root: config.root,
215
200
  files: [
216
- resolve2(distDir, "runtime/entry.js")
201
+ resolve(distDir, "entry.js")
217
202
  ],
218
203
  fetch(id) {
219
204
  return process.__vitest_worker__.rpc("fetch", id);
@@ -228,13 +213,13 @@ async function init(ctx) {
228
213
  async function run(ctx) {
229
214
  process.stdout.write("\0");
230
215
  const { config, port } = ctx;
231
- const rpcPromiseMap = /* @__PURE__ */ new Map();
216
+ const rpcPromiseMap = new Map();
232
217
  process.__vitest_worker__ = {
233
218
  config,
234
219
  rpc: (method, ...args) => {
235
- return new Promise((resolve3, reject) => {
220
+ return new Promise((resolve2, reject) => {
236
221
  const id = nanoid();
237
- rpcPromiseMap.set(id, { resolve: resolve3, reject });
222
+ rpcPromiseMap.set(id, { resolve: resolve2, reject });
238
223
  port.postMessage({ method, args, id });
239
224
  });
240
225
  },
@@ -257,7 +242,5 @@ async function run(ctx) {
257
242
  ctx.files.forEach((i) => moduleCache.delete(i));
258
243
  return run2(ctx.files, ctx.config);
259
244
  }
260
- export {
261
- run as default,
262
- init
263
- };
245
+
246
+ export { run as default, init };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vitest",
3
- "version": "0.0.66",
3
+ "version": "0.0.70",
4
4
  "description": "A blazing fast unit test framework powered by Vite",
5
5
  "keywords": [
6
6
  "vite",
@@ -39,9 +39,9 @@
39
39
  "*.d.ts"
40
40
  ],
41
41
  "scripts": {
42
- "build": "tsup --dts",
42
+ "build": "rimraf dist && rollup -c",
43
43
  "coverage": "node bin/vitest.mjs -r test/core --coverage",
44
- "dev": "tsup --watch src",
44
+ "dev": "rollup -c -w src",
45
45
  "docs": "npm -C docs run dev",
46
46
  "docs:build": "npm -C docs run build",
47
47
  "docs:serve": "npm -C docs run serve",
@@ -50,19 +50,20 @@
50
50
  "prepublishOnly": "nr build",
51
51
  "release": "bumpp --commit --push --tag && esmo scripts/publish.ts",
52
52
  "test": "node bin/vitest.mjs -r test/core",
53
- "test:all": "pnpm -r --stream --filter !vitest run test --",
54
- "test:ci": "pnpm -r --stream --filter !vitest --filter !@vitest/test-fails run test --",
53
+ "test:all": "cross-env CI=true pnpm -r --stream --filter !vitest run test --",
54
+ "test:ci": "cross-env CI=true pnpm -r --stream --filter !vitest --filter !@vitest/test-fails run test --",
55
55
  "typecheck": "tsc --noEmit && nr lint"
56
56
  },
57
57
  "dependencies": {
58
58
  "@types/chai": "^4.3.0",
59
+ "@types/chai-subset": "^1.3.3",
60
+ "@types/sinon": "^10.0.6",
59
61
  "@types/sinon-chai": "^3.2.6",
60
62
  "chai": "^4.3.4",
61
63
  "chai-subset": "^1.6.0",
62
64
  "fast-glob": "^3.2.7",
63
- "log-update": "^5.0.0",
65
+ "local-pkg": "^0.4.0",
64
66
  "micromatch": "^4.0.4",
65
- "picocolors": "^1.0.0",
66
67
  "piscina": "^3.2.0",
67
68
  "sinon": "^12.0.1",
68
69
  "sinon-chai": "^3.7.0",
@@ -71,29 +72,36 @@
71
72
  "devDependencies": {
72
73
  "@antfu/eslint-config": "^0.13.1",
73
74
  "@antfu/ni": "^0.12.0",
74
- "@types/chai-subset": "^1.3.3",
75
+ "@rollup/plugin-alias": "^3.1.8",
76
+ "@rollup/plugin-commonjs": "^21.0.1",
77
+ "@rollup/plugin-json": "^4.1.0",
78
+ "@rollup/plugin-node-resolve": "^13.0.6",
75
79
  "@types/diff": "^5.0.1",
76
80
  "@types/jsdom": "^16.2.13",
77
81
  "@types/micromatch": "^4.0.2",
78
82
  "@types/natural-compare": "^1.4.1",
79
83
  "@types/node": "^16.11.12",
80
84
  "@types/sade": "^1.7.3",
81
- "@types/sinon": "^10.0.6",
82
85
  "bumpp": "^7.1.1",
83
86
  "c8": "^7.10.0",
84
87
  "cac": "^6.7.12",
85
88
  "cli-truncate": "^3.1.0",
89
+ "cross-env": "^7.0.3",
86
90
  "diff": "^5.0.0",
87
91
  "eslint": "^8.4.1",
88
92
  "esno": "^0.12.1",
89
93
  "find-up": "^6.2.0",
90
94
  "happy-dom": "^2.24.5",
91
95
  "jsdom": "^19.0.0",
96
+ "log-update": "^5.0.0",
92
97
  "nanoid": "^3.1.30",
93
98
  "natural-compare": "^1.4.0",
94
99
  "npm-run-all": "^4.1.5",
100
+ "picocolors": "^1.0.0",
95
101
  "pretty-format": "^27.4.2",
96
102
  "rimraf": "^3.0.2",
103
+ "rollup-plugin-dts": "^4.0.1",
104
+ "rollup-plugin-esbuild": "^4.7.2",
97
105
  "strip-ansi": "^7.0.1",
98
106
  "tsup": "^5.11.1",
99
107
  "typescript": "^4.5.3",
@@ -1,19 +0,0 @@
1
- import {
2
- init_esm_shims
3
- } from "./chunk-R2SMNEBL.js";
4
-
5
- // node_modules/.pnpm/nanoid@3.1.30/node_modules/nanoid/non-secure/index.js
6
- init_esm_shims();
7
- var urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
8
- var nanoid = (size = 21) => {
9
- let id = "";
10
- let i = size;
11
- while (i--) {
12
- id += urlAlphabet[Math.random() * 64 | 0];
13
- }
14
- return id;
15
- };
16
-
17
- export {
18
- nanoid
19
- };
@@ -1,95 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __defProps = Object.defineProperties;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
- var __getProtoOf = Object.getPrototypeOf;
9
- var __hasOwnProp = Object.prototype.hasOwnProperty;
10
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
11
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
12
- var __spreadValues = (a, b) => {
13
- for (var prop in b || (b = {}))
14
- if (__hasOwnProp.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- if (__getOwnPropSymbols)
17
- for (var prop of __getOwnPropSymbols(b)) {
18
- if (__propIsEnum.call(b, prop))
19
- __defNormalProp(a, prop, b[prop]);
20
- }
21
- return a;
22
- };
23
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
24
- var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
25
- var __esm = (fn, res) => function __init() {
26
- return fn && (res = (0, fn[Object.keys(fn)[0]])(fn = 0)), res;
27
- };
28
- var __commonJS = (cb, mod) => function __require() {
29
- return mod || (0, cb[Object.keys(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
30
- };
31
- var __export = (target, all) => {
32
- __markAsModule(target);
33
- for (var name in all)
34
- __defProp(target, name, { get: all[name], enumerable: true });
35
- };
36
- var __reExport = (target, module, desc) => {
37
- if (module && typeof module === "object" || typeof module === "function") {
38
- for (let key of __getOwnPropNames(module))
39
- if (!__hasOwnProp.call(target, key) && key !== "default")
40
- __defProp(target, key, { get: () => module[key], enumerable: !(desc = __getOwnPropDesc(module, key)) || desc.enumerable });
41
- }
42
- return target;
43
- };
44
- var __toModule = (module) => {
45
- return __reExport(__markAsModule(__defProp(module != null ? __create(__getProtoOf(module)) : {}, "default", module && module.__esModule && "default" in module ? { get: () => module.default, enumerable: true } : { value: module, enumerable: true })), module);
46
- };
47
- var __accessCheck = (obj, member, msg) => {
48
- if (!member.has(obj))
49
- throw TypeError("Cannot " + msg);
50
- };
51
- var __privateGet = (obj, member, getter) => {
52
- __accessCheck(obj, member, "read from private field");
53
- return getter ? getter.call(obj) : member.get(obj);
54
- };
55
- var __privateAdd = (obj, member, value) => {
56
- if (member.has(obj))
57
- throw TypeError("Cannot add the same private member more than once");
58
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
59
- };
60
- var __privateSet = (obj, member, value, setter) => {
61
- __accessCheck(obj, member, "write to private field");
62
- setter ? setter.call(obj, value) : member.set(obj, value);
63
- return value;
64
- };
65
- var __privateWrapper = (obj, member, setter, getter) => {
66
- return {
67
- set _(value) {
68
- __privateSet(obj, member, value, setter);
69
- },
70
- get _() {
71
- return __privateGet(obj, member, getter);
72
- }
73
- };
74
- };
75
-
76
- // node_modules/.pnpm/tsup@5.11.1_typescript@4.5.3/node_modules/tsup/assets/esm_shims.js
77
- import { fileURLToPath } from "url";
78
- import path from "path";
79
- var init_esm_shims = __esm({
80
- "node_modules/.pnpm/tsup@5.11.1_typescript@4.5.3/node_modules/tsup/assets/esm_shims.js"() {
81
- }
82
- });
83
-
84
- export {
85
- __spreadValues,
86
- __spreadProps,
87
- __commonJS,
88
- __export,
89
- __toModule,
90
- __privateGet,
91
- __privateAdd,
92
- __privateSet,
93
- __privateWrapper,
94
- init_esm_shims
95
- };
@@ -1,78 +0,0 @@
1
- import {
2
- init_esm_shims
3
- } from "./chunk-R2SMNEBL.js";
4
-
5
- // src/integrations/snapshot/port/jest-test-result-helper.ts
6
- init_esm_shims();
7
- var emptySummary = (options) => {
8
- const summary = {
9
- added: 0,
10
- failure: false,
11
- filesAdded: 0,
12
- filesRemoved: 0,
13
- filesRemovedList: [],
14
- filesUnmatched: 0,
15
- filesUpdated: 0,
16
- matched: 0,
17
- total: 0,
18
- unchecked: 0,
19
- uncheckedKeysByFile: [],
20
- unmatched: 0,
21
- updated: 0,
22
- didUpdate: options.updateSnapshot === "all"
23
- };
24
- return summary;
25
- };
26
- var packSnapshotState = (filepath, state) => {
27
- const snapshot = {
28
- filepath,
29
- added: 0,
30
- fileDeleted: false,
31
- matched: 0,
32
- unchecked: 0,
33
- uncheckedKeys: [],
34
- unmatched: 0,
35
- updated: 0
36
- };
37
- const uncheckedCount = state.getUncheckedCount();
38
- const uncheckedKeys = state.getUncheckedKeys();
39
- if (uncheckedCount)
40
- state.removeUncheckedKeys();
41
- const status = state.save();
42
- snapshot.fileDeleted = status.deleted;
43
- snapshot.added = state.added;
44
- snapshot.matched = state.matched;
45
- snapshot.unmatched = state.unmatched;
46
- snapshot.updated = state.updated;
47
- snapshot.unchecked = !status.deleted ? uncheckedCount : 0;
48
- snapshot.uncheckedKeys = Array.from(uncheckedKeys);
49
- return snapshot;
50
- };
51
- var addSnapshotResult = (summary, result) => {
52
- if (result.added)
53
- summary.filesAdded++;
54
- if (result.fileDeleted)
55
- summary.filesRemoved++;
56
- if (result.unmatched)
57
- summary.filesUnmatched++;
58
- if (result.updated)
59
- summary.filesUpdated++;
60
- summary.added += result.added;
61
- summary.matched += result.matched;
62
- summary.unchecked += result.unchecked;
63
- if (result.uncheckedKeys && result.uncheckedKeys.length > 0) {
64
- summary.uncheckedKeysByFile.push({
65
- filePath: result.filepath,
66
- keys: result.uncheckedKeys
67
- });
68
- }
69
- summary.unmatched += result.unmatched;
70
- summary.updated += result.updated;
71
- summary.total += result.added + result.matched + result.unmatched + result.updated;
72
- };
73
-
74
- export {
75
- emptySummary,
76
- packSnapshotState,
77
- addSnapshotResult
78
- };
@@ -1,35 +0,0 @@
1
- import {
2
- init_esm_shims
3
- } from "./chunk-R2SMNEBL.js";
4
-
5
- // src/constants.ts
6
- init_esm_shims();
7
- import { resolve } from "path";
8
- import { fileURLToPath } from "url";
9
- var distDir = resolve(fileURLToPath(import.meta.url), "../../dist");
10
- var defaultIncludes = ["**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"];
11
- var defaultExcludes = ["**/node_modules/**", "**/dist/**"];
12
- var globalApis = [
13
- "suite",
14
- "test",
15
- "describe",
16
- "it",
17
- "chai",
18
- "expect",
19
- "assert",
20
- "sinon",
21
- "spy",
22
- "mock",
23
- "stub",
24
- "beforeAll",
25
- "afterAll",
26
- "beforeEach",
27
- "afterEach"
28
- ];
29
-
30
- export {
31
- distDir,
32
- defaultIncludes,
33
- defaultExcludes,
34
- globalApis
35
- };
@@ -1,86 +0,0 @@
1
- import {
2
- afterAll,
3
- afterEach,
4
- beforeAll,
5
- beforeEach,
6
- clearContext,
7
- createSuiteHooks,
8
- defaultSuite,
9
- describe,
10
- it,
11
- suite,
12
- test
13
- } from "./chunk-ANPMHBIF.js";
14
- import {
15
- __export,
16
- init_esm_shims
17
- } from "./chunk-R2SMNEBL.js";
18
-
19
- // src/index.ts
20
- var src_exports = {};
21
- __export(src_exports, {
22
- afterAll: () => afterAll,
23
- afterEach: () => afterEach,
24
- assert: () => assert,
25
- beforeAll: () => beforeAll,
26
- beforeEach: () => beforeEach,
27
- chai: () => chai,
28
- clearContext: () => clearContext,
29
- createSuiteHooks: () => createSuiteHooks,
30
- defaultSuite: () => defaultSuite,
31
- describe: () => describe,
32
- expect: () => expect,
33
- it: () => it,
34
- mock: () => mock,
35
- should: () => should,
36
- sinon: () => sinon,
37
- spy: () => spy,
38
- stub: () => stub,
39
- suite: () => suite,
40
- test: () => test
41
- });
42
- init_esm_shims();
43
-
44
- // src/types/index.ts
45
- init_esm_shims();
46
-
47
- // src/types/options.ts
48
- init_esm_shims();
49
-
50
- // src/types/tasks.ts
51
- init_esm_shims();
52
-
53
- // src/types/reporter.ts
54
- init_esm_shims();
55
-
56
- // src/types/snapshot.ts
57
- init_esm_shims();
58
-
59
- // src/types/worker.ts
60
- init_esm_shims();
61
-
62
- // src/types/general.ts
63
- init_esm_shims();
64
-
65
- // src/integrations/chai/index.ts
66
- init_esm_shims();
67
- import chai from "chai";
68
- import { assert, should, expect } from "chai";
69
-
70
- // src/integrations/sinon.ts
71
- init_esm_shims();
72
- import sinon from "sinon";
73
- var { mock, spy, stub } = sinon;
74
- sinon.fn = sinon.spy;
75
-
76
- export {
77
- chai,
78
- assert,
79
- should,
80
- expect,
81
- sinon,
82
- mock,
83
- spy,
84
- stub,
85
- src_exports
86
- };
@@ -1,22 +0,0 @@
1
- import {
2
- src_exports
3
- } from "./chunk-YPKHVZRP.js";
4
- import {
5
- globalApis
6
- } from "./chunk-XUIDSY4V.js";
7
- import "./chunk-ANPMHBIF.js";
8
- import "./chunk-APGELTDH.js";
9
- import {
10
- init_esm_shims
11
- } from "./chunk-R2SMNEBL.js";
12
-
13
- // src/integrations/global.ts
14
- init_esm_shims();
15
- function registerApiGlobally() {
16
- globalApis.forEach((api) => {
17
- globalThis[api] = src_exports[api];
18
- });
19
- }
20
- export {
21
- registerApiGlobally
22
- };
@@ -1 +0,0 @@
1
-