vitest 0.0.38 → 0.0.39

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.
package/README.gh.md CHANGED
@@ -271,8 +271,36 @@ describe('suite', () => {
271
271
  })
272
272
  ```
273
273
 
274
- You can also use `.skip`, `.only`, and `.todo` with concurrent tasks. All the following combinations are valid:
274
+ If you use `.concurrent` in a suite, every tasks in it will be run in parallel
275
+ ```ts
276
+ // The two tasks marked with concurrent will be run in parallel
277
+ describe.concurrent('suite', () => {
278
+ it('concurrent task 1', () => {
279
+ assert.equal(Math.sqrt(4), 3)
280
+ })
281
+ it('concurrent task 2', () => {
282
+ assert.equal(Math.sqrt(4), 3)
283
+ })
284
+ // No effect, same as not using .concurrent
285
+ it.concurrent('concurrent task 3', () => {
286
+ assert.equal(Math.sqrt(4), 3)
287
+ })
288
+ })
289
+ ```
290
+
291
+ You can also use `.skip`, `.only`, and `.todo` with concurrent suite and tasks. All the following combinations are valid:
275
292
  ```js
293
+ describe.concurrent(...)
294
+
295
+ describe.skip.concurrent(...)
296
+ describe.concurrent.skip(...)
297
+
298
+ describe.only.concurrent(...)
299
+ describe.concurrent.only(...)
300
+
301
+ describe.todo.concurrent(...)
302
+ describe.concurrent.todo(...)
303
+
276
304
  it.concurrent(...)
277
305
 
278
306
  it.skip.concurrent(...)
@@ -285,6 +313,7 @@ it.todo.concurrent(...)
285
313
  it.concurrent.todo(...)
