vitest 0.0.64 → 0.0.68

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,9 +1,7 @@
1
1
  import { RpcCall, RpcSend, WorkerContext } from '../index';
2
- import { R as ResolvedConfig } from '../options-654578ef';
2
+ import { R as ResolvedConfig } from '../options-63a726fa';
3
3
  import 'worker_threads';
4
4
  import 'vite';
5
- import '../general-39d52683';
6
- import '@antfu/utils';
7
5
  import 'chai';
8
6
  import 'sinon';
9
7
  import 'pretty-format';
@@ -1,5 +1,264 @@
1
- import{distDir,init_esm_shims}from"../chunk-CNY47EZT.js";init_esm_shims();import{resolve as resolve2}from"path";import{nanoid}from"nanoid";init_esm_shims();import{builtinModules,createRequire}from"module";import{fileURLToPath,pathToFileURL}from"url";import{dirname,resolve}from"path";import vm from"vm";import{slash}from"@antfu/utils";var defaultInline=["vitest/dist","vitest/src","@vue","@vueuse","vue-demi","vue",/virtual:/,/\.ts$/,/\/esm\/.*\.js$/,/\.(es|esm|esm-browser|esm-bundler|es6).js$/],depsExternal=[/\.cjs.js$/],isWindows=process.platform==="win32",stubRequests={"/@vite/client":{injectQuery:id=>id,createHotContext(){return{accept:()=>{},prune:()=>{}}},updateStyle(){}}};async function interpretedImport(path,interpretDefault){let mod=await import(path);if(interpretDefault&&"__esModule"in mod&&"default"in mod){let defaultExport=mod.default;return"default"in defaultExport||Object.defineProperty(defaultExport,"default",{enumerable:!0,configurable:!0,get(){return defaultExport}}),defaultExport}return mod}async function executeInViteNode(options){let{moduleCache:moduleCache2,root,files,fetch}=options,externaled=new Set(builtinModules),result=[];for(let file of files)result.push(await cachedRequest(`/@fs/${slash(resolve(file))}`,[]));return result;async function directRequest(id,fsPath,callstack){callstack=[...callstack,id];let request=async dep=>{var _a;if(callstack.includes(dep)){let cacheKey=toFilePath(dep,root);if(!((_a=moduleCache2.get(cacheKey))==null?void 0:_a.exports))throw new Error(`Circular dependency detected
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";
13
+
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",
26
+ "@vue",
27
+ "@vueuse",
28
+ "vue-demi",
29
+ "vue",
30
+ /virtual:/,
31
+ /\.ts$/,
32
+ /\/esm\/.*\.js$/,
33
+ /\.(es|esm|esm-browser|esm-bundler|es6).js$/
34
+ ];
35
+ var depsExternal = [
36
+ /\.cjs.js$/
37
+ ];
38
+ var isWindows = process.platform === "win32";
39
+ var stubRequests = {
40
+ "/@vite/client": {
41
+ injectQuery: (id) => id,
42
+ createHotContext() {
43
+ return {
44
+ accept: () => {
45
+ },
46
+ prune: () => {
47
+ }
48
+ };
49
+ },
50
+ updateStyle() {
51
+ }
52
+ }
53
+ };
54
+ async function interpretedImport(path, interpretDefault) {
55
+ const mod = await import(path);
56
+ if (interpretDefault && "__esModule" in mod && "default" in mod) {
57
+ const defaultExport = mod.default;
58
+ if (!("default" in defaultExport)) {
59
+ Object.defineProperty(defaultExport, "default", {
60
+ enumerable: true,
61
+ configurable: true,
62
+ get() {
63
+ return defaultExport;
64
+ }
65
+ });
66
+ }
67
+ return defaultExport;
68
+ }
69
+ return mod;
70
+ }
71
+ async function executeInViteNode(options) {
72
+ const { moduleCache: moduleCache2, root, files, fetch } = options;
73
+ const externaled = new Set(builtinModules);
74
+ const result = [];
75
+ for (const file of files)
76
+ result.push(await cachedRequest(`/@fs/${slash(resolve(file))}`, []));
77
+ return result;
78
+ async function directRequest(id, fsPath, callstack) {
79
+ callstack = [...callstack, id];
80
+ const request = async (dep) => {
81
+ var _a;
82
+ if (callstack.includes(dep)) {
83
+ const cacheKey = toFilePath(dep, root);
84
+ if (!((_a = moduleCache2.get(cacheKey)) == null ? void 0 : _a.exports))
85
+ throw new Error(`Circular dependency detected
2
86
  Stack:
3
- ${[...callstack,dep].reverse().map(p=>`- ${p}`).join(`
4
- `)}`);return moduleCache2.get(cacheKey).exports}return cachedRequest(dep,callstack)};if(id in stubRequests)return stubRequests[id];let result2=await fetch(id);if(!result2)throw new Error(`failed to load ${id}`);let url=pathToFileURL(fsPath).href,exports={};setCache(fsPath,{transformResult:result2,exports});let __filename2=fileURLToPath(url),context={require:createRequire(url),__filename:__filename2,__dirname:dirname(__filename2),__vite_ssr_import__:request,__vite_ssr_dynamic_import__:request,__vite_ssr_exports__:exports,__vite_ssr_exportAll__:obj=>exportAll(exports,obj),__vite_ssr_import_meta__:{url}};return await vm.runInThisContext(`async (${Object.keys(context).join(",")})=>{${result2.code}
5
- }`,{filename:fsPath,lineOffset:0})(...Object.values(context)),exports}function setCache(id,mod){moduleCache2.has(id)?Object.assign(moduleCache2.get(id),mod):moduleCache2.set(id,mod)}async function cachedRequest(rawId,callstack){var _a,_b;let id=normalizeId(rawId);if(externaled.has(id))return interpretedImport(id,options.interpretDefault);let fsPath=toFilePath(id,root),importPath=patchWindowsImportPath(fsPath);if(externaled.has(importPath)||await shouldExternalize(importPath,options))return externaled.add(importPath),interpretedImport(importPath,options.interpretDefault);if((_a=moduleCache2.get(fsPath))==null?void 0:_a.promise)return(_b=moduleCache2.get(fsPath))==null?void 0:_b.promise;let promise=directRequest(id,fsPath,callstack);return setCache(fsPath,{promise}),await promise}function exportAll(exports,sourceModule){for(let key in sourceModule)if(key!=="default")try{Object.defineProperty(exports,key,{enumerable:!0,configurable:!0,get(){return sourceModule[key]}})}catch{}}}function normalizeId(id){return id&&id.startsWith("/@id/__x00__")&&(id=`\0${id.slice("/@id/__x00__".length)}`),id&&id.startsWith("/@id/")&&(id=id.slice("/@id/".length)),id.startsWith("__vite-browser-external:")&&(id=id.slice("__vite-browser-external:".length)),id.startsWith("node:")&&(id=id.slice("node:".length)),id}async function shouldExternalize(id,config){return matchExternalizePattern(id,config.inline)?!1:matchExternalizePattern(id,config.external)||matchExternalizePattern(id,depsExternal)?!0:matchExternalizePattern(id,defaultInline)?!1:id.includes("/node_modules/")}function toFilePath(id,root){id=slash(id);let absolute=id.startsWith("/@fs/")?id.slice(4):id.startsWith(dirname(root))?id:id.startsWith("/")?slash(resolve(root,id.slice(1))):id;return absolute.startsWith("//")&&(absolute=absolute.slice(1)),isWindows&&absolute.startsWith("/")?pathToFileURL(absolute.slice(1)).href:absolute}function matchExternalizePattern(id,patterns){for(let ex of patterns)if(typeof ex=="string"){if(id.includes(`/node_modules/${ex}/`))return!0}else if(ex.test(id))return!0;return!1}function patchWindowsImportPath(path){return path.match(/^\w:\//)?`/${path}`:path}var _run,moduleCache=new Map;async function init(ctx){if(_run)return _run;let{config}=ctx;return _run=(await executeInViteNode({root:config.root,files:[resolve2(distDir,"runtime/entry.js")],fetch(id){return process.__vitest_worker__.rpc("fetch",id)},inline:config.depsInline,external:config.depsExternal,interpretDefault:config.interpretDefault,moduleCache}))[0].run,_run}async function run(ctx){process.stdout.write("\0");let{config,port}=ctx,rpcPromiseMap=new Map;process.__vitest_worker__={config,rpc:(method,...args)=>new Promise((resolve3,reject)=>{let id=nanoid();rpcPromiseMap.set(id,{resolve:resolve3,reject}),port.postMessage({method,args,id})}),send(method,...args){port.postMessage({method,args})}},port.addListener("message",async data=>{let api=rpcPromiseMap.get(data.id);api&&(data.error?api.reject(data.error):api.resolve(data.result))});let run2=await init(ctx);return ctx.invalidates&&ctx.invalidates.forEach(i=>moduleCache.delete(i)),ctx.files.forEach(i=>moduleCache.delete(i)),run2(ctx.files,ctx.config)}export{run as default,init};
87
+ ${[...callstack, dep].reverse().map((p) => `- ${p}`).join("\n")}`);
88
+ return moduleCache2.get(cacheKey).exports;
89
+ }
90
+ return cachedRequest(dep, callstack);
91
+ };
92
+ if (id in stubRequests)
93
+ return stubRequests[id];
94
+ const result2 = await fetch(id);
95
+ if (!result2)
96
+ throw new Error(`failed to load ${id}`);
97
+ const url = pathToFileURL(fsPath).href;
98
+ const exports = {};
99
+ setCache(fsPath, { transformResult: result2, exports });
100
+ const __filename2 = fileURLToPath(url);
101
+ const context = {
102
+ require: createRequire(url),
103
+ __filename: __filename2,
104
+ __dirname: dirname(__filename2),
105
+ __vite_ssr_import__: request,
106
+ __vite_ssr_dynamic_import__: request,
107
+ __vite_ssr_exports__: exports,
108
+ __vite_ssr_exportAll__: (obj) => exportAll(exports, obj),
109
+ __vite_ssr_import_meta__: { url }
110
+ };
111
+ const fn = vm.runInThisContext(`async (${Object.keys(context).join(",")})=>{${result2.code}
112
+ }`, {
113
+ filename: fsPath,
114
+ lineOffset: 0
115
+ });
116
+ await fn(...Object.values(context));
117
+ return exports;
118
+ }
119
+ function setCache(id, mod) {
120
+ if (!moduleCache2.has(id))
121
+ moduleCache2.set(id, mod);
122
+ else
123
+ Object.assign(moduleCache2.get(id), mod);
124
+ }
125
+ async function cachedRequest(rawId, callstack) {
126
+ var _a, _b;
127
+ const id = normalizeId(rawId);
128
+ if (externaled.has(id))
129
+ return interpretedImport(id, options.interpretDefault);
130
+ const fsPath = toFilePath(id, root);
131
+ const importPath = patchWindowsImportPath(fsPath);
132
+ if (externaled.has(importPath) || await shouldExternalize(importPath, options)) {
133
+ externaled.add(importPath);
134
+ return interpretedImport(importPath, options.interpretDefault);
135
+ }
136
+ if ((_a = moduleCache2.get(fsPath)) == null ? void 0 : _a.promise)
137
+ return (_b = moduleCache2.get(fsPath)) == null ? void 0 : _b.promise;
138
+ const promise = directRequest(id, fsPath, callstack);
139
+ setCache(fsPath, { promise });
140
+ return await promise;
141
+ }
142
+ function exportAll(exports, sourceModule) {
143
+ for (const key in sourceModule) {
144
+ if (key !== "default") {
145
+ try {
146
+ Object.defineProperty(exports, key, {
147
+ enumerable: true,
148
+ configurable: true,
149
+ get() {
150
+ return sourceModule[key];
151
+ }
152
+ });
153
+ } catch (_err) {
154
+ }
155
+ }
156
+ }
157
+ }
158
+ }
159
+ function normalizeId(id) {
160
+ if (id && id.startsWith("/@id/__x00__"))
161
+ id = `\0${id.slice("/@id/__x00__".length)}`;
162
+ if (id && id.startsWith("/@id/"))
163
+ id = id.slice("/@id/".length);
164
+ if (id.startsWith("__vite-browser-external:"))
165
+ id = id.slice("__vite-browser-external:".length);
166
+ if (id.startsWith("node:"))
167
+ id = id.slice("node:".length);
168
+ return id;
169
+ }
170
+ async function shouldExternalize(id, config) {
171
+ if (matchExternalizePattern(id, config.inline))
172
+ return false;
173
+ if (matchExternalizePattern(id, config.external))
174
+ return true;
175
+ if (matchExternalizePattern(id, depsExternal))
176
+ return true;
177
+ if (matchExternalizePattern(id, defaultInline))
178
+ return false;
179
+ return id.includes("/node_modules/");
180
+ }
181
+ function toFilePath(id, root) {
182
+ id = slash(id);
183
+ let absolute = id.startsWith("/@fs/") ? id.slice(4) : id.startsWith(dirname(root)) ? id : id.startsWith("/") ? slash(resolve(root, id.slice(1))) : id;
184
+ if (absolute.startsWith("//"))
185
+ absolute = absolute.slice(1);
186
+ return isWindows && absolute.startsWith("/") ? pathToFileURL(absolute.slice(1)).href : absolute;
187
+ }
188
+ function matchExternalizePattern(id, patterns) {
189
+ for (const ex of patterns) {
190
+ if (typeof ex === "string") {
191
+ if (id.includes(`/node_modules/${ex}/`))
192
+ return true;
193
+ } else {
194
+ if (ex.test(id))
195
+ return true;
196
+ }
197
+ }
198
+ return false;
199
+ }
200
+ function patchWindowsImportPath(path) {
201
+ if (path.match(/^\w:\//))
202
+ return `/${path}`;
203
+ else
204
+ return path;
205
+ }
206
+
207
+ // src/runtime/worker.ts
208
+ var _run;
209
+ var moduleCache = /* @__PURE__ */ new Map();
210
+ async function init(ctx) {
211
+ if (_run)
212
+ return _run;
213
+ const { config } = ctx;
214
+ _run = (await executeInViteNode({
215
+ root: config.root,
216
+ files: [
217
+ resolve2(distDir, "runtime/entry.js")
218
+ ],
219
+ fetch(id) {
220
+ return process.__vitest_worker__.rpc("fetch", id);
221
+ },
222
+ inline: config.depsInline,
223
+ external: config.depsExternal,
224
+ interpretDefault: config.interpretDefault,
225
+ moduleCache
226
+ }))[0].run;
227
+ return _run;
228
+ }
229
+ async function run(ctx) {
230
+ process.stdout.write("\0");
231
+ const { config, port } = ctx;
232
+ const rpcPromiseMap = /* @__PURE__ */ new Map();
233
+ process.__vitest_worker__ = {
234
+ config,
235
+ rpc: (method, ...args) => {
236
+ return new Promise((resolve3, reject) => {
237
+ const id = nanoid();
238
+ rpcPromiseMap.set(id, { resolve: resolve3, reject });
239
+ port.postMessage({ method, args, id });
240
+ });
241
+ },
242
+ send(method, ...args) {
243
+ port.postMessage({ method, args });
244
+ }
245
+ };
246
+ port.addListener("message", async (data) => {
247
+ const api = rpcPromiseMap.get(data.id);
248
+ if (api) {
249
+ if (data.error)
250
+ api.reject(data.error);
251
+ else
252
+ api.resolve(data.result);
253
+ }
254
+ });
255
+ const run2 = await init(ctx);
256
+ if (ctx.invalidates)
257
+ ctx.invalidates.forEach((i) => moduleCache.delete(i));
258
+ ctx.files.forEach((i) => moduleCache.delete(i));
259
+ return run2(ctx.files, ctx.config);
260
+ }
261
+ export {
262
+ run as default,
263
+ init
264
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vitest",
3
- "version": "0.0.64",
3
+ "version": "0.0.68",
4
4
  "description": "A blazing fast unit test framework powered by Vite",
5
5
  "keywords": [
6
6
  "vite",
@@ -39,43 +39,34 @@
39
39
  "*.d.ts"
40
40
  ],
41
41
  "scripts": {
42
- "build": "tsup --dts --minify-whitespace --minify-syntax",
42
+ "build": "tsup --dts",
43
43
  "coverage": "node bin/vitest.mjs -r test/core --coverage",
44
44
  "dev": "tsup --watch src",
45
- "typecheck": "tsc --noEmit",
45
+ "docs": "npm -C docs run dev",
46
+ "docs:build": "npm -C docs run build",
47
+ "docs:serve": "npm -C docs run serve",
46
48
  "lint": "eslint \"{src,test}/**/*.ts\"",
47
49
  "prepare": "esmo scripts/generate-types.ts",
48
50
  "prepublishOnly": "nr build",
49
51
  "release": "bumpp --commit --push --tag && esmo scripts/publish.ts",
50
52
  "test": "node bin/vitest.mjs -r test/core",
51
- "test:all": "pnpm -r --stream --filter !vitest run test --",
52
- "test:ci": "pnpm -r --stream --filter !vitest --filter !@vitest/test-fails run test --",
53
- "docs": "npm -C docs run dev",
54
- "docs:build": "npm -C docs run build",
55
- "docs:serve": "npm -C docs run serve"
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
+ "typecheck": "tsc --noEmit && nr lint"
56
56
  },
57
57
  "dependencies": {
58
- "@antfu/utils": "^0.3.0",
59
58
  "@types/chai": "^4.3.0",
60
59
  "@types/sinon-chai": "^3.2.6",
61
60
  "chai": "^4.3.4",
62
61
  "chai-subset": "^1.6.0",
63
- "cli-truncate": "^3.1.0",
64
- "diff": "^5.0.0",
65
62
  "fast-glob": "^3.2.7",
66
- "find-up": "^6.2.0",
67
63
  "log-update": "^5.0.0",
68
64
  "micromatch": "^4.0.4",
69
- "nanoid": "^3.1.30",
70
65
  "picocolors": "^1.0.0",
71
66
  "piscina": "^3.2.0",
72
- "pretty-format": "^27.4.2",
73
- "sade": "^1.7.4",
74
67
  "sinon": "^12.0.1",
75
68
  "sinon-chai": "^3.7.0",
76
- "source-map": "^0.7.3",
77
- "source-map-support": "^0.5.21",
78
- "strip-ansi": "^7.0.1"
69
+ "source-map": "^0.7.3"
79
70
  },
80
71
  "devDependencies": {
81
72
  "@antfu/eslint-config": "^0.13.1",
@@ -88,15 +79,23 @@
88
79
  "@types/node": "^16.11.12",
89
80
  "@types/sade": "^1.7.3",
90
81
  "@types/sinon": "^10.0.6",
91
- "@types/source-map-support": "^0.5.4",
92
82
  "bumpp": "^7.1.1",
93
83
  "c8": "^7.10.0",
84
+ "cac": "^6.7.12",
85
+ "cli-truncate": "^3.1.0",
86
+ "cross-env": "^7.0.3",
87
+ "diff": "^5.0.0",
94
88
  "eslint": "^8.4.1",
95
89
  "esno": "^0.12.1",
90
+ "find-up": "^6.2.0",
96
91
  "happy-dom": "^2.24.5",
97
92
  "jsdom": "^19.0.0",
93
+ "nanoid": "^3.1.30",
94
+ "natural-compare": "^1.4.0",
98
95
  "npm-run-all": "^4.1.5",
96
+ "pretty-format": "^27.4.2",
99
97
  "rimraf": "^3.0.2",
98
+ "strip-ansi": "^7.0.1",
100
99
  "tsup": "^5.11.1",
101
100
  "typescript": "^4.5.3",
102
101
  "vite": "^2.7.1"
@@ -108,13 +107,13 @@
108
107
  "vite": "^2.7.1"
109
108
  },
110
109
  "peerDependenciesMeta": {
111
- "happy-dom": {
110
+ "c8": {
112
111
  "optional": true
113
112
  },
114
- "jsdom": {
113
+ "happy-dom": {
115
114
  "optional": true
116
115
  },
117
- "c8": {
116
+ "jsdom": {
118
117
  "optional": true
119
118
  }
120
119
  },
@@ -1 +0,0 @@
1
- import{afterAll,afterEach,beforeAll,beforeEach,clearContext,createSuiteHooks,defaultSuite,describe,it,suite,test}from"./chunk-3VLG4URE.js";import{__export,init_esm_shims}from"./chunk-CNY47EZT.js";var src_exports={};__export(src_exports,{afterAll:()=>afterAll,afterEach:()=>afterEach,assert:()=>assert,beforeAll:()=>beforeAll,beforeEach:()=>beforeEach,chai:()=>chai,clearContext:()=>clearContext,createSuiteHooks:()=>createSuiteHooks,defaultSuite:()=>defaultSuite,describe:()=>describe,expect:()=>expect,it:()=>it,mock:()=>mock,should:()=>should,sinon:()=>sinon,spy:()=>spy,stub:()=>stub,suite:()=>suite,test:()=>test});init_esm_shims();init_esm_shims();init_esm_shims();init_esm_shims();init_esm_shims();init_esm_shims();init_esm_shims();init_esm_shims();init_esm_shims();import chai from"chai";import{assert,should,expect}from"chai";init_esm_shims();import sinon from"sinon";var{mock,spy,stub}=sinon;sinon.fn=sinon.spy;export{chai,assert,should,expect,sinon,mock,spy,stub,src_exports};
@@ -1 +0,0 @@
1
- import{defaultHookTimeout,defaultTestTimeout,init_esm_shims}from"./chunk-CNY47EZT.js";init_esm_shims();import{nanoid}from"nanoid";init_esm_shims();var context={tasks:[],currentSuite:null};init_esm_shims();var fnMap=new WeakMap,hooksMap=new WeakMap;function setFn(key,fn){fnMap.set(key,fn)}function getFn(key){return fnMap.get(key)}function setHooks(key,hooks){hooksMap.set(key,hooks)}function getHooks(key){return hooksMap.get(key)}var suite=createSuite(),defaultSuite=suite("");function getCurrentSuite(){return context.currentSuite||defaultSuite}function createSuiteHooks(){return{beforeAll:[],afterAll:[],beforeEach:[],afterEach:[]}}function createSuiteCollector(name,factory=()=>{},mode,suiteComputeMode){var _a;let tasks=[],factoryQueue=[],suite2;initSuite();let test2=createTestCollector((name2,fn,mode2,computeMode)=>{let test3={id:nanoid(),type:"test",name:name2,mode:mode2,computeMode:computeMode??suiteComputeMode??"serial",suite:void 0};setFn(test3,fn),tasks.push(test3)}),collector={type:"collector",name,mode,test:test2,tasks,collect,clear,on:addHook};function addHook(name2,...fn){getHooks(suite2)[name2].push(...fn)}function initSuite(){suite2={id:nanoid(),type:"suite",computeMode:"serial",name,mode,tasks:[]},setHooks(suite2,createSuiteHooks())}function clear(){tasks.length=0,factoryQueue.length=0,initSuite()}async function collect(file){if(factoryQueue.length=0,factory){let prev=context.currentSuite;context.currentSuite=collector,await factory(test2),context.currentSuite=prev}let allChildren=await Promise.all([...factoryQueue,...tasks].map(i=>i.type==="collector"?i.collect(file):i));return suite2.file=file,suite2.tasks=allChildren,allChildren.forEach(task=>{task.suite=suite2,file&&(task.file=file)}),suite2}return(_a=context.currentSuite)==null||_a.tasks.push(collector),collector}function createTestCollector(collectTest){function test2(name,fn,timeout){collectTest(name,withTimeout(fn,timeout),"run")}test2.concurrent=concurrent,test2.skip=skip,test2.only=only,test2.todo=todo;function concurrent(name,fn,timeout){collectTest(name,withTimeout(fn,timeout),"run","concurrent")}concurrent.skip=(name,fn,timeout)=>collectTest(name,withTimeout(fn,timeout),"skip","concurrent"),concurrent.only=(name,fn,timeout)=>collectTest(name,withTimeout(fn,timeout),"only","concurrent"),concurrent.todo=todo;function skip(name,fn,timeout){collectTest(name,withTimeout(fn,timeout),"skip")}skip.concurrent=concurrent.skip;function only(name,fn,timeout){collectTest(name,withTimeout(fn,timeout),"only")}only.concurrent=concurrent.only;function todo(name){collectTest(name,()=>{},"todo")}return todo.concurrent=todo,test2}var test=function(){function test2(name,fn,timeout){return getCurrentSuite().test(name,fn,timeout)}function concurrent(name,fn,timeout){return getCurrentSuite().test.concurrent(name,fn,timeout)}concurrent.skip=(name,fn,timeout)=>getCurrentSuite().test.concurrent.skip(name,fn,timeout),concurrent.only=(name,fn,timeout)=>getCurrentSuite().test.concurrent.only(name,fn,timeout),concurrent.todo=name=>getCurrentSuite().test.concurrent.todo(name);function skip(name,fn,timeout){return getCurrentSuite().test.skip(name,fn,timeout)}skip.concurrent=(name,fn,timeout)=>getCurrentSuite().test.skip.concurrent(name,fn,timeout);function only(name,fn,timeout){return getCurrentSuite().test.only(name,fn,timeout)}only.concurrent=(name,fn,timeout)=>getCurrentSuite().test.only.concurrent(name,fn,timeout);function todo(name){return getCurrentSuite().test.todo(name)}return todo.concurrent=name=>getCurrentSuite().test.todo.concurrent(name),test2.concurrent=concurrent,test2.skip=skip,test2.only=only,test2.todo=todo,test2}();function createSuite(){function suite2(suiteName,factory){return createSuiteCollector(suiteName,factory,"run")}function concurrent(suiteName,factory){return createSuiteCollector(suiteName,factory,"run","concurrent")}concurrent.skip=(suiteName,factory)=>createSuiteCollector(suiteName,factory,"skip","concurrent"),concurrent.only=(suiteName,factory)=>createSuiteCollector(suiteName,factory,"only","concurrent"),concurrent.todo=suiteName=>createSuiteCollector(suiteName,void 0,"todo");function skip(suiteName,factory){return createSuiteCollector(suiteName,factory,"skip")}skip.concurrent=concurrent.skip;function only(suiteName,factory){return createSuiteCollector(suiteName,factory,"only")}only.concurrent=concurrent.only;function todo(suiteName){return createSuiteCollector(suiteName,void 0,"todo")}return todo.concurrent=concurrent.todo,suite2.concurrent=concurrent,suite2.skip=skip,suite2.only=only,suite2.todo=todo,suite2}var describe=suite,it=test,beforeAll=(fn,timeout=defaultHookTimeout)=>getCurrentSuite().on("beforeAll",withTimeout(fn,timeout)),afterAll=(fn,timeout=defaultHookTimeout)=>getCurrentSuite().on("afterAll",withTimeout(fn,timeout)),beforeEach=(fn,timeout=defaultHookTimeout)=>getCurrentSuite().on("beforeEach",withTimeout(fn,timeout)),afterEach=(fn,timeout=defaultHookTimeout)=>getCurrentSuite().on("afterEach",withTimeout(fn,timeout));function clearContext(){context.tasks.length=0,defaultSuite.clear(),context.currentSuite=defaultSuite}function withTimeout(fn,timeout=defaultTestTimeout){return timeout<=0||timeout===1/0?fn:(...args)=>Promise.race([fn(...args),new Promise((resolve,reject)=>{let timer=setTimeout(()=>{clearTimeout(timer),reject(new Error(`Test timed out in ${timeout}ms.`))},timeout);timer.unref()})])}export{context,getFn,setHooks,getHooks,suite,defaultSuite,createSuiteHooks,test,describe,it,beforeAll,afterAll,beforeEach,afterEach,clearContext};
@@ -1 +0,0 @@
1
- var __create=Object.create;var __defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropNames=Object.getOwnPropertyNames,__getOwnPropSymbols=Object.getOwnPropertySymbols,__getProtoOf=Object.getPrototypeOf,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable;var __defNormalProp=(obj,key,value)=>key in obj?__defProp(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value,__spreadValues=(a,b)=>{for(var prop in b||(b={}))__hasOwnProp.call(b,prop)&&__defNormalProp(a,prop,b[prop]);if(__getOwnPropSymbols)for(var prop of __getOwnPropSymbols(b))__propIsEnum.call(b,prop)&&__defNormalProp(a,prop,b[prop]);return a},__spreadProps=(a,b)=>__defProps(a,__getOwnPropDescs(b)),__markAsModule=target=>__defProp(target,"__esModule",{value:!0});var __esm=(fn,res)=>function(){return fn&&(res=(0,fn[Object.keys(fn)[0]])(fn=0)),res};var __commonJS=(cb,mod)=>function(){return mod||(0,cb[Object.keys(cb)[0]])((mod={exports:{}}).exports,mod),mod.exports};var __export=(target,all)=>{__markAsModule(target);for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__reExport=(target,module,desc)=>{if(module&&typeof module=="object"||typeof module=="function")for(let key of __getOwnPropNames(module))!__hasOwnProp.call(target,key)&&key!=="default"&&__defProp(target,key,{get:()=>module[key],enumerable:!(desc=__getOwnPropDesc(module,key))||desc.enumerable});return target},__toModule=module=>__reExport(__markAsModule(__defProp(module!=null?__create(__getProtoOf(module)):{},"default",module&&module.__esModule&&"default"in module?{get:()=>module.default,enumerable:!0}:{value:module,enumerable:!0})),module);import{fileURLToPath}from"url";import path from"path";var init_esm_shims=__esm({"node_modules/.pnpm/tsup@5.11.1_typescript@4.5.3/node_modules/tsup/assets/esm_shims.js"(){}});init_esm_shims();import{resolve}from"path";import{fileURLToPath as fileURLToPath2}from"url";var distDir=resolve(fileURLToPath2(import.meta.url),"../../dist"),defaultTestTimeout=5e3,defaultHookTimeout=5e3,defaultIncludes=["**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"],defaultExcludes=["**/node_modules/**","**/dist/**"],globalApis=["suite","test","describe","it","chai","expect","assert","sinon","spy","mock","stub","beforeAll","afterAll","beforeEach","afterEach"];export{__spreadValues,__spreadProps,__commonJS,__export,__toModule,init_esm_shims,distDir,defaultTestTimeout,defaultHookTimeout,defaultIncludes,defaultExcludes,globalApis};
@@ -1 +0,0 @@
1
- import{init_esm_shims}from"./chunk-CNY47EZT.js";init_esm_shims();import{toArray}from"@antfu/utils";function partitionSuiteChildren(suite){let tasksGroup=[],tasksGroups=[];for(let c of suite.tasks)tasksGroup.length===0||c.computeMode===tasksGroup[0].computeMode?tasksGroup.push(c):(tasksGroups.push(tasksGroup),tasksGroup=[c]);return tasksGroup.length>0&&tasksGroups.push(tasksGroup),tasksGroups}function interpretOnlyMode(items){items.some(i=>i.mode==="only")&&items.forEach(i=>{i.mode==="run"?i.mode="skip":i.mode==="only"&&(i.mode="run")})}function getTests(suite){return toArray(suite).flatMap(s=>s.tasks.flatMap(c=>c.type==="test"?[c]:getTests(c)))}function getSuites(suite){return toArray(suite).flatMap(s=>s.type==="suite"?[s,...getSuites(s.tasks)]:[])}function hasTests(suite){return toArray(suite).some(s=>s.tasks.some(c=>c.type==="test"||hasTests(c)))}function hasFailed(suite){return toArray(suite).some(s=>{var _a;return((_a=s.result)==null?void 0:_a.state)==="fail"||s.type==="suite"&&hasFailed(s.tasks)})}function getNames(task){let names=[task.name],current=task;for(;(current==null?void 0:current.suite)||(current==null?void 0:current.file);)current=current.suite||current.file,(current==null?void 0:current.name)&&names.unshift(current.name);return names}init_esm_shims();var emptySummary=options=>({added:0,failure:!1,filesAdded:0,filesRemoved:0,filesRemovedList:[],filesUnmatched:0,filesUpdated:0,matched:0,total:0,unchecked:0,uncheckedKeysByFile:[],unmatched:0,updated:0,didUpdate:options.updateSnapshot==="all"}),packSnapshotState=(filepath,state)=>{let snapshot={filepath,added:0,fileDeleted:!1,matched:0,unchecked:0,uncheckedKeys:[],unmatched:0,updated:0},uncheckedCount=state.getUncheckedCount(),uncheckedKeys=state.getUncheckedKeys();uncheckedCount&&state.removeUncheckedKeys();let status=state.save();return snapshot.fileDeleted=status.deleted,snapshot.added=state.added,snapshot.matched=state.matched,snapshot.unmatched=state.unmatched,snapshot.updated=state.updated,snapshot.unchecked=status.deleted?0:uncheckedCount,snapshot.uncheckedKeys=Array.from(uncheckedKeys),snapshot},addSnapshotResult=(summary,result)=>{result.added&&summary.filesAdded++,result.fileDeleted&&summary.filesRemoved++,result.unmatched&&summary.filesUnmatched++,result.updated&&summary.filesUpdated++,summary.added+=result.added,summary.matched+=result.matched,summary.unchecked+=result.unchecked,result.uncheckedKeys&&result.uncheckedKeys.length>0&&summary.uncheckedKeysByFile.push({filePath:result.filepath,keys:result.uncheckedKeys}),summary.unmatched+=result.unmatched,summary.updated+=result.updated,summary.total+=result.added+result.matched+result.unmatched+result.updated};export{partitionSuiteChildren,interpretOnlyMode,getTests,getSuites,hasTests,hasFailed,getNames,emptySummary,packSnapshotState,addSnapshotResult};
@@ -1,43 +0,0 @@
1
- import { Awaitable } from '@antfu/utils';
2
- import { TransformResult, ViteDevServer } from 'vite';
3
- import { F as File, l as Task, T as TaskResultPack, R as ResolvedConfig, t as SnapshotSummary, S as SnapshotResult, n as Reporter } from './options-654578ef';
4
-
5
- declare class StateManager {
6
- filesMap: Record<string, File>;
7
- idMap: Record<string, Task>;
8
- taskFileMap: WeakMap<Task, File>;
9
- getFiles(keys?: string[]): File[];
10
- collectFiles(files: File[]): void;
11
- updateId(task: Task): void;
12
- updateTasks(packs: TaskResultPack[]): void;
13
- }
14
-
15
- declare class SnapshotManager {
16
- config: ResolvedConfig;
17
- summary: SnapshotSummary;
18
- constructor(config: ResolvedConfig);
19
- clear(): void;
20
- add(result: SnapshotResult): void;
21
- }
22
-
23
- interface ModuleCache {
24
- promise?: Promise<any>;
25
- exports?: any;
26
- transformResult?: TransformResult;
27
- }
28
- interface EnvironmentReturn {
29
- teardown: (global: any) => Awaitable<void>;
30
- }
31
- interface Environment {
32
- name: string;
33
- setup(global: any): Awaitable<EnvironmentReturn>;
34
- }
35
- interface VitestContext {
36
- config: ResolvedConfig;
37
- server: ViteDevServer;
38
- state: StateManager;
39
- snapshot: SnapshotManager;
40
- reporter: Reporter;
41
- }
42
-
43
- export { EnvironmentReturn as E, ModuleCache as M, VitestContext as V, Environment as a };
@@ -1 +0,0 @@
1
- import{src_exports}from"./chunk-3P4SNPBT.js";import"./chunk-3VLG4URE.js";import{globalApis,init_esm_shims}from"./chunk-CNY47EZT.js";init_esm_shims();function registerApiGlobally(){globalApis.forEach(api=>{globalThis[api]=src_exports[api]})}export{registerApiGlobally};