vitest 0.0.64 → 0.0.65

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-652352ad';
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,261 @@
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-NK2VTQLQ.js";
4
+ import {
5
+ nanoid
6
+ } from "../chunk-3GMBTS5G.js";
7
+ import {
8
+ distDir,
9
+ init_esm_shims
10
+ } from "../chunk-RNHB4AXG.js";
11
+
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 = [
23
+ "@vue",
24
+ "@vueuse",
25
+ "vue-demi",
26
+ "vue",
27
+ /virtual:/,
28
+ /\.ts$/,
29
+ /\/esm\/.*\.js$/,
30
+ /\.(es|esm|esm-browser|esm-bundler|es6).js$/
31
+ ];
32
+ var depsExternal = [
33
+ /\.cjs.js$/
34
+ ];
35
+ var isWindows = process.platform === "win32";
36
+ var stubRequests = {
37
+ "/@vite/client": {
38
+ injectQuery: (id) => id,
39
+ createHotContext() {
40
+ return {
41
+ accept: () => {
42
+ },
43
+ prune: () => {
44
+ }
45
+ };
46
+ },
47
+ updateStyle() {
48
+ }
49
+ }
50
+ };
51
+ async function interpretedImport(path, interpretDefault) {
52
+ const mod = await import(path);
53
+ if (interpretDefault && "__esModule" in mod && "default" in mod) {
54
+ const defaultExport = mod.default;
55
+ if (!("default" in defaultExport)) {
56
+ Object.defineProperty(defaultExport, "default", {
57
+ enumerable: true,
58
+ configurable: true,
59
+ get() {
60
+ return defaultExport;
61
+ }
62
+ });
63
+ }
64
+ return defaultExport;
65
+ }
66
+ return mod;
67
+ }
68
+ async function executeInViteNode(options) {
69
+ const { moduleCache: moduleCache2, root, files, fetch } = options;
70
+ const externaled = new Set(builtinModules);
71
+ const result = [];
72
+ for (const file of files)
73
+ result.push(await cachedRequest(`/@fs/${slash(resolve(file))}`, []));
74
+ return result;
75
+ async function directRequest(id, fsPath, callstack) {
76
+ callstack = [...callstack, id];
77
+ const request = async (dep) => {
78
+ var _a;
79
+ if (callstack.includes(dep)) {
80
+ const cacheKey = toFilePath(dep, root);
81
+ if (!((_a = moduleCache2.get(cacheKey)) == null ? void 0 : _a.exports))
82
+ throw new Error(`Circular dependency detected
2
83
  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};
84
+ ${[...callstack, dep].reverse().map((p) => `- ${p}`).join("\n")}`);
85
+ return moduleCache2.get(cacheKey).exports;
86
+ }
87
+ return cachedRequest(dep, callstack);
88
+ };
89
+ if (id in stubRequests)
90
+ return stubRequests[id];
91
+ const result2 = await fetch(id);
92
+ if (!result2)
93
+ throw new Error(`failed to load ${id}`);
94
+ const url = pathToFileURL(fsPath).href;
95
+ const exports = {};
96
+ setCache(fsPath, { transformResult: result2, exports });
97
+ const __filename2 = fileURLToPath(url);
98
+ const context = {
99
+ require: createRequire(url),
100
+ __filename: __filename2,
101
+ __dirname: dirname(__filename2),
102
+ __vite_ssr_import__: request,
103
+ __vite_ssr_dynamic_import__: request,
104
+ __vite_ssr_exports__: exports,
105
+ __vite_ssr_exportAll__: (obj) => exportAll(exports, obj),
106
+ __vite_ssr_import_meta__: { url }
107
+ };
108
+ const fn = vm.runInThisContext(`async (${Object.keys(context).join(",")})=>{${result2.code}
109
+ }`, {
110
+ filename: fsPath,
111
+ lineOffset: 0
112
+ });
113
+ await fn(...Object.values(context));
114
+ return exports;
115
+ }
116
+ function setCache(id, mod) {
117
+ if (!moduleCache2.has(id))
118
+ moduleCache2.set(id, mod);
119
+ else
120
+ Object.assign(moduleCache2.get(id), mod);
121
+ }
122
+ async function cachedRequest(rawId, callstack) {
123
+ var _a, _b;
124
+ const id = normalizeId(rawId);
125
+ if (externaled.has(id))
126
+ return interpretedImport(id, options.interpretDefault);
127
+ const fsPath = toFilePath(id, root);
128
+ const importPath = patchWindowsImportPath(fsPath);
129
+ if (externaled.has(importPath) || await shouldExternalize(importPath, options)) {
130
+ externaled.add(importPath);
131
+ return interpretedImport(importPath, options.interpretDefault);
132
+ }
133
+ if ((_a = moduleCache2.get(fsPath)) == null ? void 0 : _a.promise)
134
+ return (_b = moduleCache2.get(fsPath)) == null ? void 0 : _b.promise;
135
+ const promise = directRequest(id, fsPath, callstack);
136
+ setCache(fsPath, { promise });
137
+ return await promise;
138
+ }
139
+ function exportAll(exports, sourceModule) {
140
+ for (const key in sourceModule) {
141
+ if (key !== "default") {
142
+ try {
143
+ Object.defineProperty(exports, key, {
144
+ enumerable: true,
145
+ configurable: true,
146
+ get() {
147
+ return sourceModule[key];
148
+ }
149
+ });
150
+ } catch (_err) {
151
+ }
152
+ }
153
+ }
154
+ }
155
+ }
156
+ function normalizeId(id) {
157
+ if (id && id.startsWith("/@id/__x00__"))
158
+ id = `\0${id.slice("/@id/__x00__".length)}`;
159
+ if (id && id.startsWith("/@id/"))
160
+ id = id.slice("/@id/".length);
161
+ if (id.startsWith("__vite-browser-external:"))
162
+ id = id.slice("__vite-browser-external:".length);
163
+ if (id.startsWith("node:"))
164
+ id = id.slice("node:".length);
165
+ return id;
166
+ }
167
+ async function shouldExternalize(id, config) {
168
+ if (matchExternalizePattern(id, config.inline))
169
+ return false;
170
+ if (matchExternalizePattern(id, config.external))
171
+ return true;
172
+ if (matchExternalizePattern(id, depsExternal))
173
+ return true;
174
+ if (matchExternalizePattern(id, defaultInline))
175
+ return false;
176
+ return id.includes("/node_modules/");
177
+ }
178
+ function toFilePath(id, root) {
179
+ id = slash(id);
180
+ let absolute = id.startsWith("/@fs/") ? id.slice(4) : id.startsWith(dirname(root)) ? id : id.startsWith("/") ? slash(resolve(root, id.slice(1))) : id;
181
+ if (absolute.startsWith("//"))
182
+ absolute = absolute.slice(1);
183
+ return isWindows && absolute.startsWith("/") ? pathToFileURL(absolute.slice(1)).href : absolute;
184
+ }
185
+ function matchExternalizePattern(id, patterns) {
186
+ for (const ex of patterns) {
187
+ if (typeof ex === "string") {
188
+ if (id.includes(`/node_modules/${ex}/`))
189
+ return true;
190
+ } else {
191
+ if (ex.test(id))
192
+ return true;
193
+ }
194
+ }
195
+ return false;
196
+ }
197
+ function patchWindowsImportPath(path) {
198
+ if (path.match(/^\w:\//))
199
+ return `/${path}`;
200
+ else
201
+ return path;
202
+ }
203
+
204
+ // src/runtime/worker.ts
205
+ var _run;
206
+ var moduleCache = /* @__PURE__ */ new Map();
207
+ async function init(ctx) {
208
+ if (_run)
209
+ return _run;
210
+ const { config } = ctx;
211
+ _run = (await executeInViteNode({
212
+ root: config.root,
213
+ files: [
214
+ resolve2(distDir, "runtime/entry.js")
215
+ ],
216
+ fetch(id) {
217
+ return process.__vitest_worker__.rpc("fetch", id);
218
+ },
219
+ inline: config.depsInline,
220
+ external: config.depsExternal,
221
+ interpretDefault: config.interpretDefault,
222
+ moduleCache
223
+ }))[0].run;
224
+ return _run;
225
+ }
226
+ async function run(ctx) {
227
+ process.stdout.write("\0");
228
+ const { config, port } = ctx;
229
+ const rpcPromiseMap = /* @__PURE__ */ new Map();
230
+ process.__vitest_worker__ = {
231
+ config,
232
+ rpc: (method, ...args) => {
233
+ return new Promise((resolve3, reject) => {
234
+ const id = nanoid();
235
+ rpcPromiseMap.set(id, { resolve: resolve3, reject });
236
+ port.postMessage({ method, args, id });
237
+ });
238
+ },
239
+ send(method, ...args) {
240
+ port.postMessage({ method, args });
241
+ }
242
+ };
243
+ port.addListener("message", async (data) => {
244
+ const api = rpcPromiseMap.get(data.id);
245
+ if (api) {
246
+ if (data.error)
247
+ api.reject(data.error);
248
+ else
249
+ api.resolve(data.result);
250
+ }
251
+ });
252
+ const run2 = await init(ctx);
253
+ if (ctx.invalidates)
254
+ ctx.invalidates.forEach((i) => moduleCache.delete(i));
255
+ ctx.files.forEach((i) => moduleCache.delete(i));
256
+ return run2(ctx.files, ctx.config);
257
+ }
258
+ export {
259
+ run as default,
260
+ init
261
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vitest",
3
- "version": "0.0.64",
3
+ "version": "0.0.65",
4
4
  "description": "A blazing fast unit test framework powered by Vite",
5
5
  "keywords": [
6
6
  "vite",
@@ -39,10 +39,12 @@
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",
@@ -50,32 +52,22 @@
50
52
  "test": "node bin/vitest.mjs -r test/core",
51
53
  "test:all": "pnpm -r --stream --filter !vitest run test --",
52
54
  "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"
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
67
  "sade": "^1.7.4",
74
68
  "sinon": "^12.0.1",
75
69
  "sinon-chai": "^3.7.0",
76
- "source-map": "^0.7.3",
77
- "source-map-support": "^0.5.21",
78
- "strip-ansi": "^7.0.1"
70
+ "source-map": "^0.7.3"
79
71
  },
80
72
  "devDependencies": {
81
73
  "@antfu/eslint-config": "^0.13.1",
@@ -88,15 +80,21 @@
88
80
  "@types/node": "^16.11.12",
89
81
  "@types/sade": "^1.7.3",
90
82
  "@types/sinon": "^10.0.6",
91
- "@types/source-map-support": "^0.5.4",
92
83
  "bumpp": "^7.1.1",
93
84
  "c8": "^7.10.0",
85
+ "cli-truncate": "^3.1.0",
86
+ "diff": "^5.0.0",
94
87
  "eslint": "^8.4.1",
95
88
  "esno": "^0.12.1",
89
+ "find-up": "^6.2.0",
96
90
  "happy-dom": "^2.24.5",
97
91
  "jsdom": "^19.0.0",
92
+ "nanoid": "^3.1.30",
93
+ "natural-compare": "^1.4.0",
98
94
  "npm-run-all": "^4.1.5",
95
+ "pretty-format": "^27.4.2",
99
96
  "rimraf": "^3.0.2",
97
+ "strip-ansi": "^7.0.1",
100
98
  "tsup": "^5.11.1",
101
99
  "typescript": "^4.5.3",
102
100
  "vite": "^2.7.1"
@@ -108,13 +106,13 @@
108
106
  "vite": "^2.7.1"
109
107
  },
110
108
  "peerDependenciesMeta": {
111
- "happy-dom": {
109
+ "c8": {
112
110
  "optional": true
113
111
  },
114
- "jsdom": {
112
+ "happy-dom": {
115
113
  "optional": true
116
114
  },
117
- "c8": {
115
+ "jsdom": {
118
116
  "optional": true
119
117
  }
120
118
  },
@@ -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};