286
314
  ```
287
315
 
316
+
288
317
  ## Sponsors
289
318
 
290
319
  <p align="center">
@@ -0,0 +1 @@
1
+ import{a as F,b as h,f as y}from"./chunk-XPSQDVUG.js";y();y();var d={suites:[],currentSuite:null};var S=R(),k=S("");function c(){return d.currentSuite||k}function l(o,e=()=>{},r,i){let s=[],t=[],n={name:o,mode:r,hooks:{beforeAll:[],afterAll:[],beforeEach:[],afterEach:[]}},u=E((f,a,p,g)=>{s.push({name:f,mode:p,computeMode:g??i??"serial",suite:{},state:p!=="run"&&p!=="only"?p:void 0,fn:a})}),T={name:o,mode:r,test:u,collect:b,clear:C,on:x};function x(f,...a){n.hooks[f].push(...a)}function C(){s.length=0,t.length=0}async function b(f){t.length=0,e&&await e(u);let a=[...t,...s],p=h(F({},n),{tasks:a,file:f});return a.forEach(g=>{g.suite=p,f&&(g.file=f)}),p}return d.currentSuite=T,d.suites.push(T),T}function E(o){function e(n,u){o(n,u,"run")}e.concurrent=r,e.skip=i,e.only=s,e.todo=t;function r(n,u){o(n,u,"run","concurrent")}r.skip=(n,u)=>o(n,u,"skip","concurrent"),r.only=(n,u)=>o(n,u,"only","concurrent"),r.todo=t;function i(n,u){o(n,u,"skip")}i.concurrent=r.skip;function s(n,u){o(n,u,"only")}s.concurrent=r.only;function t(n){o(n,()=>{},"todo")}return t.concurrent=t,e}var A=function(){function o(t,n){return c().test(t,n)}function e(t,n){return c().test.concurrent(t,n)}e.skip=(t,n)=>c().test.concurrent.skip(t,n),e.only=(t,n)=>c().test.concurrent.only(t,n),e.todo=t=>c().test.concurrent.todo(t);function r(t,n){return c().test.skip(t,n)}r.concurrent=(t,n)=>c().test.skip.concurrent(t,n);function i(t,n){return c().test.only(t,n)}i.concurrent=(t,n)=>c().test.only.concurrent(t,n);function s(t){return c().test.todo(t)}return s.concurrent=t=>c().test.todo.concurrent(t),o.concurrent=e,o.skip=r,o.only=i,o.todo=s,o}();function R(){function o(t,n){return l(t,n,"run")}function e(t,n){return l(t,n,"run","concurrent")}e.skip=(t,n)=>l(t,n,"skip","concurrent"),e.only=(t,n)=>l(t,n,"only","concurrent"),e.todo=t=>l(t,void 0,"todo");function r(t,n){return l(t,n,"skip")}r.concurrent=e.skip;function i(t,n){return l(t,n,"only")}i.concurrent=e.only;function s(t){return l(t,void 0,"todo")}return s.concurrent=e.todo,o.concurrent=e,o.skip=r,o.only=i,o.todo=s,o}var v=S,w=A,B=o=>c().on("beforeAll",o),H=o=>c().on("afterAll",o),P=o=>c().on("beforeEach",o),Q=o=>c().on("afterEach",o);function j(){d.suites.length=0,k.clear(),d.currentSuite=k}export{d as a,S as b,k as c,A as d,v as e,w as f,B as g,H as h,P as i,Q as j,j as k};
@@ -0,0 +1 @@
1
+ import{f as s}from"./chunk-XPSQDVUG.js";s();var c=["**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"],o=["**/node_modules/**","**/dist/**"],l=["suite","test","describe","it","chai","expect","assert","sinon","spy","mock","stub","beforeAll","afterAll","beforeEach","afterEach"];export{c as a,o as b,l as c};
@@ -0,0 +1 @@
1
+ import{b as r,c as a,d as s,e as l,f as c,g as d,h as u,i as p,j as f,k as x}from"./chunk-7SGHSD2B.js";import{d as i,f as e}from"./chunk-XPSQDVUG.js";var h={};i(h,{afterAll:()=>u,afterEach:()=>f,assert:()=>v,beforeAll:()=>d,beforeEach:()=>p,chai:()=>g,clearContext:()=>x,defaultSuite:()=>a,describe:()=>l,expect:()=>C,it:()=>c,mock:()=>k,should:()=>m,sinon:()=>t,spy:()=>S,stub:()=>T,suite:()=>r,test:()=>s});e();e();e();import g from"chai";import{assert as v,should as m,expect as C}from"chai";e();import t from"sinon";var{mock:k,spy:S,stub:T}=t;t.fn=t.spy;export{g as a,v as b,m as c,C as d,t as e,k as f,S as g,T as h,h as i};
@@ -0,0 +1 @@
1
+ import{i as r}from"./chunk-TUQVO6ML.js";import{c as l}from"./chunk-SAR64N7W.js";import"./chunk-7SGHSD2B.js";import{f as i}from"./chunk-XPSQDVUG.js";i();function a(){l.forEach(o=>{globalThis[o]=r[o]})}export{a as registerApiGlobally};
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as pretty_format from 'pretty-format';
2
- import { S as SuiteCollector, T as TestFunction, a as TestFactory, b as Suite, U as UserOptions } from './types-d3253f2d';
3
- export { C as ConcurrentOptions, F as File, G as GlobalContext, H as HookListener, h as Reporter, R as ResolvedConfig, c as RunMode, g as RunnerContext, b as Suite, S as SuiteCollector, e as Task, d as TaskState, f as TestCollector, a as TestFactory, T as TestFunction, U as UserOptions } from './types-d3253f2d';
2
+ import { T as TestFactory, S as SuiteCollector, a as TestFunction, b as Suite, U as UserOptions } from './types-91b8a38d';
3
+ export { C as ComputeMode, F as File, G as GlobalContext, H as HookListener, h as Reporter, R as ResolvedConfig, c as RunMode, g as RunnerContext, b as Suite, S as SuiteCollector, e as Task, d as TaskState, f as TestCollector, T as TestFactory, a as TestFunction, U as UserOptions } from './types-91b8a38d';
4
4
  export { assert, default as chai, expect, should } from 'chai';
5
5
  import sinon from 'sinon';
6
6
  export { default as sinon } from 'sinon';
@@ -8,50 +8,85 @@ import '@antfu/utils';
8
8
  import 'jest-snapshot';
9
9
  import 'jest-snapshot/build/State';
10
10
 
11
+ declare const suite: {
12
+ (suiteName: string, factory?: TestFactory | undefined): SuiteCollector;
13
+ concurrent: {
14
+ (suiteName: string, factory?: TestFactory | undefined): SuiteCollector;
15
+ skip(suiteName: string, factory?: TestFactory | undefined): SuiteCollector;
16
+ only(suiteName: string, factory?: TestFactory | undefined): SuiteCollector;
17
+ todo(suiteName: string): SuiteCollector;
18
+ };
19
+ skip: {
20
+ (suiteName: string, factory?: TestFactory | undefined): SuiteCollector;
21
+ concurrent: (suiteName: string, factory?: TestFactory | undefined) => SuiteCollector;
22
+ };
23
+ only: {
24
+ (suiteName: string, factory?: TestFactory | undefined): SuiteCollector;
25
+ concurrent: (suiteName: string, factory?: TestFactory | undefined) => SuiteCollector;
26
+ };
27
+ todo: {
28
+ (suiteName: string): SuiteCollector;
29
+ concurrent: (suiteName: string) => SuiteCollector;
30
+ };
31
+ };
11
32
  declare const defaultSuite: SuiteCollector;
12
33
  declare const test: {
13
34
  (name: string, fn: TestFunction): void;
14
35
  concurrent: {
15
- (name: string, fn: TestFunction, timeout?: number | undefined): void;
16
- skip(name: string, fn: TestFunction, timeout?: number | undefined): void;
17
- only(name: string, fn: TestFunction, timeout?: number | undefined): void;
36
+ (name: string, fn: TestFunction): void;
37
+ skip(name: string, fn: TestFunction): void;
38
+ only(name: string, fn: TestFunction): void;
18
39
  todo(name: string): void;
19
40
  };
20
41
  skip: {
21
42
  (name: string, fn: TestFunction): void;
22
- concurrent(name: string, fn: TestFunction, timeout?: number | undefined): void;
43
+ concurrent(name: string, fn: TestFunction): void;
23
44
  };
24
45
  only: {
25
46
  (name: string, fn: TestFunction): void;
26
- concurrent(name: string, fn: TestFunction, timeout?: number | undefined): void;
47
+ concurrent(name: string, fn: TestFunction): void;
27
48
  };
28
49
  todo: {
29
50
  (name: string): void;
30
51
  concurrent(name: string): void;
31
52
  };
32
53
  };
33
- declare function suite(suiteName: string, factory?: TestFactory): SuiteCollector;
34
- declare namespace suite {
35
- var skip: (suiteName: string, factory?: TestFactory | undefined) => SuiteCollector;
36
- var only: (suiteName: string, factory?: TestFactory | undefined) => SuiteCollector;
37
- var todo: (suiteName: string) => SuiteCollector;
38
- }
39
- declare const describe: typeof suite;
54
+ declare const describe: {
55
+ (suiteName: string, factory?: TestFactory | undefined): SuiteCollector;
56
+ concurrent: {
57
+ (suiteName: string, factory?: TestFactory | undefined): SuiteCollector;
58
+ skip(suiteName: string, factory?: TestFactory | undefined): SuiteCollector;
59
+ only(suiteName: string, factory?: TestFactory | undefined): SuiteCollector;
60
+ todo(suiteName: string): SuiteCollector;
61
+ };
62
+ skip: {
63
+ (suiteName: string, factory?: TestFactory | undefined): SuiteCollector;
64
+ concurrent: (suiteName: string, factory?: TestFactory | undefined) => SuiteCollector;
65
+ };
66
+ only: {
67
+ (suiteName: string, factory?: TestFactory | undefined): SuiteCollector;
68
+ concurrent: (suiteName: string, factory?: TestFactory | undefined) => SuiteCollector;
69
+ };
70
+ todo: {
71
+ (suiteName: string): SuiteCollector;
72
+ concurrent: (suiteName: string) => SuiteCollector;
73
+ };
74
+ };
40
75
  declare const it: {
41
76
  (name: string, fn: TestFunction): void;
42
77
  concurrent: {
43
- (name: string, fn: TestFunction, timeout?: number | undefined): void;
44
- skip(name: string, fn: TestFunction, timeout?: number | undefined): void;
45
- only(name: string, fn: TestFunction, timeout?: number | undefined): void;
78
+ (name: string, fn: TestFunction): void;
79
+ skip(name: string, fn: TestFunction): void;
80
+ only(name: string, fn: TestFunction): void;
46
81
  todo(name: string): void;
47
82
  };
48
83
  skip: {
49
84
  (name: string, fn: TestFunction): void;
50
- concurrent(name: string, fn: TestFunction, timeout?: number | undefined): void;
85
+ concurrent(name: string, fn: TestFunction): void;
51
86
  };
52
87
  only: {
53
88
  (name: string, fn: TestFunction): void;
54
- concurrent(name: string, fn: TestFunction, timeout?: number | undefined): void;
89
+ concurrent(name: string, fn: TestFunction): void;
55
90
  };
56
91
  todo: {
57
92
  (name: string): void;
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{a as k,b as l,c as m,d as n,e as o,f as p,g as q,h as r}from"./chunk-CUG6SVUZ.js";import{e as a,f as b,g as c,h as d,i as e,j as f,k as g,l as h,m as i,n as j}from"./chunk-4OVO6RD6.js";import"./chunk-XPSQDVUG.js";export{g as afterAll,i as afterEach,l as assert,f as beforeAll,h as beforeEach,k as chai,j as clearContext,a as defaultSuite,d as describe,n as expect,e as it,p as mock,m as should,o as sinon,q as spy,r as stub,c as suite,b as test};
1
+ import{a as k,b as l,c as m,d as n,e as o,f as p,g as q,h as r}from"./chunk-TUQVO6ML.js";import{b as a,c as b,d as c,e as d,f as e,g as f,h as g,i as h,j as i,k as j}from"./chunk-7SGHSD2B.js";import"./chunk-XPSQDVUG.js";export{g as afterAll,i as afterEach,l as assert,f as beforeAll,h as beforeEach,k as chai,j as clearContext,b as defaultSuite,d as describe,n as expect,e as it,p as mock,m as should,o as sinon,q as spy,r as stub,a as suite,c as test};
@@ -1,4 +1,4 @@
1
- import { U as UserOptions } from '../types-d3253f2d';
1
+ import { U as UserOptions } from '../types-91b8a38d';
2
2
  import '@antfu/utils';
3
3
  import 'jest-snapshot';
4
4
  import 'jest-snapshot/build/State';
package/dist/node/cli.js CHANGED
@@ -1,4 +1,4 @@
1
- import{f as g}from"../chunk-XPSQDVUG.js";g();import{fileURLToPath as H}from"url";import{resolve as w,dirname as Q}from"path";import{findUp as G}from"find-up";import K from"sade";import v from"picocolors";var C="0.0.38";g();import{createServer as L,mergeConfig as J}from"vite";g();import{builtinModules as F,createRequire as A}from"module";import{fileURLToPath as D,pathToFileURL as N}from"url";import{dirname as E,resolve as V}from"path";import W from"vm";var $={"/@vite/client":{injectQuery:e=>e,createHotContext(){return{accept:()=>{},prune:()=>{}}},updateStyle(){}}};async function T({moduleCache:e,root:s,files:r,fetch:i,inline:p,external:c}){let h=[];for(let t of r)h.push(await u(`/@fs/${b(V(t))}`,[]));return h;async function y(t,n,o){o=[...o,t];let a=async f=>{if(o.includes(f)){if(!e.get(f))throw new Error(`Circular dependency detected
1
+ import{f as g}from"../chunk-XPSQDVUG.js";g();import{fileURLToPath as H}from"url";import{resolve as w,dirname as Q}from"path";import{findUp as G}from"find-up";import K from"sade";import v from"picocolors";var C="0.0.39";g();import{createServer as L,mergeConfig as J}from"vite";g();import{builtinModules as F,createRequire as A}from"module";import{fileURLToPath as D,pathToFileURL as N}from"url";import{dirname as E,resolve as V}from"path";import W from"vm";var $={"/@vite/client":{injectQuery:e=>e,createHotContext(){return{accept:()=>{},prune:()=>{}}},updateStyle(){}}};async function T({moduleCache:e,root:s,files:r,fetch:i,inline:p,external:c}){let h=[];for(let t of r)h.push(await u(`/@fs/${b(V(t))}`,[]));return h;async function y(t,n,o){o=[...o,t];let a=async f=>{if(o.includes(f)){if(!e.get(f))throw new Error(`Circular dependency detected
2
2
  Stack:
3
3
  ${[...o,f].reverse().map(I=>`- ${I}`).join(`
4
4
  `)}`);return e.get(f).exports}return u(f,o)};if(t in $)return $[t];let d=await i(t);if(!d)throw new Error(`failed to load ${t}`);let m=N(n),l={};_(t,{transformResult:d,exports:l});let j=D(m),R={require:A(m),__filename:j,__dirname:E(j),__vite_ssr_import__:a,__vite_ssr_dynamic_import__:a,__vite_ssr_exports__:l,__vite_ssr_exportAll__:f=>q(l,f),__vite_ssr_import_meta__:{url:m}};return await W.runInThisContext(`async (${Object.keys(R).join(",")}) => { ${d.code} }`,{filename:n,lineOffset:0})(...Object.values(R)),l}function _(t,n){e.has(t)?Object.assign(e.get(t),n):e.set(t,n)}function x(t){for(let n of p)if(typeof n=="string"){if(t.includes(`/node_modules/${n}/`))return!1}else if(n.test(t))return!1;for(let n of c)if(typeof n=="string"){if(t.includes(`/node_modules/${n}/`))return!0}else if(n.test(t))return!0;return t.includes("/node_modules/")}async function u(t,n){var m,l;let o=k(t);if(F.includes(o))return import(o);let a=U(o,s);if(x(a))return a.match(/^\w:\//)?import(`/${a}`):import(a);if((m=e.get(a))==null?void 0:m.promise)return(l=e.get(a))==null?void 0:l.promise;let d=y(o,a,n);return _(a,{promise:d}),await d}function q(t,n){for(let o in n)if(o!=="default")try{Object.defineProperty(t,o,{enumerable:!0,configurable:!0,get(){return n[o]}})}catch{}}}function k(e){return e&&e.startsWith("/@id/__x00__")&&(e=`\0${e.slice("/@id/__x00__".length)}`),e&&e.startsWith("/@id/")&&(e=e.slice("/@id/".length)),e.startsWith("__vite-browser-external:")&&(e=e.slice("__vite-browser-external:".length)),e}function U(e,s){let r=b(e).startsWith("/@fs/")?e.slice(4):e.startsWith(E(s))?e:e.startsWith("/")?b(V(s,e.slice(1))):e;return r.startsWith("//")&&(r=r.slice(1)),r}function b(e){return e.replace(/\\/g,"/")}var M=new Map;async function P(e){var h,y,_,x;process.exitCode=0;let s=e.root||process.cwd();process.chdir(s);let r=e.files||e._;e.shouldExternalize=e.shouldExternalize||(u=>u.includes("/node_modules/"));let i=await L(J(e.defaultConfig||{},{logLevel:"error",clearScreen:!1,configFile:e.config,root:s,resolve:{}}));await i.pluginContainer.buildStart({}),process.__vite_node__={server:i,moduleCache:M};let p=["vitest/dist","vitest/src","vue","@vue","diff"],c={root:i.config.root,files:r,fetch:u=>B(i,u),inline:[...p,...((y=(h=i.config.test)==null?void 0:h.deps)==null?void 0:y.inline)||[]],external:((x=(_=i.config.test)==null?void 0:_.deps)==null?void 0:x.external)||[],moduleCache:M};try{await T(c)}catch(u){throw process.exitCode=1,u}finally{process.__vite_node__.watch||await i.close()}}async function B(e,s){if(s.match(/\.(?:[cm]?[jt]sx?|json)$/))return await e.transformRequest(s,{ssr:!0});{let r=await e.transformRequest(s);return r?await e.ssrTransform(r.code,r.map,s):void 0}}K("vitest [filter]",!0).version(C).describe("A blazing fast unit test framework powered by Vite.").option("-r, --root","root path",process.cwd()).option("-c, --config","path to config file").option("-w, --watch","watch mode",!1).option("-u, --update","update snapshot",!1).option("--global","inject apis globally",!1).option("--dev","dev mode",!1).option("--dom","mock browser api using jsdom or happy-dom","").action(async(e,s)=>{process.env.VITEST="true",console.log(v.yellow(v.bold(`
@@ -1,19 +1,19 @@
1
- import{a as F,b as I,c as K,e as q,n as z}from"../chunk-4OVO6RD6.js";import{a as A,c as Se,e as ye,f as c}from"../chunk-XPSQDVUG.js";var Y=Se((it,V)=>{c();"use strict";V.exports=t=>{let e=/^\\\\\?\\/.test(t),n=/[^\u0000-\u0080]+/.test(t);return e||n?t:t.replace(/\\/g,"/")}});c();c();c();import ne from"jest-snapshot";c();import Me from"chai";import xe from"jest-snapshot";c();import we from"@jest/test-result";var{makeEmptyAggregatedTestResult:ke}=we,P=t=>{let e=ke().snapshot;return e.didUpdate=t.updateSnapshot==="all",e},G=t=>{let e={added:0,fileDeleted:!1,matched:0,unchecked:0,uncheckedKeys:[],unmatched:0,updated:0},n=t.getUncheckedCount(),o=t.getUncheckedKeys();n&&t.removeUncheckedKeys();let r=t.save();return e.fileDeleted=r.deleted,e.added=t.added,e.matched=t.matched,e.unmatched=t.unmatched,e.updated=t.updated,e.unchecked=r.deleted?0:n,e.uncheckedKeys=Array.from(o),e},J=(t,e,n)=>{e.added&&t.filesAdded++,e.fileDeleted&&t.filesRemoved++,e.unmatched&&t.filesUnmatched++,e.updated&&t.filesUpdated++,t.added+=e.added,t.matched+=e.matched,t.unchecked+=e.unchecked,e.uncheckedKeys&&e.uncheckedKeys.length>0&&t.uncheckedKeysByFile.push({filePath:n,keys:e.uncheckedKeys}),t.unmatched+=e.unmatched,t.updated+=e.updated,t.total+=e.added+e.matched+e.unmatched+e.updated};c();var Q=ye(Y());import C,{isAbsolute as $e}from"path";import{pluralize as m}from"jest-util";import g from"picocolors";var _=(t,e)=>{$e(e)&&(e=C.relative(t,e));let n=C.dirname(e),o=C.basename(e);return(0,Q.default)(g.dim(n+C.sep)+g.bold(o))},$=" \u203A ",X=" \u21B3 ",E=" \u2022 ",ve=t=>g.bold(g.red(t)),Z=t=>g.bold(g.yellow(t)),Ce=t=>g.bold(g.green(t)),j=g.dim,ee=t=>g.bold(g.green(t)),be=g.bold,Te=t=>g.bold(g.green(t)),B="re-run mocha with `--update` to update them",te=(t,e)=>{let n=[];if(n.push(be("Snapshot Summary")),e.added&&n.push(`${Ce(`${$+m("snapshot",e.added)} written `)}from ${m("test suite",e.filesAdded)}.`),e.unmatched&&n.push(`${ve(`${$}${m("snapshot",e.unmatched)} failed`)} from ${m("test suite",e.filesUnmatched)}. ${j(`Inspect your code changes or ${B} to update them.`)}`),e.updated&&n.push(`${Te(`${$+m("snapshot",e.updated)} updated `)}from ${m("test suite",e.filesUpdated)}.`),e.filesRemoved&&(e.didUpdate?n.push(`${ee(`${$}${m("snapshot file",e.filesRemoved)} removed `)}from ${m("test suite",e.filesRemoved)}.`):n.push(`${Z(`${$}${m("snapshot file",e.filesRemoved)} obsolete `)}from ${m("test suite",e.filesRemoved)}. ${j(`To remove ${e.filesRemoved===1?"it":"them all"}, ${B}.`)}`)),e.filesRemovedList&&e.filesRemovedList.length){let[o,...r]=e.filesRemovedList;n.push(` ${X} ${E}${_(t,o)}`),r.forEach(s=>{n.push(` ${E}${_(t,s)}`)})}return e.unchecked&&(e.didUpdate?n.push(`${ee(`${$}${m("snapshot",e.unchecked)} removed `)}from ${m("test suite",e.uncheckedKeysByFile.length)}.`):n.push(`${Z(`${$}${m("snapshot",e.unchecked)} obsolete `)}from ${m("test suite",e.uncheckedKeysByFile.length)}. ${j(`To remove ${e.unchecked===1?"it":"them all"}, ${B}.`)}`),e.uncheckedKeysByFile.forEach(o=>{n.push(` ${X}${_(t,o.filePath)}`),o.keys.forEach(r=>{n.push(` ${E}${r}`)})})),n};var{expect:Re}=Me,{SnapshotState:Oe}=xe,D=class{snapshotState=null;snapshotSummary;snapshotOptions;context=null;testFile="";snapshotResolver;rootDir;constructor({rootDir:e,update:n,snapshotResolver:o=null}){this.rootDir=e,this.snapshotResolver=o;let r=process.env,s=!!r.CI,i=n||r.UPDATE_SNAPSHOT;this.snapshotOptions={updateSnapshot:s&&!i?"none":i?"all":"new"},this.snapshotSummary=P(this.snapshotOptions)}onFileChanged(){!this.context||(this.snapshotState!==null&&this.saveSnap(),this.testFile=this.context.file,this.snapshotState=new Oe(this.snapshotResolver.resolveSnapshotPath(this.testFile),this.snapshotOptions))}setTask(e){var n;this.setContext({file:((n=e.file)==null?void 0:n.filepath)||e.name,title:e.name,fullTitle:[e.suite.name,e.name].filter(Boolean).join(" > ")})}setContext(e){!e.title||!e.file||(this.context=e,this.testFile!==e.file&&this.onFileChanged())}assert(e,n){if(!this.snapshotState||!this.context)return;let{actual:o,expected:r,key:s,pass:i}=this.snapshotState.match({testName:this.context.fullTitle||this.context.title||this.context.file,received:e,isInline:!1});i||Re(o.trim()).equals(r?r.trim():"",n||`Snapshot name: \`${s}\``)}clear(){this.snapshotSummary=P(this.snapshotOptions)}saveSnap(){if(!this.testFile||!this.snapshotState)return;let e=G(this.snapshotState);J(this.snapshotSummary,e,this.testFile),this.testFile="",this.snapshotState=null}report(){let e=te(this.rootDir,this.snapshotSummary);if(e.length>1)return e}};var{addSerializer:Ae}=ne,b;function T(){return b}async function oe(t){let{root:e}=t;return b=new D({rootDir:e,update:t.update}),b.snapshotResolver=await ne.buildSnapshotResolver({transform:[],rootDir:e}),function(n,o){for(let r of["matchSnapshot","toMatchSnapshot"])o.addMethod(n.Assertion.prototype,r,function(s){let i=o.flag(this,"object");b.assert(i,s)});n.expect.addSnapshotSerializer=Ae}}c();import{slash as Fe}from"@antfu/utils";c();async function M(t){let e={};for(let r of t){let s={filepath:r,suites:[],collected:!1};z();try{await import(r);let i=[q,...F.suites];for(let a of i)F.currentSuite=a,s.suites.push(await a.collect(s));s.collected=!0}catch(i){s.error=i,s.collected=!1,process.exitCode=1}e[r]=s}let o=Object.values(e).reduce((r,s)=>r.concat(s.suites),[]);return L(o),o.forEach(r=>{r.mode==="skip"?r.tasks.forEach(s=>s.mode==="run"&&(s.mode="skip")):L(r.tasks),r.tasks.forEach(s=>s.mode==="skip"&&(s.state="skip"))}),e}async function se(t){var w;let{reporter:e,snapshotManager:n,filesMap:o}=t;await((w=e.onWatcherStart)==null?void 0:w.call(e,t));let r,s=new Set,i=new Set,{server:a,moduleCache:d}=process.__vite_node__;a.watcher.on("change",async h=>{h=Fe(h),ie(h,t,s,i),i.forEach(S=>d.delete(S)),i.clear(),s.size!==0&&(clearTimeout(r),r=setTimeout(async()=>{var v,l,H;if(s.size===0)return;n.clear();let S=Array.from(s);s.clear(),await((v=e.onWatcherRerun)==null?void 0:v.call(e,S,h,t)),S.forEach(ge=>d.delete(ge));let k=await M(S);Object.assign(o,k),await N(k,t),n.saveSnap(),await((l=e.onFinished)==null?void 0:l.call(e,t,Object.values(k))),await((H=e.onWatcherStart)==null?void 0:H.call(e,t))},100))}),await new Promise(()=>{})}function ie(t,e,n=new Set,o=new Set){if(o.has(t)||n.has(t))return n;if(o.add(t),t in e.filesMap)return n.add(t),n;let r=process.__vite_node__.server.moduleGraph.getModuleById(t);return r&&r.importers.forEach(s=>{s.id&&ie(s.id,e,n,o)}),n}c();c();import x from"chai";import Pe from"sinon-chai";import _e from"chai-subset";c();function re(){return(t,e)=>{let n=t.Assertion.prototype;e.addMethod(n,"toEqual",function(o){return this.eql(o)}),e.addMethod(n,"toStrictEqual",function(o){return this.equal(o)}),e.addMethod(n,"toBe",function(o){return this.equal(o)}),e.addMethod(n,"toMatchObject",function(o){return this.containSubset(o)}),e.addMethod(n,"toMatch",function(o){return typeof o=="string"?this.include(o):this.match(o)}),e.addMethod(n,"toContain",function(o){return this.contain(o)}),e.addMethod(n,"toBeTruthy",function(){let o=e.flag(this,"object");this.assert(Boolean(o),"expected #{this} to be truthy","expected #{this} to not be truthy",o)}),e.addMethod(n,"toBeFalsy",function(){let o=e.flag(this,"object");this.assert(!o,"expected #{this} to be falsy","expected #{this} to not be falsy",o)}),e.addMethod(n,"toBeNaN",function(){return this.be.NaN}),e.addMethod(n,"toBeUndefined",function(){return this.be.undefined}),e.addMethod(n,"toBeNull",function(){return this.be.null}),e.addMethod(n,"toBeDefined",function(){return this.not.be.undefined}),e.addMethod(n,"toBeInstanceOf",function(o){return this.instanceOf(o)}),e.addMethod(n,"toHaveBeenCalledTimes",function(o){return this.callCount(o)}),e.addMethod(n,"toHaveBeenCalledOnce",function(){return this.callCount(1)}),e.addMethod(n,"toHaveBeenCalled",function(){return this.called}),e.addMethod(n,"toHaveBeenCalled",function(){return this.called}),e.addMethod(n,"toHaveBeenCalledWith",function(...o){return this.calledWith(...o)})}}async function ae(t){x.use(Pe),x.use(re()),x.use(_e),x.use(await oe(t))}c();import{performance as ue}from"perf_hooks";import{relative as Je}from"path";import u from"picocolors";import U from"listr";c();import{promises as Ee,existsSync as je}from"fs";import y from"picocolors";import{createPatch as Ge}from"diff";import{notNullish as Be}from"@antfu/utils";import{SourceMapConsumer as De}from"source-map";async function R(t){var i;if(!(t instanceof Error)){console.error(t);return}let{moduleCache:e}=process.__vite_node__,n=t,o=!1,s=Ie(n.stack||"").find(a=>e.has(a.file));if(s){let a=(i=e.get(s.file))==null?void 0:i.transformResult,d=await Le(a==null?void 0:a.map,s);if(d&&je(s.file)){let w=await Ee.readFile(s.file,"utf-8");console.error(`${y.red(`${y.bold(n.name)}: ${n.message}`)}`),console.log(y.gray(`${s.file}:${d.line}:${d.column}`)),console.log(y.yellow(Ue(w,d))),o=!0}}o||console.error(n),n.showDiff&&console.error(y.gray(Ke(ce(n.actual),ce(n.expected))))}function Le(t,{line:e,column:n}){return new Promise(o=>{if(!t)return o(null);De.with(t,null,r=>{let s=r.originalPositionFor({line:e,column:n});s.line!=null&&s.column!=null?o(s):o(null)})})}var le=/\r?\n/;function Ne(t,e){if(typeof e=="number")return e;let n=t.split(le),{line:o,column:r}=e,s=0;for(let i=0;i<o-1;i++)s+=n[i].length+1;return s+r}function Ue(t,e=0,n,o=2){e=Ne(t,e),n=n||e;let r=t.split(le),s=0,i=[];for(let a=0;a<r.length;a++)if(s+=r[a].length+1,s>=e){for(let d=a-o;d<=a+o||n>s;d++){if(d<0||d>=r.length)continue;let w=d+1;i.push(`${y.gray(`${w}${" ".repeat(Math.max(3-String(w).length,0))}|`)} ${r[d]}`);let h=r[d].length;if(d===a){let S=e-(s-h)+1,k=Math.max(1,n>s?h-S:n-e);i.push(`${y.gray(" |")} ${" ".repeat(S)}${"^".repeat(k)}`)}else if(d>a){if(n>s){let S=Math.max(Math.min(n-s,h),1);i.push(`${y.gray(" |")} ${"^".repeat(S)}`)}s+=h+1}}break}return i.join(`
1
+ import{a as q,b as z}from"../chunk-SAR64N7W.js";import{a as F,c as I,k as K}from"../chunk-7SGHSD2B.js";import{a as A,c as Se,e as ye,f as c}from"../chunk-XPSQDVUG.js";var Y=Se((it,V)=>{c();"use strict";V.exports=t=>{let e=/^\\\\\?\\/.test(t),o=/[^\u0000-\u0080]+/.test(t);return e||o?t:t.replace(/\\/g,"/")}});c();c();c();import oe from"jest-snapshot";c();import Me from"chai";import xe from"jest-snapshot";c();import we from"@jest/test-result";var{makeEmptyAggregatedTestResult:ke}=we,P=t=>{let e=ke().snapshot;return e.didUpdate=t.updateSnapshot==="all",e},G=t=>{let e={added:0,fileDeleted:!1,matched:0,unchecked:0,uncheckedKeys:[],unmatched:0,updated:0},o=t.getUncheckedCount(),n=t.getUncheckedKeys();o&&t.removeUncheckedKeys();let r=t.save();return e.fileDeleted=r.deleted,e.added=t.added,e.matched=t.matched,e.unmatched=t.unmatched,e.updated=t.updated,e.unchecked=r.deleted?0:o,e.uncheckedKeys=Array.from(n),e},J=(t,e,o)=>{e.added&&t.filesAdded++,e.fileDeleted&&t.filesRemoved++,e.unmatched&&t.filesUnmatched++,e.updated&&t.filesUpdated++,t.added+=e.added,t.matched+=e.matched,t.unchecked+=e.unchecked,e.uncheckedKeys&&e.uncheckedKeys.length>0&&t.uncheckedKeysByFile.push({filePath:o,keys:e.uncheckedKeys}),t.unmatched+=e.unmatched,t.updated+=e.updated,t.total+=e.added+e.matched+e.unmatched+e.updated};c();var Q=ye(Y());import C,{isAbsolute as $e}from"path";import{pluralize as m}from"jest-util";import g from"picocolors";var _=(t,e)=>{$e(e)&&(e=C.relative(t,e));let o=C.dirname(e),n=C.basename(e);return(0,Q.default)(g.dim(o+C.sep)+g.bold(n))},$=" \u203A ",X=" \u21B3 ",E=" \u2022 ",ve=t=>g.bold(g.red(t)),Z=t=>g.bold(g.yellow(t)),Ce=t=>g.bold(g.green(t)),j=g.dim,ee=t=>g.bold(g.green(t)),be=g.bold,Te=t=>g.bold(g.green(t)),B="re-run mocha with `--update` to update them",te=(t,e)=>{let o=[];if(o.push(be("Snapshot Summary")),e.added&&o.push(`${Ce(`${$+m("snapshot",e.added)} written `)}from ${m("test suite",e.filesAdded)}.`),e.unmatched&&o.push(`${ve(`${$}${m("snapshot",e.unmatched)} failed`)} from ${m("test suite",e.filesUnmatched)}. ${j(`Inspect your code changes or ${B} to update them.`)}`),e.updated&&o.push(`${Te(`${$+m("snapshot",e.updated)} updated `)}from ${m("test suite",e.filesUpdated)}.`),e.filesRemoved&&(e.didUpdate?o.push(`${ee(`${$}${m("snapshot file",e.filesRemoved)} removed `)}from ${m("test suite",e.filesRemoved)}.`):o.push(`${Z(`${$}${m("snapshot file",e.filesRemoved)} obsolete `)}from ${m("test suite",e.filesRemoved)}. ${j(`To remove ${e.filesRemoved===1?"it":"them all"}, ${B}.`)}`)),e.filesRemovedList&&e.filesRemovedList.length){let[n,...r]=e.filesRemovedList;o.push(` ${X} ${E}${_(t,n)}`),r.forEach(s=>{o.push(` ${E}${_(t,s)}`)})}return e.unchecked&&(e.didUpdate?o.push(`${ee(`${$}${m("snapshot",e.unchecked)} removed `)}from ${m("test suite",e.uncheckedKeysByFile.length)}.`):o.push(`${Z(`${$}${m("snapshot",e.unchecked)} obsolete `)}from ${m("test suite",e.uncheckedKeysByFile.length)}. ${j(`To remove ${e.unchecked===1?"it":"them all"}, ${B}.`)}`),e.uncheckedKeysByFile.forEach(n=>{o.push(` ${X}${_(t,n.filePath)}`),n.keys.forEach(r=>{o.push(` ${E}${r}`)})})),o};var{expect:Re}=Me,{SnapshotState:Oe}=xe,D=class{snapshotState=null;snapshotSummary;snapshotOptions;context=null;testFile="";snapshotResolver;rootDir;constructor({rootDir:e,update:o,snapshotResolver:n=null}){this.rootDir=e,this.snapshotResolver=n;let r=process.env,s=!!r.CI,i=o||r.UPDATE_SNAPSHOT;this.snapshotOptions={updateSnapshot:s&&!i?"none":i?"all":"new"},this.snapshotSummary=P(this.snapshotOptions)}onFileChanged(){!this.context||(this.snapshotState!==null&&this.saveSnap(),this.testFile=this.context.file,this.snapshotState=new Oe(this.snapshotResolver.resolveSnapshotPath(this.testFile),this.snapshotOptions))}setTask(e){var o;this.setContext({file:((o=e.file)==null?void 0:o.filepath)||e.name,title:e.name,fullTitle:[e.suite.name,e.name].filter(Boolean).join(" > ")})}setContext(e){!e.title||!e.file||(this.context=e,this.testFile!==e.file&&this.onFileChanged())}assert(e,o){if(!this.snapshotState||!this.context)return;let{actual:n,expected:r,key:s,pass:i}=this.snapshotState.match({testName:this.context.fullTitle||this.context.title||this.context.file,received:e,isInline:!1});i||Re(n.trim()).equals(r?r.trim():"",o||`Snapshot name: \`${s}\``)}clear(){this.snapshotSummary=P(this.snapshotOptions)}saveSnap(){if(!this.testFile||!this.snapshotState)return;let e=G(this.snapshotState);J(this.snapshotSummary,e,this.testFile),this.testFile="",this.snapshotState=null}report(){let e=te(this.rootDir,this.snapshotSummary);if(e.length>1)return e}};var{addSerializer:Ae}=oe,b;function T(){return b}async function ne(t){let{root:e}=t;return b=new D({rootDir:e,update:t.update}),b.snapshotResolver=await oe.buildSnapshotResolver({transform:[],rootDir:e}),function(o,n){for(let r of["matchSnapshot","toMatchSnapshot"])n.addMethod(o.Assertion.prototype,r,function(s){let i=n.flag(this,"object");b.assert(i,s)});o.expect.addSnapshotSerializer=Ae}}c();import{slash as Fe}from"@antfu/utils";c();async function M(t){let e={};for(let r of t){let s={filepath:r,suites:[],collected:!1};K();try{await import(r);let i=[I,...F.suites];for(let a of i)F.currentSuite=a,s.suites.push(await a.collect(s));s.collected=!0}catch(i){s.error=i,s.collected=!1,process.exitCode=1}e[r]=s}let n=Object.values(e).reduce((r,s)=>r.concat(s.suites),[]);return L(n),n.forEach(r=>{r.mode==="skip"?r.tasks.forEach(s=>s.mode==="run"&&(s.mode="skip")):L(r.tasks),r.tasks.forEach(s=>s.mode==="skip"&&(s.state="skip"))}),e}async function se(t){var w;let{reporter:e,snapshotManager:o,filesMap:n}=t;await((w=e.onWatcherStart)==null?void 0:w.call(e,t));let r,s=new Set,i=new Set,{server:a,moduleCache:d}=process.__vite_node__;a.watcher.on("change",async h=>{h=Fe(h),ie(h,t,s,i),i.forEach(S=>d.delete(S)),i.clear(),s.size!==0&&(clearTimeout(r),r=setTimeout(async()=>{var v,l,H;if(s.size===0)return;o.clear();let S=Array.from(s);s.clear(),await((v=e.onWatcherRerun)==null?void 0:v.call(e,S,h,t)),S.forEach(ge=>d.delete(ge));let k=await M(S);Object.assign(n,k),await N(k,t),o.saveSnap(),await((l=e.onFinished)==null?void 0:l.call(e,t,Object.values(k))),await((H=e.onWatcherStart)==null?void 0:H.call(e,t))},100))}),await new Promise(()=>{})}function ie(t,e,o=new Set,n=new Set){if(n.has(t)||o.has(t))return o;if(n.add(t),t in e.filesMap)return o.add(t),o;let r=process.__vite_node__.server.moduleGraph.getModuleById(t);return r&&r.importers.forEach(s=>{s.id&&ie(s.id,e,o,n)}),o}c();c();import x from"chai";import Pe from"sinon-chai";import _e from"chai-subset";c();function re(){return(t,e)=>{let o=t.Assertion.prototype;e.addMethod(o,"toEqual",function(n){return this.eql(n)}),e.addMethod(o,"toStrictEqual",function(n){return this.equal(n)}),e.addMethod(o,"toBe",function(n){return this.equal(n)}),e.addMethod(o,"toMatchObject",function(n){return this.containSubset(n)}),e.addMethod(o,"toMatch",function(n){return typeof n=="string"?this.include(n):this.match(n)}),e.addMethod(o,"toContain",function(n){return this.contain(n)}),e.addMethod(o,"toBeTruthy",function(){let n=e.flag(this,"object");this.assert(Boolean(n),"expected #{this} to be truthy","expected #{this} to not be truthy",n)}),e.addMethod(o,"toBeFalsy",function(){let n=e.flag(this,"object");this.assert(!n,"expected #{this} to be falsy","expected #{this} to not be falsy",n)}),e.addMethod(o,"toBeNaN",function(){return this.be.NaN}),e.addMethod(o,"toBeUndefined",function(){return this.be.undefined}),e.addMethod(o,"toBeNull",function(){return this.be.null}),e.addMethod(o,"toBeDefined",function(){return this.not.be.undefined}),e.addMethod(o,"toBeInstanceOf",function(n){return this.instanceOf(n)}),e.addMethod(o,"toHaveBeenCalledTimes",function(n){return this.callCount(n)}),e.addMethod(o,"toHaveBeenCalledOnce",function(){return this.callCount(1)}),e.addMethod(o,"toHaveBeenCalled",function(){return this.called}),e.addMethod(o,"toHaveBeenCalled",function(){return this.called}),e.addMethod(o,"toHaveBeenCalledWith",function(...n){return this.calledWith(...n)})}}async function ae(t){x.use(Pe),x.use(re()),x.use(_e),x.use(await ne(t))}c();import{performance as ue}from"perf_hooks";import{relative as Je}from"path";import u from"picocolors";import U from"listr";c();import{promises as Ee,existsSync as je}from"fs";import y from"picocolors";import{createPatch as Ge}from"diff";import{notNullish as Be}from"@antfu/utils";import{SourceMapConsumer as De}from"source-map";async function R(t){var i;if(!(t instanceof Error)){console.error(t);return}let{moduleCache:e}=process.__vite_node__,o=t,n=!1,s=Ie(o.stack||"").find(a=>e.has(a.file));if(s){let a=(i=e.get(s.file))==null?void 0:i.transformResult,d=await Le(a==null?void 0:a.map,s);if(d&&je(s.file)){let w=await Ee.readFile(s.file,"utf-8");console.error(`${y.red(`${y.bold(o.name)}: ${o.message}`)}`),console.log(y.gray(`${s.file}:${d.line}:${d.column}`)),console.log(y.yellow(Ue(w,d))),n=!0}}n||console.error(o),o.showDiff&&console.error(y.gray(Ke(ce(o.actual),ce(o.expected))))}function Le(t,{line:e,column:o}){return new Promise(n=>{if(!t)return n(null);De.with(t,null,r=>{let s=r.originalPositionFor({line:e,column:o});s.line!=null&&s.column!=null?n(s):n(null)})})}var le=/\r?\n/;function Ne(t,e){if(typeof e=="number")return e;let o=t.split(le),{line:n,column:r}=e,s=0;for(let i=0;i<n-1;i++)s+=o[i].length+1;return s+r}function Ue(t,e=0,o,n=2){e=Ne(t,e),o=o||e;let r=t.split(le),s=0,i=[];for(let a=0;a<r.length;a++)if(s+=r[a].length+1,s>=e){for(let d=a-n;d<=a+n||o>s;d++){if(d<0||d>=r.length)continue;let w=d+1;i.push(`${y.gray(`${w}${" ".repeat(Math.max(3-String(w).length,0))}|`)} ${r[d]}`);let h=r[d].length;if(d===a){let S=e-(s-h)+1,k=Math.max(1,o>s?h-S:o-e);i.push(`${y.gray(" |")} ${" ".repeat(S)}${"^".repeat(k)}`)}else if(d>a){if(o>s){let S=Math.max(Math.min(o-s,h),1);i.push(`${y.gray(" |")} ${"^".repeat(S)}`)}s+=h+1}}break}return i.join(`
2
2
  `)}function ce(t){return String(t)}var We=/at (.*) \((.+):(\d+):(\d+)\)$/,He=/at ()(.+):(\d+):(\d+)$/;function Ie(t){return t.split(`
3
- `).map(o=>{let r=o.trim(),s=r.match(We)||r.match(He);if(!s)return null;let i=s[2];return i.startsWith("file://")&&(i=i.slice(7)),{method:s[1],file:s[2],line:parseInt(s[3]),column:parseInt(s[4])}}).filter(Be)}function Ke(t,e){let n=2048;return t.length>n&&(t=`${t.substring(0,n)} ... Lines skipped`),e.length>n&&(e=`${e.substring(0,n)} ... Lines skipped`),qe(t,e)}function qe(t,e){let n=" ";function o(i){return i[0]==="+"?n+y.green(`${i[0]} ${i.slice(1)}`):i[0]==="-"?n+y.red(`${i[0]} ${i.slice(1)}`):i.match(/@@/)?"--":i.match(/\\ No newline/)?null:n+i}let s=Ge("string",t,e).split(`
3
+ `).map(n=>{let r=n.trim(),s=r.match(We)||r.match(He);if(!s)return null;let i=s[2];return i.startsWith("file://")&&(i=i.slice(7)),{method:s[1],file:s[2],line:parseInt(s[3]),column:parseInt(s[4])}}).filter(Be)}function Ke(t,e){let o=2048;return t.length>o&&(t=`${t.substring(0,o)} ... Lines skipped`),e.length>o&&(e=`${e.substring(0,o)} ... Lines skipped`),qe(t,e)}function qe(t,e){let o=" ";function n(i){return i[0]==="+"?o+y.green(`${i[0]} ${i.slice(1)}`):i[0]==="-"?o+y.red(`${i[0]} ${i.slice(1)}`):i.match(/@@/)?"--":i.match(/\\ No newline/)?null:o+i}let s=Ge("string",t,e).split(`
4
4
  `).splice(5);return`
5
- ${n}${y.red("- actual")}
6
- ${n}${y.green("+ expected")}
5
+ ${o}${y.red("- actual")}
6
+ ${o}${y.green("+ expected")}
7
7
 
8
- ${s.map(o).filter(ze).join(`
8
+ ${s.map(n).filter(ze).join(`
9
9
  `)}`}function ze(t){return typeof t!="undefined"&&t!==null}var Ve="\u2716 ",W=class{start=0;end=0;listr=null;listrPromise=null;taskMap=new Map;cwd=process.cwd();relative(e){return Je(this.cwd,e)}onStart(e){this.cwd=e.root,console.log(u.green(`Running tests under ${u.gray(this.cwd)}
10
- `))}onCollected(e){this.start=ue.now(),this.taskMap=new Map,e.reduce((s,i)=>s.concat(i.suites.flatMap(a=>a.tasks)),[]).forEach(s=>{let i={};i.promise=new Promise((a,d)=>{i.resolve=a,i.reject=d}),this.taskMap.set(s,i)});let o=s=>s.map(i=>({title:i.name,skip:()=>i.mode==="skip",task:async()=>{var a;return await((a=this.taskMap.get(i))==null?void 0:a.promise)}})),r={exitOnError:!1};this.listr=new U(e.map(s=>({title:this.relative(s.filepath),task:()=>{if(s.error)throw s.error;let i=s.suites.filter(a=>a.tasks.length);if(!i.length)throw new Error("No tasks found");return new U(i.flatMap(a=>a.name?[{title:a.name,skip:()=>a.mode!=="run",task:()=>new U(o(a.tasks),r)}]:o(a.tasks)),r)}})),r),this.listrPromise=this.listr.run().catch(()=>{})}onTaskEnd(e){var n,o;e.state==="fail"?(n=this.taskMap.get(e))==null||n.reject(e.error):(o=this.taskMap.get(e))==null||o.resolve()}async onFinished(e,n=e.files){var v;await this.listrPromise,this.end=ue.now(),console.log();let o=e.snapshotManager.report();o&&console.log(o.join(`
11
- `));let r=n.flatMap(l=>l.suites),s=r.flatMap(l=>l.tasks),i=n.filter(l=>l.error),a=r.filter(l=>l.error),d=s.filter(l=>l.state==="pass"||l.state==="fail"),w=s.filter(l=>l.state==="pass"),h=s.filter(l=>l.state==="fail"),S=s.filter(l=>l.state==="skip"),k=s.filter(l=>l.state==="todo");if(i.length){console.error(u.red(u.bold(`
10
+ `))}onCollected(e){this.start=ue.now(),this.taskMap=new Map,e.reduce((s,i)=>s.concat(i.suites.flatMap(a=>a.tasks)),[]).forEach(s=>{let i={};i.promise=new Promise((a,d)=>{i.resolve=a,i.reject=d}),this.taskMap.set(s,i)});let n=s=>s.map(i=>({title:i.name,skip:()=>i.mode==="skip",task:async()=>{var a;return await((a=this.taskMap.get(i))==null?void 0:a.promise)}})),r={exitOnError:!1};this.listr=new U(e.map(s=>({title:this.relative(s.filepath),task:()=>{if(s.error)throw s.error;let i=s.suites.filter(a=>a.tasks.length);if(!i.length)throw new Error("No tasks found");return new U(i.flatMap(a=>a.name?[{title:a.name,skip:()=>a.mode!=="run",task:()=>new U(n(a.tasks),r)}]:n(a.tasks)),r)}})),r),this.listrPromise=this.listr.run().catch(()=>{})}onTaskEnd(e){var o,n;e.state==="fail"?(o=this.taskMap.get(e))==null||o.reject(e.error):(n=this.taskMap.get(e))==null||n.resolve()}async onFinished(e,o=e.files){var v;await this.listrPromise,this.end=ue.now(),console.log();let n=e.snapshotManager.report();n&&console.log(n.join(`
11
+ `));let r=o.flatMap(l=>l.suites),s=r.flatMap(l=>l.tasks),i=o.filter(l=>l.error),a=r.filter(l=>l.error),d=s.filter(l=>l.state==="pass"||l.state==="fail"),w=s.filter(l=>l.state==="pass"),h=s.filter(l=>l.state==="fail"),S=s.filter(l=>l.state==="skip"),k=s.filter(l=>l.state==="todo");if(i.length){console.error(u.red(u.bold(`
12
12
  Failed to parse ${i.length} files:`)));for(let l of i)console.error(u.red(`- ${l.filepath}`));console.log();for(let l of i)await R(l.error),console.log()}if(a.length){console.error(u.bold(u.red(`
13
13
  Failed to run ${a.length} suites:`)));for(let l of a)console.error(u.red(`
14
14
  - ${(v=l.file)==null?void 0:v.filepath} > ${l.name}`)),await R(l.error),console.log()}if(h.length){console.error(u.bold(u.red(`
15
15
  Failed Tests (${h.length})`)));for(let l of h)console.error(`${u.red(`
16
- ${Ve+u.inverse(" FAIL ")}`)} ${[l.suite.name,l.name].filter(Boolean).join(" > ")}`),await R(l.error),console.log()}console.log(u.bold(u.green(`Passed ${w.length} / ${d.length}`))),h.length&&console.log(u.bold(u.red(`Failed ${h.length} / ${d.length}`))),S.length&&console.log(u.yellow(`Skipped ${S.length}`)),k.length&&console.log(u.dim(`Todo ${k.length}`)),console.log(`Time ${(this.end-this.start).toFixed(2)}ms`)}async onWatcherStart(e){await this.listrPromise;let n=e.tasks.filter(o=>o.state==="fail");n.length?console.log(`
17
- ${u.bold(u.inverse(u.red(" FAIL ")))}${u.red(` ${n.length} tests failed. Watching for file changes...`)}`):console.log(`
18
- ${u.bold(u.inverse(u.green(" PASS ")))}${u.green(" Watching for file changes...")}`)}async onWatcherRerun(e,n){await this.listrPromise,console.clear(),console.log(u.blue("Re-running tests...")+u.dim(` [ ${this.relative(n)} ]
19
- `))}onSnapshotUpdate(){}};async function de(t){return await ae(t),t.global&&(await import("../global-CKRMAXWF.js")).registerApiGlobally(),t.dom==="happy-dom"?(await import("../happy-dom-RNJZR3YC.js")).setupHappyDOM(globalThis):t.dom&&(await import("../jsdom-6QAZGE6T.js")).setupJSDOM(globalThis),{filesMap:{},get files(){return Object.values(this.filesMap)},get suites(){return Object.values(this.filesMap).reduce((n,o)=>n.concat(o.suites),[])},get tasks(){return this.suites.reduce((n,o)=>n.concat(o.tasks),[])},config:t,reporter:t.reporter||new W,snapshotManager:T()}}c();import Ye from"fast-glob";async function he(t){var n;let e=await Ye(t.includes||I,{absolute:!0,cwd:t.root,ignore:t.excludes||K});return((n=t.filters)==null?void 0:n.length)&&(e=e.filter(o=>t.filters.some(r=>o.includes(r)))),e}async function O(t,e,n){await Promise.all(t.hooks[e].map(o=>o(...n)))}async function fe(t,e){var o,r,s;let{reporter:n}=e;if((o=T())==null||o.setTask(t),await((r=n.onTaskBegin)==null?void 0:r.call(n,t,e)),t.mode==="run"){try{await O(t.suite,"beforeEach",[t,t.suite]),await t.fn(),t.state="pass"}catch(i){t.state="fail",t.error=i,process.exitCode=1}try{await O(t.suite,"afterEach",[t,t.suite])}catch(i){t.state="fail",t.error=i,process.exitCode=1}}await((s=n.onTaskEnd)==null?void 0:s.call(n,t,e))}function L(t){t.some(e=>e.mode==="only")&&t.forEach(e=>{e.mode==="run"?e.mode="skip":e.mode==="only"&&(e.mode="run")})}async function pe(t,e){var o,r;let{reporter:n}=e;if(await((o=n.onSuiteBegin)==null?void 0:o.call(n,t,e)),t.mode==="skip")t.status="skip";else if(t.mode==="todo")t.status="todo";else try{await O(t,"beforeAll",[t]);for(let s of Qe(t.tasks))if(s[0].concurrent)await Promise.all(s.map(i=>fe(i,e)));else for(let i of s)await fe(i,e);await O(t,"afterAll",[t])}catch(s){t.error=s,t.status="fail",process.exitCode=1}await((r=n.onSuiteEnd)==null?void 0:r.call(n,t,e))}function Qe(t){let e=[],n=[];for(let o of t)e.length===0||!!o.concurrent==!!e[0].concurrent?e.push(o):(n.push(e),e=[o]);return e.length>0&&n.push(e),n}async function Xe(t,e){var r,s;let{reporter:n}=e;if(t.suites.filter(i=>i.mode==="run").length!==0){if(await((r=n.onFileBegin)==null?void 0:r.call(n,t,e)),e.config.parallel)await Promise.all(t.suites.map(i=>pe(i,e)));else for(let i of t.suites)await pe(i,e);await((s=n.onFileEnd)==null?void 0:s.call(n,t,e))}}async function N(t,e){var o;let{reporter:n}=e;await((o=n.onCollected)==null?void 0:o.call(n,Object.values(t),e));for(let r of Object.values(t))await Xe(r,e)}async function me(t){var a,d;t.watch&&(process.__vite_node__.watch=!0);let e=await he(t);if(!e.length){console.error("No test files found"),process.exitCode=1;return}let n=await de(t),{filesMap:o,snapshotManager:r,reporter:s}=n;await((a=s.onStart)==null?void 0:a.call(s,t));let i=await M(e);Object.assign(o,i),await N(o,n),r.saveSnap(),await((d=s.onFinished)==null?void 0:d.call(s,n)),t.watch&&await se(n)}if(!process.__vite_node__||!process.__vitest__)throw new Error("Vitest can only run in vite-node environment, please use the CLI to start the process");var Ze=process.__vite_node__.server.config.test||{},et=process.__vitest__.options||{},tt=A(A({},et),Ze);await me(tt);var nt=setTimeout(()=>{process.exit()},500);nt.unref();
16
+ ${Ve+u.inverse(" FAIL ")}`)} ${[l.suite.name,l.name].filter(Boolean).join(" > ")}`),await R(l.error),console.log()}console.log(u.bold(u.green(`Passed ${w.length} / ${d.length}`))),h.length&&console.log(u.bold(u.red(`Failed ${h.length} / ${d.length}`))),S.length&&console.log(u.yellow(`Skipped ${S.length}`)),k.length&&console.log(u.dim(`Todo ${k.length}`)),console.log(`Time ${(this.end-this.start).toFixed(2)}ms`)}async onWatcherStart(e){await this.listrPromise;let o=e.tasks.filter(n=>n.state==="fail");o.length?console.log(`
17
+ ${u.bold(u.inverse(u.red(" FAIL ")))}${u.red(` ${o.length} tests failed. Watching for file changes...`)}`):console.log(`
18
+ ${u.bold(u.inverse(u.green(" PASS ")))}${u.green(" Watching for file changes...")}`)}async onWatcherRerun(e,o){await this.listrPromise,console.clear(),console.log(u.blue("Re-running tests...")+u.dim(` [ ${this.relative(o)} ]
19
+ `))}onSnapshotUpdate(){}};async function de(t){return await ae(t),t.global&&(await import("../global-PFX5FMYU.js")).registerApiGlobally(),t.dom==="happy-dom"?(await import("../happy-dom-RNJZR3YC.js")).setupHappyDOM(globalThis):t.dom&&(await import("../jsdom-6QAZGE6T.js")).setupJSDOM(globalThis),{filesMap:{},get files(){return Object.values(this.filesMap)},get suites(){return Object.values(this.filesMap).reduce((o,n)=>o.concat(n.suites),[])},get tasks(){return this.suites.reduce((o,n)=>o.concat(n.tasks),[])},config:t,reporter:t.reporter||new W,snapshotManager:T()}}c();import Ye from"fast-glob";async function he(t){var o;let e=await Ye(t.includes||q,{absolute:!0,cwd:t.root,ignore:t.excludes||z});return((o=t.filters)==null?void 0:o.length)&&(e=e.filter(n=>t.filters.some(r=>n.includes(r)))),e}async function O(t,e,o){await Promise.all(t.hooks[e].map(n=>n(...o)))}async function fe(t,e){var n,r,s;let{reporter:o}=e;if((n=T())==null||n.setTask(t),await((r=o.onTaskBegin)==null?void 0:r.call(o,t,e)),t.mode==="run"){try{await O(t.suite,"beforeEach",[t,t.suite]),await t.fn(),t.state="pass"}catch(i){t.state="fail",t.error=i,process.exitCode=1}try{await O(t.suite,"afterEach",[t,t.suite])}catch(i){t.state="fail",t.error=i,process.exitCode=1}}await((s=o.onTaskEnd)==null?void 0:s.call(o,t,e))}function L(t){t.some(e=>e.mode==="only")&&t.forEach(e=>{e.mode==="run"?e.mode="skip":e.mode==="only"&&(e.mode="run")})}async function pe(t,e){var n,r;let{reporter:o}=e;if(await((n=o.onSuiteBegin)==null?void 0:n.call(o,t,e)),t.mode==="skip")t.status="skip";else if(t.mode==="todo")t.status="todo";else try{await O(t,"beforeAll",[t]);for(let s of Qe(t.tasks)){let i=s[0].computeMode;if(i==="serial")for(let a of s)await fe(a,e);else i==="concurrent"&&await Promise.all(s.map(a=>fe(a,e)))}await O(t,"afterAll",[t])}catch(s){t.error=s,t.status="fail",process.exitCode=1}await((r=o.onSuiteEnd)==null?void 0:r.call(o,t,e))}function Qe(t){let e=[],o=[];for(let n of t)e.length===0||n.computeMode===e[0].computeMode?e.push(n):(o.push(e),e=[n]);return e.length>0&&o.push(e),o}async function Xe(t,e){var r,s;let{reporter:o}=e;if(t.suites.filter(i=>i.mode==="run").length!==0){if(await((r=o.onFileBegin)==null?void 0:r.call(o,t,e)),e.config.parallel)await Promise.all(t.suites.map(i=>pe(i,e)));else for(let i of t.suites)await pe(i,e);await((s=o.onFileEnd)==null?void 0:s.call(o,t,e))}}async function N(t,e){var n;let{reporter:o}=e;await((n=o.onCollected)==null?void 0:n.call(o,Object.values(t),e));for(let r of Object.values(t))await Xe(r,e)}async function me(t){var a,d;t.watch&&(process.__vite_node__.watch=!0);let e=await he(t);if(!e.length){console.error("No test files found"),process.exitCode=1;return}let o=await de(t),{filesMap:n,snapshotManager:r,reporter:s}=o;await((a=s.onStart)==null?void 0:a.call(s,t));let i=await M(e);Object.assign(n,i),await N(n,o),r.saveSnap(),await((d=s.onFinished)==null?void 0:d.call(s,o)),t.watch&&await se(o)}if(!process.__vite_node__||!process.__vitest__)throw new Error("Vitest can only run in vite-node environment, please use the CLI to start the process");var Ze=process.__vite_node__.server.config.test||{},et=process.__vitest__.options||{},tt=A(A({},et),Ze);await me(tt);var ot=setTimeout(()=>{process.exit()},500);ot.unref();
@@ -114,13 +114,11 @@ interface ResolvedConfig extends Required<UserOptions> {
114
114
  }
115
115
  declare type RunMode = 'run' | 'skip' | 'only' | 'todo';
116
116
  declare type TaskState = RunMode | 'pass' | 'fail';
117
- interface ConcurrentOptions {
118
- timeout: number;
119
- }
117
+ declare type ComputeMode = 'serial' | 'concurrent';
120
118
  interface Task {
121
119
  name: string;
122
120
  mode: RunMode;
123
- concurrent?: ConcurrentOptions;
121
+ computeMode: ComputeMode;
124
122
  suite: Suite;
125
123
  fn: () => Awaitable<void>;
126
124
  file?: File;
@@ -129,18 +127,18 @@ interface Task {
129
127
  }
130
128
  declare type TestFunction = () => Awaitable<void>;
131
129
  interface ConcurrentCollector {
132
- (name: string, fn: TestFunction, timeout?: number): void;
133
- only: (name: string, fn: TestFunction, timeout?: number) => void;
134
- skip: (name: string, fn: TestFunction, timeout?: number) => void;
130
+ (name: string, fn: TestFunction): void;
131
+ only: (name: string, fn: TestFunction) => void;
132
+ skip: (name: string, fn: TestFunction) => void;
135
133
  todo: (name: string) => void;
136
134
  }
137
135
  interface OnlyCollector {
138
136
  (name: string, fn: TestFunction): void;
139
- concurrent: (name: string, fn: TestFunction, timeout?: number) => void;
137
+ concurrent: (name: string, fn: TestFunction) => void;
140
138
  }
141
139
  interface SkipCollector {
142
140
  (name: string, fn: TestFunction): void;
143
- concurrent: (name: string, fn: TestFunction, timeout?: number) => void;
141
+ concurrent: (name: string, fn: TestFunction) => void;
144
142
  }
145
143
  interface TodoCollector {
146
144
  (name: string): void;
@@ -210,4 +208,4 @@ interface Reporter {
210
208
  onWatcherRerun?: (files: string[], trigger: string, ctx: RunnerContext) => Awaitable<void>;
211
209
  }
212
210
 
213
- export { ConcurrentOptions as C, File as F, GlobalContext as G, HookListener as H, ResolvedConfig as R, SuiteCollector as S, TestFunction as T, UserOptions as U, TestFactory as a, Suite as b, RunMode as c, TaskState as d, Task as e, TestCollector as f, RunnerContext as g, Reporter as h };
211
+ export { ComputeMode as C, File as F, GlobalContext as G, HookListener as H, ResolvedConfig as R, SuiteCollector as S, TestFactory as T, UserOptions as U, TestFunction as a, Suite as b, RunMode as c, TaskState as d, Task as e, TestCollector as f, RunnerContext as g, Reporter as h };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vitest",
3
- "version": "0.0.38",
3
+ "version": "0.0.39",
4
4
  "description": "A blazing fast unit test framework powered by Vite",
5
5
  "keywords": [
6
6
  "vite",
@@ -1 +0,0 @@
1
- import{a as k,b as F,f as d}from"./chunk-XPSQDVUG.js";d();var O=["**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"],R=["**/node_modules/**","**/dist/**"],G=["suite","test","describe","it","chai","expect","assert","sinon","spy","mock","stub","beforeAll","afterAll","beforeEach","afterEach"],C=5e3;d();d();var g={suites:[],currentSuite:null};var y=h("");function s(){return g.currentSuite||y}function x(t,r=()=>{},u){let c=[],i=[],e={name:t,mode:u,hooks:{beforeAll:[],afterAll:[],beforeEach:[],afterEach:[]}},n=j((f,p,a,T)=>{c.push({name:f,mode:a,concurrent:T,suite:{},state:a!=="run"&&a!=="only"?a:void 0,fn:p})}),o={name:t,mode:u,test:n,collect:A,clear:E,on:l};function l(f,...p){e.hooks[f].push(...p)}function E(){c.length=0,i.length=0}async function A(f){i.length=0,r&&await r(n);let p=[...i,...c],a=F(k({},e),{tasks:p,file:f});return p.forEach(T=>{T.suite=a,f&&(T.file=f)}),a}return g.currentSuite=o,g.suites.push(o),o}function b(t){return{timeout:t??C}}function j(t){function r(n,o){t(n,o,"run")}r.concurrent=u,r.skip=c,r.only=i,r.todo=e;function u(n,o,l){t(n,o,"run",b(l))}u.skip=(n,o,l)=>t(n,o,"skip",b(l)),u.only=(n,o,l)=>t(n,o,"only",b(l)),u.todo=e;function c(n,o){t(n,o,"skip")}c.concurrent=u.skip;function i(n,o){t(n,o,"only")}i.concurrent=u.only;function e(n){t(n,()=>{},"todo")}return e.concurrent=e,r}var M=function(){function t(e,n){return s().test(e,n)}function r(e,n,o){return s().test.concurrent(e,n,o)}r.skip=(e,n,o)=>s().test.concurrent.skip(e,n,o),r.only=(e,n,o)=>s().test.concurrent.only(e,n,o),r.todo=e=>s().test.concurrent.todo(e);function u(e,n){return s().test.skip(e,n)}u.concurrent=(e,n,o)=>s().test.skip.concurrent(e,n,o);function c(e,n){return s().test.only(e,n)}c.concurrent=(e,n,o)=>s().test.only.concurrent(e,n,o);function i(e){return s().test.todo(e)}return i.concurrent=e=>s().test.todo.concurrent(e),t.concurrent=r,t.skip=u,t.only=c,t.todo=i,t}();function h(t,r){return x(t,r,"run")}h.skip=(t,r)=>x(t,r,"skip");h.only=(t,r)=>x(t,r,"only");h.todo=t=>x(t,void 0,"todo");var H=h,I=M,P=t=>s().on("beforeAll",t),Q=t=>s().on("afterAll",t),_=t=>s().on("beforeEach",t),z=t=>s().on("afterEach",t);function D(){g.suites.length=0,y.clear(),g.currentSuite=y}export{g as a,O as b,R as c,G as d,y as e,M as f,h as g,H as h,I as i,P as j,Q as k,_ as l,z as m,D as n};
@@ -1 +0,0 @@
1
- import{e as r,f as a,g as s,h as l,i as c,j as d,k as u,l as p,m as f,n as m}from"./chunk-4OVO6RD6.js";import{d as i,f as e}from"./chunk-XPSQDVUG.js";var T={};i(T,{afterAll:()=>u,afterEach:()=>f,assert:()=>g,beforeAll:()=>d,beforeEach:()=>p,chai:()=>x,clearContext:()=>m,defaultSuite:()=>r,describe:()=>l,expect:()=>C,it:()=>c,mock:()=>b,should:()=>v,sinon:()=>t,spy:()=>k,stub:()=>S,suite:()=>s,test:()=>a});e();e();e();import x from"chai";import{assert as g,should as v,expect as C}from"chai";e();import t from"sinon";var{mock:b,spy:k,stub:S}=t;t.fn=t.spy;export{x as a,g as b,v as c,C as d,t as e,b as f,k as g,S as h,T as i};
@@ -1 +0,0 @@
1
- import{i as l}from"./chunk-CUG6SVUZ.js";import{d as r}from"./chunk-4OVO6RD6.js";import{f as i}from"./chunk-XPSQDVUG.js";i();function a(){r.forEach(o=>{globalThis[o]=l[o]})}export{a as registerApiGlobally};