vitest 0.0.65 → 0.0.69

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,25 +1,13 @@
1
- import {
2
- slash
3
- } from "../chunk-NK2VTQLQ.js";
4
- import {
5
- nanoid
6
- } from "../chunk-3GMBTS5G.js";
7
- import {
8
- distDir,
9
- init_esm_shims
10
- } from "../chunk-RNHB4AXG.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';
11
8
 
12
- // src/runtime/worker.ts
13
- init_esm_shims();
14
- import { resolve as resolve2 } from "path";
15
-
16
- // src/node/execute.ts
17
- init_esm_shims();
18
- import { builtinModules, createRequire } from "module";
19
- import { fileURLToPath, pathToFileURL } from "url";
20
- import { dirname, resolve } from "path";
21
- import vm from "vm";
22
- var defaultInline = [
9
+ const defaultInline = [
10
+ "vitest/dist",
23
11
  "@vue",
24
12
  "@vueuse",
25
13
  "vue-demi",
@@ -29,11 +17,11 @@ var defaultInline = [
29
17
  /\/esm\/.*\.js$/,
30
18
  /\.(es|esm|esm-browser|esm-bundler|es6).js$/
31
19
  ];
32
- var depsExternal = [
20
+ const depsExternal = [
33
21
  /\.cjs.js$/
34
22
  ];
35
- var isWindows = process.platform === "win32";
36
- var stubRequests = {
23
+ const isWindows = process.platform === "win32";
24
+ const stubRequests = {
37
25
  "/@vite/client": {
38
26
  injectQuery: (id) => id,
39
27
  createHotContext() {
@@ -66,7 +54,7 @@ async function interpretedImport(path, interpretDefault) {
66
54
  return mod;
67
55
  }
68
56
  async function executeInViteNode(options) {
69
- const { moduleCache: moduleCache2, root, files, fetch } = options;
57
+ const { moduleCache, root, files, fetch } = options;
70
58
  const externaled = new Set(builtinModules);
71
59
  const result = [];
72
60
  for (const file of files)
@@ -78,11 +66,11 @@ async function executeInViteNode(options) {
78
66
  var _a;
79
67
  if (callstack.includes(dep)) {
80
68
  const cacheKey = toFilePath(dep, root);
81
- if (!((_a = moduleCache2.get(cacheKey)) == null ? void 0 : _a.exports))
69
+ if (!((_a = moduleCache.get(cacheKey)) == null ? void 0 : _a.exports))
82
70
  throw new Error(`Circular dependency detected
83
71
  Stack:
84
72
  ${[...callstack, dep].reverse().map((p) => `- ${p}`).join("\n")}`);
85
- return moduleCache2.get(cacheKey).exports;
73
+ return moduleCache.get(cacheKey).exports;
86
74
  }
87
75
  return cachedRequest(dep, callstack);
88
76
  };
@@ -94,11 +82,11 @@ ${[...callstack, dep].reverse().map((p) => `- ${p}`).join("\n")}`);
94
82
  const url = pathToFileURL(fsPath).href;
95
83
  const exports = {};
96
84
  setCache(fsPath, { transformResult: result2, exports });
97
- const __filename2 = fileURLToPath(url);
85
+ const __filename = fileURLToPath(url);
98
86
  const context = {
99
87
  require: createRequire(url),
100
- __filename: __filename2,
101
- __dirname: dirname(__filename2),
88
+ __filename,
89
+ __dirname: dirname(__filename),
102
90
  __vite_ssr_import__: request,
103
91
  __vite_ssr_dynamic_import__: request,
104
92
  __vite_ssr_exports__: exports,
@@ -114,10 +102,10 @@ ${[...callstack, dep].reverse().map((p) => `- ${p}`).join("\n")}`);
114
102
  return exports;
115
103
  }
116
104
  function setCache(id, mod) {
117
- if (!moduleCache2.has(id))
118
- moduleCache2.set(id, mod);
105
+ if (!moduleCache.has(id))
106
+ moduleCache.set(id, mod);
119
107
  else
120
- Object.assign(moduleCache2.get(id), mod);
108
+ Object.assign(moduleCache.get(id), mod);
121
109
  }
122
110
  async function cachedRequest(rawId, callstack) {
123
111
  var _a, _b;
@@ -130,8 +118,8 @@ ${[...callstack, dep].reverse().map((p) => `- ${p}`).join("\n")}`);
130
118
  externaled.add(importPath);
131
119
  return interpretedImport(importPath, options.interpretDefault);
132
120
  }
133
- if ((_a = moduleCache2.get(fsPath)) == null ? void 0 : _a.promise)
134
- 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;
135
123
  const promise = directRequest(id, fsPath, callstack);
136
124
  setCache(fsPath, { promise });
137
125
  return await promise;
@@ -201,9 +189,8 @@ function patchWindowsImportPath(path) {
201
189
  return path;
202
190
  }
203
191
 
204
- // src/runtime/worker.ts
205
- var _run;
206
- var moduleCache = /* @__PURE__ */ new Map();
192
+ let _run;
193
+ const moduleCache = new Map();
207
194
  async function init(ctx) {
208
195
  if (_run)
209
196
  return _run;
@@ -211,7 +198,7 @@ async function init(ctx) {
211
198
  _run = (await executeInViteNode({
212
199
  root: config.root,
213
200
  files: [
214
- resolve2(distDir, "runtime/entry.js")
201
+ resolve(distDir, "entry.js")
215
202
  ],
216
203
  fetch(id) {
217
204
  return process.__vitest_worker__.rpc("fetch", id);
@@ -226,13 +213,13 @@ async function init(ctx) {
226
213
  async function run(ctx) {
227
214
  process.stdout.write("\0");
228
215
  const { config, port } = ctx;
229
- const rpcPromiseMap = /* @__PURE__ */ new Map();
216
+ const rpcPromiseMap = new Map();
230
217
  process.__vitest_worker__ = {
231
218
  config,
232
219
  rpc: (method, ...args) => {
233
- return new Promise((resolve3, reject) => {
220
+ return new Promise((resolve2, reject) => {
234
221
  const id = nanoid();
235
- rpcPromiseMap.set(id, { resolve: resolve3, reject });
222
+ rpcPromiseMap.set(id, { resolve: resolve2, reject });
236
223
  port.postMessage({ method, args, id });
237
224
  });
238
225
  },
@@ -255,7 +242,5 @@ async function run(ctx) {
255
242
  ctx.files.forEach((i) => moduleCache.delete(i));
256
243
  return run2(ctx.files, ctx.config);
257
244
  }
258
- export {
259
- run as default,
260
- init
261
- };
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.65",
3
+ "version": "0.0.69",
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,8 +50,8 @@
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": {
@@ -60,18 +60,21 @@
60
60
  "chai": "^4.3.4",
61
61
  "chai-subset": "^1.6.0",
62
62
  "fast-glob": "^3.2.7",
63
- "log-update": "^5.0.0",
64
63
  "micromatch": "^4.0.4",
65
- "picocolors": "^1.0.0",
66
64
  "piscina": "^3.2.0",
67
- "sade": "^1.7.4",
68
65
  "sinon": "^12.0.1",
69
66
  "sinon-chai": "^3.7.0",
70
67
  "source-map": "^0.7.3"
71
68
  },
72
69
  "devDependencies": {
70
+ "log-update": "^5.0.0",
71
+ "picocolors": "^1.0.0",
73
72
  "@antfu/eslint-config": "^0.13.1",
74
73
  "@antfu/ni": "^0.12.0",
74
+ "@rollup/plugin-alias": "^3.1.8",
75
+ "@rollup/plugin-commonjs": "^21.0.1",
76
+ "@rollup/plugin-json": "^4.1.0",
77
+ "@rollup/plugin-node-resolve": "^13.0.6",
75
78
  "@types/chai-subset": "^1.3.3",
76
79
  "@types/diff": "^5.0.1",
77
80
  "@types/jsdom": "^16.2.13",
@@ -82,7 +85,9 @@
82
85
  "@types/sinon": "^10.0.6",
83
86
  "bumpp": "^7.1.1",
84
87
  "c8": "^7.10.0",
88
+ "cac": "^6.7.12",
85
89
  "cli-truncate": "^3.1.0",
90
+ "cross-env": "^7.0.3",
86
91
  "diff": "^5.0.0",
87
92
  "eslint": "^8.4.1",
88
93
  "esno": "^0.12.1",
@@ -94,6 +99,8 @@
94
99
  "npm-run-all": "^4.1.5",
95
100
  "pretty-format": "^27.4.2",
96
101
  "rimraf": "^3.0.2",
102
+ "rollup-plugin-dts": "^4.0.1",
103
+ "rollup-plugin-esbuild": "^4.7.2",
97
104
  "strip-ansi": "^7.0.1",
98
105
  "tsup": "^5.11.1",
99
106
  "typescript": "^4.5.3",
@@ -1,19 +0,0 @@
1
- import {
2
- init_esm_shims
3
- } from "./chunk-RNHB4AXG.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,128 +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
- // src/constants.ts
85
- init_esm_shims();
86
- import { resolve } from "path";
87
- import { fileURLToPath as fileURLToPath2 } from "url";
88
- var distDir = resolve(fileURLToPath2(import.meta.url), "../../dist");
89
- var defaultTestTimeout = 5e3;
90
- var defaultHookTimeout = 5e3;
91
- var defaultIncludes = ["**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"];
92
- var defaultExcludes = ["**/node_modules/**", "**/dist/**"];
93
- var globalApis = [
94
- "suite",
95
- "test",
96
- "describe",
97
- "it",
98
- "chai",
99
- "expect",
100
- "assert",
101
- "sinon",
102
- "spy",
103
- "mock",
104
- "stub",
105
- "beforeAll",
106
- "afterAll",
107
- "beforeEach",
108
- "afterEach"
109
- ];
110
-
111
- export {
112
- __spreadValues,
113
- __spreadProps,
114
- __commonJS,
115
- __export,
116
- __toModule,
117
- __privateGet,
118
- __privateAdd,
119
- __privateSet,
120
- __privateWrapper,
121
- init_esm_shims,
122
- distDir,
123
- defaultTestTimeout,
124
- defaultHookTimeout,
125
- defaultIncludes,
126
- defaultExcludes,
127
- globalApis
128
- };
@@ -1,78 +0,0 @@
1
- import {
2
- init_esm_shims
3
- } from "./chunk-RNHB4AXG.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,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-LRXUKIDM.js";
14
- import {
15
- __export,
16
- init_esm_shims
17
- } from "./chunk-RNHB4AXG.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,20 +0,0 @@
1
- import {
2
- src_exports
3
- } from "./chunk-VAUJEKEW.js";
4
- import "./chunk-LRXUKIDM.js";
5
- import "./chunk-3GMBTS5G.js";
6
- import {
7
- globalApis,
8
- init_esm_shims
9
- } from "./chunk-RNHB4AXG.js";
10
-
11
- // src/integrations/global.ts
12
- init_esm_shims();
13
- function registerApiGlobally() {
14
- globalApis.forEach((api) => {
15
- globalThis[api] = src_exports[api];
16
- });
17
- }
18
- export {
19
- registerApiGlobally
20
- };
@@ -1,11 +0,0 @@
1
- import { V as VitestContext } from '../options-652352ad';
2
- import 'vite';
3
- import 'pretty-format';
4
-
5
- declare global {
6
- namespace NodeJS {
7
- interface Process {
8
- __vitest__: VitestContext;
9
- }
10
- }
11
- }