vitest 0.0.67 → 0.0.71

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,29 +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 = [
25
- "vitest/dist/runtime/entry.js",
26
- "vitest/src/runtime/entry.ts",
9
+ const defaultInline = [
10
+ "vitest/dist",
27
11
  "@vue",
28
12
  "@vueuse",
29
13
  "vue-demi",
@@ -33,11 +17,11 @@ var defaultInline = [
33
17
  /\/esm\/.*\.js$/,
34
18
  /\.(es|esm|esm-browser|esm-bundler|es6).js$/
35
19
  ];
36
- var depsExternal = [
20
+ const depsExternal = [
37
21
  /\.cjs.js$/
38
22
  ];
39
- var isWindows = process.platform === "win32";
40
- var stubRequests = {
23
+ const isWindows = process.platform === "win32";
24
+ const stubRequests = {
41
25
  "/@vite/client": {
42
26
  injectQuery: (id) => id,
43
27
  createHotContext() {
@@ -70,7 +54,7 @@ async function interpretedImport(path, interpretDefault) {
70
54
  return mod;
71
55
  }
72
56
  async function executeInViteNode(options) {
73
- const { moduleCache: moduleCache2, root, files, fetch } = options;
57
+ const { moduleCache, root, files, fetch } = options;
74
58
  const externaled = new Set(builtinModules);
75
59
  const result = [];
76
60
  for (const file of files)
@@ -82,11 +66,11 @@ async function executeInViteNode(options) {
82
66
  var _a;
83
67
  if (callstack.includes(dep)) {
84
68
  const cacheKey = toFilePath(dep, root);
85
- if (!((_a = moduleCache2.get(cacheKey)) == null ? void 0 : _a.exports))
69
+ if (!((_a = moduleCache.get(cacheKey)) == null ? void 0 : _a.exports))
86
70
  throw new Error(`Circular dependency detected
87
71
  Stack:
88
72
  ${[...callstack, dep].reverse().map((p) => `- ${p}`).join("\n")}`);
89
- return moduleCache2.get(cacheKey).exports;
73
+ return moduleCache.get(cacheKey).exports;
90
74
  }
91
75
  return cachedRequest(dep, callstack);
92
76
  };
@@ -98,11 +82,11 @@ ${[...callstack, dep].reverse().map((p) => `- ${p}`).join("\n")}`);
98
82
  const url = pathToFileURL(fsPath).href;
99
83
  const exports = {};
100
84
  setCache(fsPath, { transformResult: result2, exports });
101
- const __filename2 = fileURLToPath(url);
85
+ const __filename = fileURLToPath(url);
102
86
  const context = {
103
87
  require: createRequire(url),
104
- __filename: __filename2,
105
- __dirname: dirname(__filename2),
88
+ __filename,
89
+ __dirname: dirname(__filename),
106
90
  __vite_ssr_import__: request,
107
91
  __vite_ssr_dynamic_import__: request,
108
92
  __vite_ssr_exports__: exports,
@@ -118,10 +102,10 @@ ${[...callstack, dep].reverse().map((p) => `- ${p}`).join("\n")}`);
118
102
  return exports;
119
103
  }
120
104
  function setCache(id, mod) {
121
- if (!moduleCache2.has(id))
122
- moduleCache2.set(id, mod);
105
+ if (!moduleCache.has(id))
106
+ moduleCache.set(id, mod);
123
107
  else
124
- Object.assign(moduleCache2.get(id), mod);
108
+ Object.assign(moduleCache.get(id), mod);
125
109
  }
126
110
  async function cachedRequest(rawId, callstack) {
127
111
  var _a, _b;
@@ -134,8 +118,8 @@ ${[...callstack, dep].reverse().map((p) => `- ${p}`).join("\n")}`);
134
118
  externaled.add(importPath);
135
119
  return interpretedImport(importPath, options.interpretDefault);
136
120
  }
137
- if ((_a = moduleCache2.get(fsPath)) == null ? void 0 : _a.promise)
138
- 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;
139
123
  const promise = directRequest(id, fsPath, callstack);
140
124
  setCache(fsPath, { promise });
141
125
  return await promise;
@@ -205,9 +189,8 @@ function patchWindowsImportPath(path) {
205
189
  return path;
206
190
  }
207
191
 
208
- // src/runtime/worker.ts
209
- var _run;
210
- var moduleCache = /* @__PURE__ */ new Map();
192
+ let _run;
193
+ const moduleCache = new Map();
211
194
  async function init(ctx) {
212
195
  if (_run)
213
196
  return _run;
@@ -215,7 +198,7 @@ async function init(ctx) {
215
198
  _run = (await executeInViteNode({
216
199
  root: config.root,
217
200
  files: [
218
- resolve2(distDir, "runtime/entry.js")
201
+ resolve(distDir, "entry.js")
219
202
  ],
220
203
  fetch(id) {
221
204
  return process.__vitest_worker__.rpc("fetch", id);
@@ -230,13 +213,13 @@ async function init(ctx) {
230
213
  async function run(ctx) {
231
214
  process.stdout.write("\0");
232
215
  const { config, port } = ctx;
233
- const rpcPromiseMap = /* @__PURE__ */ new Map();
216
+ const rpcPromiseMap = new Map();
234
217
  process.__vitest_worker__ = {
235
218
  config,
236
219
  rpc: (method, ...args) => {
237
- return new Promise((resolve3, reject) => {
220
+ return new Promise((resolve2, reject) => {
238
221
  const id = nanoid();
239
- rpcPromiseMap.set(id, { resolve: resolve3, reject });
222
+ rpcPromiseMap.set(id, { resolve: resolve2, reject });
240
223
  port.postMessage({ method, args, id });
241
224
  });
242
225
  },
@@ -259,7 +242,5 @@ async function run(ctx) {
259
242
  ctx.files.forEach((i) => moduleCache.delete(i));
260
243
  return run2(ctx.files, ctx.config);
261
244
  }
262
- export {
263
- run as default,
264
- init
265
- };
245
+
246
+ export { run as default, init };
package/global.d.ts CHANGED
@@ -3,7 +3,6 @@ declare global {
3
3
  const test: typeof import('vitest')['test']
4
4
  const describe: typeof import('vitest')['describe']
5
5
  const it: typeof import('vitest')['it']
6
- const chai: typeof import('vitest')['chai']
7
6
  const expect: typeof import('vitest')['expect']
8
7
  const assert: typeof import('vitest')['assert']
9
8
  const sinon: typeof import('vitest')['sinon']
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vitest",
3
- "version": "0.0.67",
3
+ "version": "0.0.71",
4
4
  "description": "A blazing fast unit test framework powered by Vite",
5
5
  "keywords": [
6
6
  "vite",
@@ -39,14 +39,13 @@
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",
48
48
  "lint": "eslint \"{src,test}/**/*.ts\"",
49
- "prepare": "esmo scripts/generate-types.ts",
50
49
  "prepublishOnly": "nr build",
51
50
  "release": "bumpp --commit --push --tag && esmo scripts/publish.ts",
52
51
  "test": "node bin/vitest.mjs -r test/core",
@@ -56,13 +55,14 @@
56
55
  },
57
56
  "dependencies": {
58
57
  "@types/chai": "^4.3.0",
58
+ "@types/chai-subset": "^1.3.3",
59
+ "@types/sinon": "^10.0.6",
59
60
  "@types/sinon-chai": "^3.2.6",
60
61
  "chai": "^4.3.4",
61
62
  "chai-subset": "^1.6.0",
62
63
  "fast-glob": "^3.2.7",
63
- "log-update": "^5.0.0",
64
+ "local-pkg": "^0.4.0",
64
65
  "micromatch": "^4.0.4",
65
- "picocolors": "^1.0.0",
66
66
  "piscina": "^3.2.0",
67
67
  "sinon": "^12.0.1",
68
68
  "sinon-chai": "^3.7.0",
@@ -71,14 +71,16 @@
71
71
  "devDependencies": {
72
72
  "@antfu/eslint-config": "^0.13.1",
73
73
  "@antfu/ni": "^0.12.0",
74
- "@types/chai-subset": "^1.3.3",
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/diff": "^5.0.1",
76
79
  "@types/jsdom": "^16.2.13",
77
80
  "@types/micromatch": "^4.0.2",
78
81
  "@types/natural-compare": "^1.4.1",
79
82
  "@types/node": "^16.11.12",
80
83
  "@types/sade": "^1.7.3",
81
- "@types/sinon": "^10.0.6",
82
84
  "bumpp": "^7.1.1",
83
85
  "c8": "^7.10.0",
84
86
  "cac": "^6.7.12",
@@ -90,11 +92,15 @@
90
92
  "find-up": "^6.2.0",
91
93
  "happy-dom": "^2.24.5",
92
94
  "jsdom": "^19.0.0",
95
+ "log-update": "^5.0.0",
93
96
  "nanoid": "^3.1.30",
94
97
  "natural-compare": "^1.4.0",
95
98
  "npm-run-all": "^4.1.5",
99
+ "picocolors": "^1.0.0",
96
100
  "pretty-format": "^27.4.2",
97
101
  "rimraf": "^3.0.2",
102
+ "rollup-plugin-dts": "^4.0.1",
103
+ "rollup-plugin-esbuild": "^4.7.2",
98
104
  "strip-ansi": "^7.0.1",
99
105
  "tsup": "^5.11.1",
100
106
  "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
-