vitest 1.5.3 → 2.0.0-beta.1
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/LICENSE.md +172 -0
- package/dist/browser.d.ts +1 -1
- package/dist/browser.js +4 -4
- package/dist/chunks/environments-node.39w4gmlF.js +19 -0
- package/dist/chunks/{install-pkg.LE8oaA1t.js → install-pkg.DNUmWFkO.js} +2 -2
- package/dist/chunks/integrations-globals.B5Jl0grA.js +31 -0
- package/dist/chunks/{runtime-console.EO5ha7qv.js → runtime-console.CUES-L8X.js} +9 -9
- package/dist/chunks/{runtime-runBaseTests.l6qXp5eU.js → runtime-runBaseTests._dXkRAZc.js} +21 -22
- package/dist/cli.js +3 -3
- package/dist/config.cjs +2 -3
- package/dist/config.d.ts +1 -1
- package/dist/config.js +2 -3
- package/dist/coverage.d.ts +1 -1
- package/dist/coverage.js +2 -2
- package/dist/environments.d.ts +1 -1
- package/dist/environments.js +1 -1
- package/dist/execute.d.ts +7 -4
- package/dist/execute.js +3 -3
- package/dist/index.d.ts +770 -21
- package/dist/index.js +12 -12
- package/dist/node.d.ts +2 -2
- package/dist/node.js +21 -22
- package/dist/{reporters-BXNXFKfg.d.ts → reporters-MGvT5U9f.d.ts} +128 -55
- package/dist/reporters.d.ts +1 -1
- package/dist/reporters.js +11 -12
- package/dist/runners.d.ts +1 -1
- package/dist/runners.js +17 -18
- package/dist/snapshot.d.ts +9 -0
- package/dist/snapshot.js +8 -0
- package/dist/{suite-KPWE530F.d.ts → suite-8WAe-urM.d.ts} +1 -1
- package/dist/suite.d.ts +2 -2
- package/dist/suite.js +4 -4
- package/dist/vendor/{base.oIzAvGLe.js → base.VFkIJ66g.js} +3 -3
- package/dist/vendor/{base.Xt0Omgh7.js → base._gnK9Slw.js} +8 -1
- package/dist/vendor/{benchmark.yGkUTKnC.js → benchmark.BNLebNi5.js} +1 -1
- package/dist/vendor/{cac.RDd_SGOd.js → cac.DzKZaJu2.js} +39 -17
- package/dist/vendor/{cli-api.AmIc1Dmz.js → cli-api.DTeni0Qq.js} +3201 -404
- package/dist/vendor/{execute.2_yoIC01.js → execute.CLLNVNnK.js} +8 -3
- package/dist/vendor/{index.Fm6OikHU.js → index.BfoZyXD1.js} +20 -21
- package/dist/vendor/{index.8bPxjt7g.js → index.BpSiYbpB.js} +5 -1
- package/dist/vendor/{index.X7lgIMc_.js → index.CRxYS9H3.js} +586 -230
- package/dist/vendor/{index.QVcwRDVW.js → index.CmILuxzC.js} +8 -6
- package/dist/vendor/{index.xL8XjTLv.js → index.DP-km6lF.js} +1 -1
- package/dist/vendor/{index.SMVOaj7F.js → index._7XLd8Kd.js} +2 -2
- package/dist/vendor/{rpc.joBhAkyK.js → rpc.DRDE9Pu1.js} +2 -2
- package/dist/vendor/{run-once.Olz_Zkd8.js → run-once.DLomgGUH.js} +1 -1
- package/dist/vendor/{setup-common.5nUd4r76.js → setup-common.XeoZAW8t.js} +2 -2
- package/dist/vendor/{tasks.IknbGB2n.js → tasks.WC7M-K-v.js} +4 -1
- package/dist/vendor/{utils.VYmeMh-u.js → utils.D5gGkwyH.js} +1 -1
- package/dist/vendor/{vi.Y_w82WR8.js → vi.ClD3hi7L.js} +23 -10
- package/dist/vendor/{vm.i4FO5N37.js → vm.Bi3bljci.js} +132 -54
- package/dist/worker.js +13 -7
- package/dist/workers/forks.js +6 -6
- package/dist/workers/runVmTests.js +22 -20
- package/dist/workers/threads.js +6 -6
- package/dist/workers/vmForks.js +9 -9
- package/dist/workers/vmThreads.js +9 -9
- package/dist/workers.d.ts +1 -1
- package/dist/workers.js +14 -14
- package/package.json +33 -29
- package/snapshot.d.ts +1 -0
- package/vitest.mjs +1 -1
- package/dist/chunks/integrations-globals.Hr6znn-f.js +0 -31
- package/dist/cli-wrapper.js +0 -119
- /package/dist/chunks/{node-git.Hw101KjS.js → node-git.CCI8evVZ.js} +0 -0
- /package/dist/vendor/{_commonjsHelpers.jjO7Zipk.js → _commonjsHelpers.BFTU3MAI.js} +0 -0
- /package/dist/vendor/{constants.5J7I254_.js → constants.5SOfHUj0.js} +0 -0
- /package/dist/vendor/{coverage.E7sG1b3r.js → coverage.ChSqD-qS.js} +0 -0
- /package/dist/vendor/{date.Ns1pGd_X.js → date.BKM1wewY.js} +0 -0
- /package/dist/vendor/{env.AtSIuHFg.js → env.bmJgw1qP.js} +0 -0
- /package/dist/vendor/{global.CkGT_TMy.js → global.7bFbnyXl.js} +0 -0
- /package/dist/vendor/{index.GVFv9dZ0.js → index.DeR1hhfY.js} +0 -0
- /package/dist/vendor/{inspector.IgLX3ur5.js → inspector.hPQncR7V.js} +0 -0
- /package/dist/vendor/{utils.0uYuCbzo.js → utils.CUjzkRH7.js} +0 -0
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import { existsSync, promises, readFileSync } from 'node:fs';
|
|
1
|
+
import fs, { existsSync, promises, readFileSync } from 'node:fs';
|
|
2
|
+
import c from 'picocolors';
|
|
3
|
+
import * as pathe from 'pathe';
|
|
2
4
|
import { basename, dirname, resolve, join, relative, extname, normalize } from 'pathe';
|
|
3
|
-
import {
|
|
5
|
+
import { a as getFullName, h as hasFailedSnapshot } from './tasks.WC7M-K-v.js';
|
|
4
6
|
import { getSafeTimers, notNullish, highlight, shuffle, inspect, positionToOffset, lineSplitRE } from '@vitest/utils';
|
|
5
|
-
import { i as isNode } from './env.
|
|
6
|
-
import c from '
|
|
7
|
-
import {
|
|
8
|
-
import { g as getStateSymbol, f as formatProjectName, p as pointer, F as F_RIGHT, r as renderSnapshotSummary, a as getStateString, b as formatTimeString, c as countTestErrors, d as divider, s as stripAnsi, e as getCols, h as getHookStateSymbol, i as F_POINTER } from './utils.VYmeMh-u.js';
|
|
7
|
+
import { i as isNode } from './env.bmJgw1qP.js';
|
|
8
|
+
import { g as getStateSymbol, f as formatProjectName, p as pointer, F as F_RIGHT, r as renderSnapshotSummary, a as getStateString, b as formatTimeString, c as countTestErrors, d as divider, s as stripAnsi, e as getCols, h as getHookStateSymbol, i as F_POINTER } from './utils.D5gGkwyH.js';
|
|
9
|
+
import { generateHash, calculateSuiteHash, someTasksAreOnly, interpretTaskModes, getTasks, getTests, hasFailed, getSuites } from '@vitest/runner/utils';
|
|
9
10
|
import { performance } from 'node:perf_hooks';
|
|
10
|
-
import { r as relativePath } from './index.
|
|
11
|
-
import { UNKNOWN_TEST_ID } from '../chunks/runtime-console.
|
|
12
|
-
import { t as toArray, b as isPrimitive } from './base.
|
|
11
|
+
import { r as relativePath } from './index._7XLd8Kd.js';
|
|
12
|
+
import { UNKNOWN_TEST_ID } from '../chunks/runtime-console.CUES-L8X.js';
|
|
13
|
+
import { t as toArray, b as isPrimitive } from './base._gnK9Slw.js';
|
|
13
14
|
import { isCI } from 'std-env';
|
|
14
15
|
import { TraceMap, generatedPositionFor, parseErrorStacktrace } from '@vitest/utils/source-map';
|
|
15
16
|
import nodeos__default, { hostname } from 'node:os';
|
|
@@ -21,10 +22,9 @@ import p$1 from 'path';
|
|
|
21
22
|
import require$$0 from 'fs';
|
|
22
23
|
import ge from 'module';
|
|
23
24
|
import { parseAstAsync } from 'vite';
|
|
24
|
-
import { ancestor } from 'acorn-walk';
|
|
25
25
|
import { Console } from 'node:console';
|
|
26
26
|
import process$2 from 'node:process';
|
|
27
|
-
import { g as getDefaultExportFromCjs, c as commonjsGlobal } from './_commonjsHelpers.
|
|
27
|
+
import { g as getDefaultExportFromCjs, c as commonjsGlobal } from './_commonjsHelpers.BFTU3MAI.js';
|
|
28
28
|
import require$$0$2 from 'assert';
|
|
29
29
|
import require$$0$1 from 'events';
|
|
30
30
|
import { createHash } from 'node:crypto';
|
|
@@ -53,11 +53,15 @@ function wrapSerializableConfig(config) {
|
|
|
53
53
|
};
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
const A=r=>r!==null&&typeof r=="object",a=(r,t)=>Object.assign(new Error(`[${r}]: ${t}`),{code:r}),_$1="ERR_INVALID_PACKAGE_CONFIG",E
|
|
56
|
+
const A=r=>r!==null&&typeof r=="object",a=(r,t)=>Object.assign(new Error(`[${r}]: ${t}`),{code:r}),_$1="ERR_INVALID_PACKAGE_CONFIG",E="ERR_INVALID_PACKAGE_TARGET",I$1="ERR_PACKAGE_PATH_NOT_EXPORTED",R$1=/^\d+$/,O=/^(\.{1,2}|node_modules)$/i,w=/\/|\\/;var h$1=(r=>(r.Export="exports",r.Import="imports",r))(h$1||{});const f=(r,t,e,o,c)=>{if(t==null)return [];if(typeof t=="string"){const[n,...i]=t.split(w);if(n===".."||i.some(l=>O.test(l)))throw a(E,`Invalid "${r}" target "${t}" defined in the package config`);return [c?t.replace(/\*/g,c):t]}if(Array.isArray(t))return t.flatMap(n=>f(r,n,e,o,c));if(A(t)){for(const n of Object.keys(t)){if(R$1.test(n))throw a(_$1,"Cannot contain numeric property keys");if(n==="default"||o.includes(n))return f(r,t[n],e,o,c)}return []}throw a(E,`Invalid "${r}" target "${t}"`)},s="*",m=(r,t)=>{const e=r.indexOf(s),o=t.indexOf(s);return e===o?t.length>r.length:o>e};function d(r,t){if(!t.includes(s)&&r.hasOwnProperty(t))return [t];let e,o;for(const c of Object.keys(r))if(c.includes(s)){const[n,i,l]=c.split(s);if(l===void 0&&t.startsWith(n)&&t.endsWith(i)){const g=t.slice(n.length,-i.length||void 0);g&&(!e||m(e,c))&&(e=c,o=g);}}return [e,o]}const p=r=>Object.keys(r).reduce((t,e)=>{const o=e===""||e[0]!==".";if(t===void 0||t===o)return o;throw a(_$1,'"exports" cannot contain some keys starting with "." and some not')},void 0),u=/^\w+:/,v=(r,t,e)=>{if(!r)throw new Error('"exports" is required');t=t===""?".":`./${t}`,(typeof r=="string"||Array.isArray(r)||A(r)&&p(r))&&(r={".":r});const[o,c]=d(r,t),n=f(h$1.Export,r[o],t,e,c);if(n.length===0)throw a(I$1,t==="."?'No "exports" main defined':`Package subpath '${t}' is not defined by "exports"`);for(const i of n)if(!i.startsWith("./")&&!u.test(i))throw a(E,`Invalid "exports" target "${i}" defined in the package config`);return n};
|
|
57
57
|
|
|
58
|
-
function B(e){return e.startsWith("\\\\?\\")?e:e.replace(/\\/g,"/")}const
|
|
59
|
-
`;break;case 114:
|
|
60
|
-
`),m++,b=n,s=14;switch(u){case 123:return n++,s=1;case 125:return n++,s=2;case 91:return n++,s=3;case 93:return n++,s=4;case 58:return n++,s=6;case 44:return n++,s=5;case 34:return n++,t=k(),s=10;case 47:const g=n-1;if(e.charCodeAt(n+1)===47){for(n+=2;n<i&&!_(e.charCodeAt(n));)n++;return t=e.substring(g,n),s=12}if(e.charCodeAt(n+1)===42){n+=2;const f=i-1;let $=!1;for(;n<f;){const O=e.charCodeAt(n);if(O===42&&e.charCodeAt(n+1)===47){n+=2,$=!0;break}n++,_(O)&&(O===13&&e.charCodeAt(n)===10&&n++,m++,b=n);}return $||(n++,c=1),t=e.substring(g,n),s=13}return t+=String.fromCharCode(u),n++,s=16;case 45:if(t+=String.fromCharCode(u),n++,n===i||!N(e.charCodeAt(n)))return s=16;case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return t+=w(),s=11;default:for(;n<i&&U(u);)n++,u=e.charCodeAt(n);if(l!==n){switch(t=e.substring(l,n),t){case"true":return s=8;case"false":return s=9;case"null":return s=7}return s=16}return t+=String.fromCharCode(u),n++,s=16}}function U(u){if(J(u)||_(u))return !1;switch(u){case 125:case 93:case 123:case 91:case 34:case 58:case 44:case 47:return !1}return !0}function F(){let u;do u=j();while(u>=12&&u<=15);return u}return {setPosition:T,getPosition:()=>n,scan:o?F:j,getToken:()=>s,getTokenValue:()=>t,getTokenOffset:()=>l,getTokenLength:()=>n-l,getTokenStartLine:()=>r,getTokenStartCharacter:()=>l-v,getTokenError:()=>c}}function J(e){return e===32||e===9}function _(e){return e===10||e===13}function N(e){return e>=48&&e<=57}var q;(function(e){e[e.lineFeed=10]="lineFeed",e[e.carriageReturn=13]="carriageReturn",e[e.space=32]="space",e[e._0=48]="_0",e[e._1=49]="_1",e[e._2=50]="_2",e[e._3=51]="_3",e[e._4=52]="_4",e[e._5=53]="_5",e[e._6=54]="_6",e[e._7=55]="_7",e[e._8=56]="_8",e[e._9=57]="_9",e[e.a=97]="a",e[e.b=98]="b",e[e.c=99]="c",e[e.d=100]="d",e[e.e=101]="e",e[e.f=102]="f",e[e.g=103]="g",e[e.h=104]="h",e[e.i=105]="i",e[e.j=106]="j",e[e.k=107]="k",e[e.l=108]="l",e[e.m=109]="m",e[e.n=110]="n",e[e.o=111]="o",e[e.p=112]="p",e[e.q=113]="q",e[e.r=114]="r",e[e.s=115]="s",e[e.t=116]="t",e[e.u=117]="u",e[e.v=118]="v",e[e.w=119]="w",e[e.x=120]="x",e[e.y=121]="y",e[e.z=122]="z",e[e.A=65]="A",e[e.B=66]="B",e[e.C=67]="C",e[e.D=68]="D",e[e.E=69]="E",e[e.F=70]="F",e[e.G=71]="G",e[e.H=72]="H",e[e.I=73]="I",e[e.J=74]="J",e[e.K=75]="K",e[e.L=76]="L",e[e.M=77]="M",e[e.N=78]="N",e[e.O=79]="O",e[e.P=80]="P",e[e.Q=81]="Q",e[e.R=82]="R",e[e.S=83]="S",e[e.T=84]="T",e[e.U=85]="U",e[e.V=86]="V",e[e.W=87]="W",e[e.X=88]="X",e[e.Y=89]="Y",e[e.Z=90]="Z",e[e.asterisk=42]="asterisk",e[e.backslash=92]="backslash",e[e.closeBrace=125]="closeBrace",e[e.closeBracket=93]="closeBracket",e[e.colon=58]="colon",e[e.comma=44]="comma",e[e.dot=46]="dot",e[e.doubleQuote=34]="doubleQuote",e[e.minus=45]="minus",e[e.openBrace=123]="openBrace",e[e.openBracket=91]="openBracket",e[e.plus=43]="plus",e[e.slash=47]="slash",e[e.formFeed=12]="formFeed",e[e.tab=9]="tab";})(q||(q={}));var I;(function(e){e.DEFAULT={allowTrailingComma:!1};})(I||(I={}));function Te(e,o=[],i=I.DEFAULT){let n=null,t=[];const l=[];function s(r){Array.isArray(t)?t.push(r):n!==null&&(t[n]=r);}return we(e,{onObjectBegin:()=>{const r={};s(r),l.push(t),t=r,n=null;},onObjectProperty:r=>{n=r;},onObjectEnd:()=>{t=l.pop();},onArrayBegin:()=>{const r=[];s(r),l.push(t),t=r,n=null;},onArrayEnd:()=>{t=l.pop();},onLiteralValue:s,onError:(r,b,v)=>{o.push({error:r,offset:b,length:v});}},i),t[0]}function we(e,o,i=I.DEFAULT){const n=be(e,!1),t=[];function l(a){return a?()=>a(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter()):()=>!0}function s(a){return a?()=>a(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter(),()=>t.slice()):()=>!0}function m(a){return a?A=>a(A,n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter()):()=>!0}function r(a){return a?A=>a(A,n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter(),()=>t.slice()):()=>!0}const b=s(o.onObjectBegin),v=r(o.onObjectProperty),c=l(o.onObjectEnd),L=s(o.onArrayBegin),T=l(o.onArrayEnd),w=r(o.onLiteralValue),k=m(o.onSeparator),j=l(o.onComment),U=m(o.onError),F=i&&i.disallowComments,u=i&&i.allowTrailingComma;function g(){for(;;){const a=n.scan();switch(n.getTokenError()){case 4:f(14);break;case 5:f(15);break;case 3:f(13);break;case 1:F||f(11);break;case 2:f(12);break;case 6:f(16);break}switch(a){case 12:case 13:F?f(10):j();break;case 16:f(1);break;case 15:case 14:break;default:return a}}}function f(a,A=[],Y=[]){if(U(a),A.length+Y.length>0){let y=n.getToken();for(;y!==17;){if(A.indexOf(y)!==-1){g();break}else if(Y.indexOf(y)!==-1)break;y=g();}}}function $(a){const A=n.getTokenValue();return a?w(A):(v(A),t.push(A)),g(),!0}function O(){switch(n.getToken()){case 11:const a=n.getTokenValue();let A=Number(a);isNaN(A)&&(f(2),A=0),w(A);break;case 7:w(null);break;case 8:w(!0);break;case 9:w(!1);break;default:return !1}return g(),!0}function ce(){return n.getToken()!==10?(f(3,[],[2,5]),!1):($(!1),n.getToken()===6?(k(":"),g(),V()||f(4,[],[2,5])):f(5,[],[2,5]),t.pop(),!0)}function fe(){b(),g();let a=!1;for(;n.getToken()!==2&&n.getToken()!==17;){if(n.getToken()===5){if(a||f(4,[],[]),k(","),g(),n.getToken()===2&&u)break}else a&&f(6,[],[]);ce()||f(4,[],[2,5]),a=!0;}return c(),n.getToken()!==2?f(7,[2],[]):g(),!0}function pe(){L(),g();let a=!0,A=!1;for(;n.getToken()!==4&&n.getToken()!==17;){if(n.getToken()===5){if(A||f(4,[],[]),k(","),g(),n.getToken()===4&&u)break}else A&&f(6,[],[]);a?(t.push(0),a=!1):t[t.length-1]++,V()||f(4,[],[4,5]),A=!0;}return T(),a||t.pop(),n.getToken()!==4?f(8,[4],[]):g(),!0}function V(){switch(n.getToken()){case 3:return pe();case 1:return fe();case 10:return $(!0);default:return O()}}return g(),n.getToken()===17?i.allowEmptyContent?!0:(f(4,[],[]),!1):V()?(n.getToken()!==17&&f(9,[],[]),!0):(f(4,[],[]),!1)}var K;(function(e){e[e.None=0]="None",e[e.UnexpectedEndOfComment=1]="UnexpectedEndOfComment",e[e.UnexpectedEndOfString=2]="UnexpectedEndOfString",e[e.UnexpectedEndOfNumber=3]="UnexpectedEndOfNumber",e[e.InvalidUnicode=4]="InvalidUnicode",e[e.InvalidEscapeCharacter=5]="InvalidEscapeCharacter",e[e.InvalidCharacter=6]="InvalidCharacter";})(K||(K={}));var C;(function(e){e[e.OpenBraceToken=1]="OpenBraceToken",e[e.CloseBraceToken=2]="CloseBraceToken",e[e.OpenBracketToken=3]="OpenBracketToken",e[e.CloseBracketToken=4]="CloseBracketToken",e[e.CommaToken=5]="CommaToken",e[e.ColonToken=6]="ColonToken",e[e.NullKeyword=7]="NullKeyword",e[e.TrueKeyword=8]="TrueKeyword",e[e.FalseKeyword=9]="FalseKeyword",e[e.StringLiteral=10]="StringLiteral",e[e.NumericLiteral=11]="NumericLiteral",e[e.LineCommentTrivia=12]="LineCommentTrivia",e[e.BlockCommentTrivia=13]="BlockCommentTrivia",e[e.LineBreakTrivia=14]="LineBreakTrivia",e[e.Trivia=15]="Trivia",e[e.Unknown=16]="Unknown",e[e.EOF=17]="EOF";})(C||(C={}));const ve=Te;var ee;(function(e){e[e.InvalidSymbol=1]="InvalidSymbol",e[e.InvalidNumberFormat=2]="InvalidNumberFormat",e[e.PropertyNameExpected=3]="PropertyNameExpected",e[e.ValueExpected=4]="ValueExpected",e[e.ColonExpected=5]="ColonExpected",e[e.CommaExpected=6]="CommaExpected",e[e.CloseBraceExpected=7]="CloseBraceExpected",e[e.CloseBracketExpected=8]="CloseBracketExpected",e[e.EndOfFileExpected=9]="EndOfFileExpected",e[e.InvalidCommentToken=10]="InvalidCommentToken",e[e.UnexpectedEndOfComment=11]="UnexpectedEndOfComment",e[e.UnexpectedEndOfString=12]="UnexpectedEndOfString",e[e.UnexpectedEndOfNumber=13]="UnexpectedEndOfNumber",e[e.InvalidUnicode=14]="InvalidUnicode",e[e.InvalidEscapeCharacter=15]="InvalidEscapeCharacter",e[e.InvalidCharacter=16]="InvalidCharacter";})(ee||(ee={}));const ne=(e,o)=>ve(ke(o,e,"utf8")),M=Symbol("implicitBaseUrl"),Oe=()=>{const{findPnpApi:e}=ge;return e&&e(process.cwd())},R=(e,o,i,n)=>{const t=`resolveFromPackageJsonPath:${e}:${o}:${i}`;if(n!=null&&n.has(t))return n.get(t);const l=ne(e,n);if(!l)return;let s=o||"tsconfig.json";if(!i&&l.exports)try{const[m]=v(l.exports,o,["require","types"]);s=m;}catch{return !1}else !o&&l.tsconfig&&(s=l.tsconfig);return s=p$1.join(e,"..",s),n==null||n.set(t,s),s},G="package.json",z="tsconfig.json",Ae=(e,o,i)=>{let n=e;if(e===".."&&(n=p$1.join(n,z)),e[0]==="."&&(n=p$1.resolve(o,n)),p$1.isAbsolute(n)){if(E(i,n)){if(P(i,n).isFile())return n}else if(!n.endsWith(".json")){const T=`${n}.json`;if(E(i,T))return T}return}const[t,...l]=e.split("/"),s=t[0]==="@"?`${t}/${l.shift()}`:t,m=l.join("/"),r=Oe();if(r){const{resolveRequest:T}=r;try{if(s===e){const w=T(p$1.join(s,G),o);if(w){const k=R(w,m,!1,i);if(k&&E(i,k))return k}}else {let w;try{w=T(e,o,{extensions:[".json"]});}catch{w=T(p$1.join(e,z),o);}if(w)return w}}catch{}}const b=Z(o,p$1.join("node_modules",s),i);if(!b||!P(i,b).isDirectory())return;const v=p$1.join(b,G);if(E(i,v)){const T=R(v,m,!1,i);if(T===!1)return;if(T&&E(i,T)&&P(i,T).isFile())return T}const c=p$1.join(b,m),L=c.endsWith(".json");if(!L){const T=`${c}.json`;if(E(i,T))return T}if(E(i,c)){if(P(i,c).isDirectory()){const T=p$1.join(c,G);if(E(i,T)){const k=R(T,"",!0,i);if(k&&E(i,k))return k}const w=p$1.join(c,z);if(E(i,w))return w}else if(L)return c}},je=(e,o,i,n)=>{const t=Ae(e,o,n);if(!t)throw new Error(`File '${e}' not found.`);if(i.has(t))throw new Error(`Circularity detected while resolving configuration: ${t}`);i.add(t);const l=p$1.dirname(t),s=te(t,n,i);delete s.references;const{compilerOptions:m}=s;if(m){const r=["baseUrl","outDir"];for(const b of r){const v=m[b];v&&(m[b]=B(p$1.relative(o,p$1.join(l,v)))||"./");}}return s.files&&(s.files=s.files.map(r=>B(p$1.relative(o,p$1.join(l,r))))),s.include&&(s.include=s.include.map(r=>B(p$1.relative(o,p$1.join(l,r))))),s.exclude&&(s.exclude=s.exclude.map(r=>B(p$1.relative(o,p$1.join(l,r))))),s},te=(e,o,i=new Set)=>{let n;try{n=ae(o,e);}catch{throw new Error(`Cannot resolve tsconfig at path: ${e}`)}let t=ne(n,o)||{};if(typeof t!="object")throw new SyntaxError(`Failed to parse tsconfig at: ${e}`);const l=p$1.dirname(n);if(t.compilerOptions){const{compilerOptions:s}=t;s.paths&&!s.baseUrl&&(s[M]=l);}if(t.extends){const s=Array.isArray(t.extends)?t.extends:[t.extends];delete t.extends;for(const m of s.reverse()){const r=je(m,l,new Set(i),o),b={...r,...t,compilerOptions:{...r.compilerOptions,...t.compilerOptions}};r.watchOptions&&(b.watchOptions={...r.watchOptions,...t.watchOptions}),t=b;}}if(t.compilerOptions){const{compilerOptions:s}=t,m=["baseUrl","rootDir"];for(const b of m){const v=s[b];if(v){const c=p$1.resolve(l,v),L=W(p$1.relative(l,c));s[b]=L;}}const{outDir:r}=s;r&&(Array.isArray(t.exclude)||(t.exclude=[]),t.exclude.includes(r)||t.exclude.push(r),s.outDir=W(r));}else t.compilerOptions={};if(t.files&&(t.files=t.files.map(W)),t.include&&(t.include=t.include.map(B)),t.watchOptions){const{watchOptions:s}=t;s.excludeDirectories&&(s.excludeDirectories=s.excludeDirectories.map(m=>B(p$1.resolve(l,m))));}return t},ie=(e,o=new Map)=>te(e,o),$e=(e=process.cwd(),o="tsconfig.json",i=new Map)=>{const n=Z(B(e),o,i);if(!n)return null;const t=ie(n,i);return {path:n,config:t}};p$1.posix;process.platform==="win32";
|
|
58
|
+
function B(e){return e.startsWith("\\\\?\\")?e:e.replace(/\\/g,"/")}const W=e=>{const t=require$$0[e];return (i,...n)=>{const l=`${e}:${n.join(":")}`;let s=i==null?void 0:i.get(l);return s===void 0&&(s=Reflect.apply(t,require$$0,n),i==null||i.set(l,s)),s}},_=W("existsSync"),ke=W("readFileSync"),I=W("statSync"),q=(e,t,i)=>{for(;;){const n=p$1.posix.join(e,t);if(_(i,n))return n;const l=p$1.dirname(e);if(l===e)return;e=l;}},h=/^\.{1,2}(\/.*)?$/,J=e=>{const t=B(e);return h.test(t)?t:`./${t}`};function be(e,t=!1){const i=e.length;let n=0,l="",s=0,o=16,m=0,u=0,w=0,v=0,f=0;function E(r,g){let c=0,$=0;for(;c<r||!g;){let A=e.charCodeAt(n);if(A>=48&&A<=57)$=$*16+A-48;else if(A>=65&&A<=70)$=$*16+A-65+10;else if(A>=97&&A<=102)$=$*16+A-97+10;else break;n++,c++;}return c<r&&($=-1),$}function b(r){n=r,l="",s=0,o=16,f=0;}function T(){let r=n;if(e.charCodeAt(n)===48)n++;else for(n++;n<e.length&&y(e.charCodeAt(n));)n++;if(n<e.length&&e.charCodeAt(n)===46)if(n++,n<e.length&&y(e.charCodeAt(n)))for(n++;n<e.length&&y(e.charCodeAt(n));)n++;else return f=3,e.substring(r,n);let g=n;if(n<e.length&&(e.charCodeAt(n)===69||e.charCodeAt(n)===101))if(n++,(n<e.length&&e.charCodeAt(n)===43||e.charCodeAt(n)===45)&&n++,n<e.length&&y(e.charCodeAt(n))){for(n++;n<e.length&&y(e.charCodeAt(n));)n++;g=n;}else f=3;return e.substring(r,g)}function k(){let r="",g=n;for(;;){if(n>=i){r+=e.substring(g,n),f=2;break}const c=e.charCodeAt(n);if(c===34){r+=e.substring(g,n),n++;break}if(c===92){if(r+=e.substring(g,n),n++,n>=i){f=2;break}switch(e.charCodeAt(n++)){case 34:r+='"';break;case 92:r+="\\";break;case 47:r+="/";break;case 98:r+="\b";break;case 102:r+="\f";break;case 110:r+=`
|
|
59
|
+
`;break;case 114:r+="\r";break;case 116:r+=" ";break;case 117:const A=E(4,!0);A>=0?r+=String.fromCharCode(A):f=4;break;default:f=5;}g=n;continue}if(c>=0&&c<=31)if(N(c)){r+=e.substring(g,n),f=2;break}else f=6;n++;}return r}function j(){if(l="",f=0,s=n,u=m,v=w,n>=i)return s=i,o=17;let r=e.charCodeAt(n);if(M(r)){do n++,l+=String.fromCharCode(r),r=e.charCodeAt(n);while(M(r));return o=15}if(N(r))return n++,l+=String.fromCharCode(r),r===13&&e.charCodeAt(n)===10&&(n++,l+=`
|
|
60
|
+
`),m++,w=n,o=14;switch(r){case 123:return n++,o=1;case 125:return n++,o=2;case 91:return n++,o=3;case 93:return n++,o=4;case 58:return n++,o=6;case 44:return n++,o=5;case 34:return n++,l=k(),o=10;case 47:const g=n-1;if(e.charCodeAt(n+1)===47){for(n+=2;n<i&&!N(e.charCodeAt(n));)n++;return l=e.substring(g,n),o=12}if(e.charCodeAt(n+1)===42){n+=2;const c=i-1;let $=!1;for(;n<c;){const A=e.charCodeAt(n);if(A===42&&e.charCodeAt(n+1)===47){n+=2,$=!0;break}n++,N(A)&&(A===13&&e.charCodeAt(n)===10&&n++,m++,w=n);}return $||(n++,f=1),l=e.substring(g,n),o=13}return l+=String.fromCharCode(r),n++,o=16;case 45:if(l+=String.fromCharCode(r),n++,n===i||!y(e.charCodeAt(n)))return o=16;case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return l+=T(),o=11;default:for(;n<i&&L(r);)n++,r=e.charCodeAt(n);if(s!==n){switch(l=e.substring(s,n),l){case"true":return o=8;case"false":return o=9;case"null":return o=7}return o=16}return l+=String.fromCharCode(r),n++,o=16}}function L(r){if(M(r)||N(r))return !1;switch(r){case 125:case 93:case 123:case 91:case 34:case 58:case 44:case 47:return !1}return !0}function U(){let r;do r=j();while(r>=12&&r<=15);return r}return {setPosition:b,getPosition:()=>n,scan:t?U:j,getToken:()=>o,getTokenValue:()=>l,getTokenOffset:()=>s,getTokenLength:()=>n-s,getTokenStartLine:()=>u,getTokenStartCharacter:()=>s-v,getTokenError:()=>f}}function M(e){return e===32||e===9}function N(e){return e===10||e===13}function y(e){return e>=48&&e<=57}var K;((function(e){e[e.lineFeed=10]="lineFeed",e[e.carriageReturn=13]="carriageReturn",e[e.space=32]="space",e[e._0=48]="_0",e[e._1=49]="_1",e[e._2=50]="_2",e[e._3=51]="_3",e[e._4=52]="_4",e[e._5=53]="_5",e[e._6=54]="_6",e[e._7=55]="_7",e[e._8=56]="_8",e[e._9=57]="_9",e[e.a=97]="a",e[e.b=98]="b",e[e.c=99]="c",e[e.d=100]="d",e[e.e=101]="e",e[e.f=102]="f",e[e.g=103]="g",e[e.h=104]="h",e[e.i=105]="i",e[e.j=106]="j",e[e.k=107]="k",e[e.l=108]="l",e[e.m=109]="m",e[e.n=110]="n",e[e.o=111]="o",e[e.p=112]="p",e[e.q=113]="q",e[e.r=114]="r",e[e.s=115]="s",e[e.t=116]="t",e[e.u=117]="u",e[e.v=118]="v",e[e.w=119]="w",e[e.x=120]="x",e[e.y=121]="y",e[e.z=122]="z",e[e.A=65]="A",e[e.B=66]="B",e[e.C=67]="C",e[e.D=68]="D",e[e.E=69]="E",e[e.F=70]="F",e[e.G=71]="G",e[e.H=72]="H",e[e.I=73]="I",e[e.J=74]="J",e[e.K=75]="K",e[e.L=76]="L",e[e.M=77]="M",e[e.N=78]="N",e[e.O=79]="O",e[e.P=80]="P",e[e.Q=81]="Q",e[e.R=82]="R",e[e.S=83]="S",e[e.T=84]="T",e[e.U=85]="U",e[e.V=86]="V",e[e.W=87]="W",e[e.X=88]="X",e[e.Y=89]="Y",e[e.Z=90]="Z",e[e.asterisk=42]="asterisk",e[e.backslash=92]="backslash",e[e.closeBrace=125]="closeBrace",e[e.closeBracket=93]="closeBracket",e[e.colon=58]="colon",e[e.comma=44]="comma",e[e.dot=46]="dot",e[e.doubleQuote=34]="doubleQuote",e[e.minus=45]="minus",e[e.openBrace=123]="openBrace",e[e.openBracket=91]="openBracket",e[e.plus=43]="plus",e[e.slash=47]="slash",e[e.formFeed=12]="formFeed",e[e.tab=9]="tab";}))(K||(K={})),new Array(20).fill(0).map((e,t)=>" ".repeat(t));const F=200;new Array(F).fill(0).map((e,t)=>`
|
|
61
|
+
`+" ".repeat(t)),new Array(F).fill(0).map((e,t)=>"\r"+" ".repeat(t)),new Array(F).fill(0).map((e,t)=>`\r
|
|
62
|
+
`+" ".repeat(t)),new Array(F).fill(0).map((e,t)=>`
|
|
63
|
+
`+" ".repeat(t)),new Array(F).fill(0).map((e,t)=>"\r"+" ".repeat(t)),new Array(F).fill(0).map((e,t)=>`\r
|
|
64
|
+
`+" ".repeat(t));var P;(function(e){e.DEFAULT={allowTrailingComma:!1};})(P||(P={}));function we(e,t=[],i=P.DEFAULT){let n=null,l=[];const s=[];function o(u){Array.isArray(l)?l.push(u):n!==null&&(l[n]=u);}return Te(e,{onObjectBegin:()=>{const u={};o(u),s.push(l),l=u,n=null;},onObjectProperty:u=>{n=u;},onObjectEnd:()=>{l=s.pop();},onArrayBegin:()=>{const u=[];o(u),s.push(l),l=u,n=null;},onArrayEnd:()=>{l=s.pop();},onLiteralValue:o,onError:(u,w,v)=>{t.push({error:u,offset:w,length:v});}},i),l[0]}function Te(e,t,i=P.DEFAULT){const n=be(e,!1),l=[];function s(a){return a?()=>a(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter()):()=>!0}function o(a){return a?()=>a(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter(),()=>l.slice()):()=>!0}function m(a){return a?O=>a(O,n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter()):()=>!0}function u(a){return a?O=>a(O,n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter(),()=>l.slice()):()=>!0}const w=o(t.onObjectBegin),v=u(t.onObjectProperty),f=s(t.onObjectEnd),E=o(t.onArrayBegin),b=s(t.onArrayEnd),T=u(t.onLiteralValue),k=m(t.onSeparator),j=s(t.onComment),L=m(t.onError),U=i&&i.disallowComments,r=i&&i.allowTrailingComma;function g(){for(;;){const a=n.scan();switch(n.getTokenError()){case 4:c(14);break;case 5:c(15);break;case 3:c(13);break;case 1:U||c(11);break;case 2:c(12);break;case 6:c(16);break}switch(a){case 12:case 13:U?c(10):j();break;case 16:c(1);break;case 15:case 14:break;default:return a}}}function c(a,O=[],Z=[]){if(L(a),O.length+Z.length>0){let x=n.getToken();for(;x!==17;){if(O.indexOf(x)!==-1){g();break}else if(Z.indexOf(x)!==-1)break;x=g();}}}function $(a){const O=n.getTokenValue();return a?T(O):(v(O),l.push(O)),g(),!0}function A(){switch(n.getToken()){case 11:const a=n.getTokenValue();let O=Number(a);isNaN(O)&&(c(2),O=0),T(O);break;case 7:T(null);break;case 8:T(!0);break;case 9:T(!1);break;default:return !1}return g(),!0}function ce(){return n.getToken()!==10?(c(3,[],[2,5]),!1):($(!1),n.getToken()===6?(k(":"),g(),S()||c(4,[],[2,5])):c(5,[],[2,5]),l.pop(),!0)}function pe(){w(),g();let a=!1;for(;n.getToken()!==2&&n.getToken()!==17;){if(n.getToken()===5){if(a||c(4,[],[]),k(","),g(),n.getToken()===2&&r)break}else a&&c(6,[],[]);ce()||c(4,[],[2,5]),a=!0;}return f(),n.getToken()!==2?c(7,[2],[]):g(),!0}function me(){E(),g();let a=!0,O=!1;for(;n.getToken()!==4&&n.getToken()!==17;){if(n.getToken()===5){if(O||c(4,[],[]),k(","),g(),n.getToken()===4&&r)break}else O&&c(6,[],[]);a?(l.push(0),a=!1):l[l.length-1]++,S()||c(4,[],[4,5]),O=!0;}return b(),a||l.pop(),n.getToken()!==4?c(8,[4],[]):g(),!0}function S(){switch(n.getToken()){case 3:return me();case 1:return pe();case 10:return $(!0);default:return A()}}return g(),n.getToken()===17?i.allowEmptyContent?!0:(c(4,[],[]),!1):S()?(n.getToken()!==17&&c(9,[],[]),!0):(c(4,[],[]),!1)}var C;(function(e){e[e.None=0]="None",e[e.UnexpectedEndOfComment=1]="UnexpectedEndOfComment",e[e.UnexpectedEndOfString=2]="UnexpectedEndOfString",e[e.UnexpectedEndOfNumber=3]="UnexpectedEndOfNumber",e[e.InvalidUnicode=4]="InvalidUnicode",e[e.InvalidEscapeCharacter=5]="InvalidEscapeCharacter",e[e.InvalidCharacter=6]="InvalidCharacter";})(C||(C={}));var ee;(function(e){e[e.OpenBraceToken=1]="OpenBraceToken",e[e.CloseBraceToken=2]="CloseBraceToken",e[e.OpenBracketToken=3]="OpenBracketToken",e[e.CloseBracketToken=4]="CloseBracketToken",e[e.CommaToken=5]="CommaToken",e[e.ColonToken=6]="ColonToken",e[e.NullKeyword=7]="NullKeyword",e[e.TrueKeyword=8]="TrueKeyword",e[e.FalseKeyword=9]="FalseKeyword",e[e.StringLiteral=10]="StringLiteral",e[e.NumericLiteral=11]="NumericLiteral",e[e.LineCommentTrivia=12]="LineCommentTrivia",e[e.BlockCommentTrivia=13]="BlockCommentTrivia",e[e.LineBreakTrivia=14]="LineBreakTrivia",e[e.Trivia=15]="Trivia",e[e.Unknown=16]="Unknown",e[e.EOF=17]="EOF";})(ee||(ee={}));const ve=we;var ne;(function(e){e[e.InvalidSymbol=1]="InvalidSymbol",e[e.InvalidNumberFormat=2]="InvalidNumberFormat",e[e.PropertyNameExpected=3]="PropertyNameExpected",e[e.ValueExpected=4]="ValueExpected",e[e.ColonExpected=5]="ColonExpected",e[e.CommaExpected=6]="CommaExpected",e[e.CloseBraceExpected=7]="CloseBraceExpected",e[e.CloseBracketExpected=8]="CloseBracketExpected",e[e.EndOfFileExpected=9]="EndOfFileExpected",e[e.InvalidCommentToken=10]="InvalidCommentToken",e[e.UnexpectedEndOfComment=11]="UnexpectedEndOfComment",e[e.UnexpectedEndOfString=12]="UnexpectedEndOfString",e[e.UnexpectedEndOfNumber=13]="UnexpectedEndOfNumber",e[e.InvalidUnicode=14]="InvalidUnicode",e[e.InvalidEscapeCharacter=15]="InvalidEscapeCharacter",e[e.InvalidCharacter=16]="InvalidCharacter";})(ne||(ne={}));const te=(e,t)=>ve(ke(t,e,"utf8")),R=Symbol("implicitBaseUrl"),Ae=()=>{const{findPnpApi:e}=ge;return e&&e(process.cwd())},G=(e,t,i,n)=>{const l=`resolveFromPackageJsonPath:${e}:${t}:${i}`;if(n!=null&&n.has(l))return n.get(l);const s=te(e,n);if(!s)return;let o=t||"tsconfig.json";if(!i&&s.exports)try{const[m]=v(s.exports,t,["require","types"]);o=m;}catch{return !1}else !t&&s.tsconfig&&(o=s.tsconfig);return o=p$1.join(e,"..",o),n==null||n.set(l,o),o},z="package.json",Q="tsconfig.json",Oe=(e,t,i)=>{let n=e;if(e===".."&&(n=p$1.join(n,Q)),e[0]==="."&&(n=p$1.resolve(t,n)),p$1.isAbsolute(n)){if(_(i,n)){if(I(i,n).isFile())return n}else if(!n.endsWith(".json")){const b=`${n}.json`;if(_(i,b))return b}return}const[l,...s]=e.split("/"),o=l[0]==="@"?`${l}/${s.shift()}`:l,m=s.join("/"),u=Ae();if(u){const{resolveRequest:b}=u;try{if(o===e){const T=b(p$1.join(o,z),t);if(T){const k=G(T,m,!1,i);if(k&&_(i,k))return k}}else {let T;try{T=b(e,t,{extensions:[".json"]});}catch{T=b(p$1.join(e,Q),t);}if(T)return T}}catch{}}const w=q(t,p$1.join("node_modules",o),i);if(!w||!I(i,w).isDirectory())return;const v=p$1.join(w,z);if(_(i,v)){const b=G(v,m,!1,i);if(b===!1)return;if(b&&_(i,b)&&I(i,b).isFile())return b}const f=p$1.join(w,m),E=f.endsWith(".json");if(!E){const b=`${f}.json`;if(_(i,b))return b}if(_(i,f)){if(I(i,f).isDirectory()){const b=p$1.join(f,z);if(_(i,b)){const k=G(b,"",!0,i);if(k&&_(i,k))return k}const T=p$1.join(f,Q);if(_(i,T))return T}else if(E)return f}},je=(e,t,i,n)=>{const l=Oe(e,t,n);if(!l)throw new Error(`File '${e}' not found.`);if(i.has(l))throw new Error(`Circularity detected while resolving configuration: ${l}`);i.add(l);const s=p$1.dirname(l),o=ie(l,n,i);delete o.references;const{compilerOptions:m}=o;if(m){const u=["baseUrl","outDir"];for(const w of u){const v=m[w];v&&(m[w]=B(p$1.relative(t,p$1.join(s,v)))||"./");}}return o.files&&(o.files=o.files.map(u=>B(p$1.relative(t,p$1.join(s,u))))),o.include&&(o.include=o.include.map(u=>B(p$1.relative(t,p$1.join(s,u))))),o.exclude&&(o.exclude=o.exclude.map(u=>B(p$1.relative(t,p$1.join(s,u))))),o},ie=(e,t,i=new Set)=>{let n;try{n=te(e,t)||{};}catch{throw new Error(`Cannot resolve tsconfig at path: ${e}`)}if(typeof n!="object")throw new SyntaxError(`Failed to parse tsconfig at: ${e}`);const l=p$1.dirname(e);if(n.compilerOptions){const{compilerOptions:s}=n;s.paths&&!s.baseUrl&&(s[R]=l);}if(n.extends){const s=Array.isArray(n.extends)?n.extends:[n.extends];delete n.extends;for(const o of s.reverse()){const m=je(o,l,new Set(i),t),u={...m,...n,compilerOptions:{...m.compilerOptions,...n.compilerOptions}};m.watchOptions&&(u.watchOptions={...m.watchOptions,...n.watchOptions}),n=u;}}if(n.compilerOptions){const{compilerOptions:s}=n,o=["baseUrl","rootDir"];for(const u of o){const w=s[u];if(w){const v=p$1.resolve(l,w),f=J(p$1.relative(l,v));s[u]=f;}}const{outDir:m}=s;m&&(Array.isArray(n.exclude)||(n.exclude=[]),n.exclude.includes(m)||n.exclude.push(m),s.outDir=J(m));}else n.compilerOptions={};if(n.files&&(n.files=n.files.map(J)),n.include&&(n.include=n.include.map(B)),n.watchOptions){const{watchOptions:s}=n;s.excludeDirectories&&(s.excludeDirectories=s.excludeDirectories.map(o=>B(p$1.resolve(l,o))));}return n},le=(e,t=new Map)=>ie(e,t),$e=(e=process.cwd(),t="tsconfig.json",i=new Map)=>{const n=q(B(e),t,i);if(!n)return null;const l=le(n,i);return {path:n,config:l}};p$1.posix;process.platform==="win32";
|
|
61
65
|
|
|
62
66
|
const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
|
|
63
67
|
const newLineRegExp = /\r?\n/;
|
|
@@ -160,6 +164,317 @@ function createIndexMap(source) {
|
|
|
160
164
|
return map;
|
|
161
165
|
}
|
|
162
166
|
|
|
167
|
+
// AST walker module for ESTree compatible trees
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
// An ancestor walk keeps an array of ancestor nodes (including the
|
|
171
|
+
// current node) and passes them to the callback as third parameter
|
|
172
|
+
// (and also as state parameter when no other state is present).
|
|
173
|
+
function ancestor(node, visitors, baseVisitor, state, override) {
|
|
174
|
+
var ancestors = [];
|
|
175
|
+
if (!baseVisitor) { baseVisitor = base
|
|
176
|
+
; }(function c(node, st, override) {
|
|
177
|
+
var type = override || node.type;
|
|
178
|
+
var isNew = node !== ancestors[ancestors.length - 1];
|
|
179
|
+
if (isNew) { ancestors.push(node); }
|
|
180
|
+
baseVisitor[type](node, st, c);
|
|
181
|
+
if (visitors[type]) { visitors[type](node, st || ancestors, ancestors); }
|
|
182
|
+
if (isNew) { ancestors.pop(); }
|
|
183
|
+
})(node, state, override);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
function makeTest(test) {
|
|
187
|
+
if (typeof test === "string")
|
|
188
|
+
{ return function (type) { return type === test; } }
|
|
189
|
+
else if (!test)
|
|
190
|
+
{ return function () { return true; } }
|
|
191
|
+
else
|
|
192
|
+
{ return test }
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
var Found = function Found(node, state) { this.node = node; this.state = state; };
|
|
196
|
+
|
|
197
|
+
// Find the innermost node of a given type that contains the given
|
|
198
|
+
// position. Interface similar to findNodeAt.
|
|
199
|
+
function findNodeAround(node, pos, test, baseVisitor, state) {
|
|
200
|
+
test = makeTest(test);
|
|
201
|
+
if (!baseVisitor) { baseVisitor = base; }
|
|
202
|
+
try {
|
|
203
|
+
(function c(node, st, override) {
|
|
204
|
+
var type = override || node.type;
|
|
205
|
+
if (node.start > pos || node.end < pos) { return }
|
|
206
|
+
baseVisitor[type](node, st, c);
|
|
207
|
+
if (test(type, node)) { throw new Found(node, st) }
|
|
208
|
+
})(node, state);
|
|
209
|
+
} catch (e) {
|
|
210
|
+
if (e instanceof Found) { return e }
|
|
211
|
+
throw e
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
function skipThrough(node, st, c) { c(node, st); }
|
|
216
|
+
function ignore(_node, _st, _c) {}
|
|
217
|
+
|
|
218
|
+
// Node walkers.
|
|
219
|
+
|
|
220
|
+
var base = {};
|
|
221
|
+
|
|
222
|
+
base.Program = base.BlockStatement = base.StaticBlock = function (node, st, c) {
|
|
223
|
+
for (var i = 0, list = node.body; i < list.length; i += 1)
|
|
224
|
+
{
|
|
225
|
+
var stmt = list[i];
|
|
226
|
+
|
|
227
|
+
c(stmt, st, "Statement");
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
base.Statement = skipThrough;
|
|
231
|
+
base.EmptyStatement = ignore;
|
|
232
|
+
base.ExpressionStatement = base.ParenthesizedExpression = base.ChainExpression =
|
|
233
|
+
function (node, st, c) { return c(node.expression, st, "Expression"); };
|
|
234
|
+
base.IfStatement = function (node, st, c) {
|
|
235
|
+
c(node.test, st, "Expression");
|
|
236
|
+
c(node.consequent, st, "Statement");
|
|
237
|
+
if (node.alternate) { c(node.alternate, st, "Statement"); }
|
|
238
|
+
};
|
|
239
|
+
base.LabeledStatement = function (node, st, c) { return c(node.body, st, "Statement"); };
|
|
240
|
+
base.BreakStatement = base.ContinueStatement = ignore;
|
|
241
|
+
base.WithStatement = function (node, st, c) {
|
|
242
|
+
c(node.object, st, "Expression");
|
|
243
|
+
c(node.body, st, "Statement");
|
|
244
|
+
};
|
|
245
|
+
base.SwitchStatement = function (node, st, c) {
|
|
246
|
+
c(node.discriminant, st, "Expression");
|
|
247
|
+
for (var i$1 = 0, list$1 = node.cases; i$1 < list$1.length; i$1 += 1) {
|
|
248
|
+
var cs = list$1[i$1];
|
|
249
|
+
|
|
250
|
+
if (cs.test) { c(cs.test, st, "Expression"); }
|
|
251
|
+
for (var i = 0, list = cs.consequent; i < list.length; i += 1)
|
|
252
|
+
{
|
|
253
|
+
var cons = list[i];
|
|
254
|
+
|
|
255
|
+
c(cons, st, "Statement");
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
};
|
|
259
|
+
base.SwitchCase = function (node, st, c) {
|
|
260
|
+
if (node.test) { c(node.test, st, "Expression"); }
|
|
261
|
+
for (var i = 0, list = node.consequent; i < list.length; i += 1)
|
|
262
|
+
{
|
|
263
|
+
var cons = list[i];
|
|
264
|
+
|
|
265
|
+
c(cons, st, "Statement");
|
|
266
|
+
}
|
|
267
|
+
};
|
|
268
|
+
base.ReturnStatement = base.YieldExpression = base.AwaitExpression = function (node, st, c) {
|
|
269
|
+
if (node.argument) { c(node.argument, st, "Expression"); }
|
|
270
|
+
};
|
|
271
|
+
base.ThrowStatement = base.SpreadElement =
|
|
272
|
+
function (node, st, c) { return c(node.argument, st, "Expression"); };
|
|
273
|
+
base.TryStatement = function (node, st, c) {
|
|
274
|
+
c(node.block, st, "Statement");
|
|
275
|
+
if (node.handler) { c(node.handler, st); }
|
|
276
|
+
if (node.finalizer) { c(node.finalizer, st, "Statement"); }
|
|
277
|
+
};
|
|
278
|
+
base.CatchClause = function (node, st, c) {
|
|
279
|
+
if (node.param) { c(node.param, st, "Pattern"); }
|
|
280
|
+
c(node.body, st, "Statement");
|
|
281
|
+
};
|
|
282
|
+
base.WhileStatement = base.DoWhileStatement = function (node, st, c) {
|
|
283
|
+
c(node.test, st, "Expression");
|
|
284
|
+
c(node.body, st, "Statement");
|
|
285
|
+
};
|
|
286
|
+
base.ForStatement = function (node, st, c) {
|
|
287
|
+
if (node.init) { c(node.init, st, "ForInit"); }
|
|
288
|
+
if (node.test) { c(node.test, st, "Expression"); }
|
|
289
|
+
if (node.update) { c(node.update, st, "Expression"); }
|
|
290
|
+
c(node.body, st, "Statement");
|
|
291
|
+
};
|
|
292
|
+
base.ForInStatement = base.ForOfStatement = function (node, st, c) {
|
|
293
|
+
c(node.left, st, "ForInit");
|
|
294
|
+
c(node.right, st, "Expression");
|
|
295
|
+
c(node.body, st, "Statement");
|
|
296
|
+
};
|
|
297
|
+
base.ForInit = function (node, st, c) {
|
|
298
|
+
if (node.type === "VariableDeclaration") { c(node, st); }
|
|
299
|
+
else { c(node, st, "Expression"); }
|
|
300
|
+
};
|
|
301
|
+
base.DebuggerStatement = ignore;
|
|
302
|
+
|
|
303
|
+
base.FunctionDeclaration = function (node, st, c) { return c(node, st, "Function"); };
|
|
304
|
+
base.VariableDeclaration = function (node, st, c) {
|
|
305
|
+
for (var i = 0, list = node.declarations; i < list.length; i += 1)
|
|
306
|
+
{
|
|
307
|
+
var decl = list[i];
|
|
308
|
+
|
|
309
|
+
c(decl, st);
|
|
310
|
+
}
|
|
311
|
+
};
|
|
312
|
+
base.VariableDeclarator = function (node, st, c) {
|
|
313
|
+
c(node.id, st, "Pattern");
|
|
314
|
+
if (node.init) { c(node.init, st, "Expression"); }
|
|
315
|
+
};
|
|
316
|
+
|
|
317
|
+
base.Function = function (node, st, c) {
|
|
318
|
+
if (node.id) { c(node.id, st, "Pattern"); }
|
|
319
|
+
for (var i = 0, list = node.params; i < list.length; i += 1)
|
|
320
|
+
{
|
|
321
|
+
var param = list[i];
|
|
322
|
+
|
|
323
|
+
c(param, st, "Pattern");
|
|
324
|
+
}
|
|
325
|
+
c(node.body, st, node.expression ? "Expression" : "Statement");
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
base.Pattern = function (node, st, c) {
|
|
329
|
+
if (node.type === "Identifier")
|
|
330
|
+
{ c(node, st, "VariablePattern"); }
|
|
331
|
+
else if (node.type === "MemberExpression")
|
|
332
|
+
{ c(node, st, "MemberPattern"); }
|
|
333
|
+
else
|
|
334
|
+
{ c(node, st); }
|
|
335
|
+
};
|
|
336
|
+
base.VariablePattern = ignore;
|
|
337
|
+
base.MemberPattern = skipThrough;
|
|
338
|
+
base.RestElement = function (node, st, c) { return c(node.argument, st, "Pattern"); };
|
|
339
|
+
base.ArrayPattern = function (node, st, c) {
|
|
340
|
+
for (var i = 0, list = node.elements; i < list.length; i += 1) {
|
|
341
|
+
var elt = list[i];
|
|
342
|
+
|
|
343
|
+
if (elt) { c(elt, st, "Pattern"); }
|
|
344
|
+
}
|
|
345
|
+
};
|
|
346
|
+
base.ObjectPattern = function (node, st, c) {
|
|
347
|
+
for (var i = 0, list = node.properties; i < list.length; i += 1) {
|
|
348
|
+
var prop = list[i];
|
|
349
|
+
|
|
350
|
+
if (prop.type === "Property") {
|
|
351
|
+
if (prop.computed) { c(prop.key, st, "Expression"); }
|
|
352
|
+
c(prop.value, st, "Pattern");
|
|
353
|
+
} else if (prop.type === "RestElement") {
|
|
354
|
+
c(prop.argument, st, "Pattern");
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
};
|
|
358
|
+
|
|
359
|
+
base.Expression = skipThrough;
|
|
360
|
+
base.ThisExpression = base.Super = base.MetaProperty = ignore;
|
|
361
|
+
base.ArrayExpression = function (node, st, c) {
|
|
362
|
+
for (var i = 0, list = node.elements; i < list.length; i += 1) {
|
|
363
|
+
var elt = list[i];
|
|
364
|
+
|
|
365
|
+
if (elt) { c(elt, st, "Expression"); }
|
|
366
|
+
}
|
|
367
|
+
};
|
|
368
|
+
base.ObjectExpression = function (node, st, c) {
|
|
369
|
+
for (var i = 0, list = node.properties; i < list.length; i += 1)
|
|
370
|
+
{
|
|
371
|
+
var prop = list[i];
|
|
372
|
+
|
|
373
|
+
c(prop, st);
|
|
374
|
+
}
|
|
375
|
+
};
|
|
376
|
+
base.FunctionExpression = base.ArrowFunctionExpression = base.FunctionDeclaration;
|
|
377
|
+
base.SequenceExpression = function (node, st, c) {
|
|
378
|
+
for (var i = 0, list = node.expressions; i < list.length; i += 1)
|
|
379
|
+
{
|
|
380
|
+
var expr = list[i];
|
|
381
|
+
|
|
382
|
+
c(expr, st, "Expression");
|
|
383
|
+
}
|
|
384
|
+
};
|
|
385
|
+
base.TemplateLiteral = function (node, st, c) {
|
|
386
|
+
for (var i = 0, list = node.quasis; i < list.length; i += 1)
|
|
387
|
+
{
|
|
388
|
+
var quasi = list[i];
|
|
389
|
+
|
|
390
|
+
c(quasi, st);
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
for (var i$1 = 0, list$1 = node.expressions; i$1 < list$1.length; i$1 += 1)
|
|
394
|
+
{
|
|
395
|
+
var expr = list$1[i$1];
|
|
396
|
+
|
|
397
|
+
c(expr, st, "Expression");
|
|
398
|
+
}
|
|
399
|
+
};
|
|
400
|
+
base.TemplateElement = ignore;
|
|
401
|
+
base.UnaryExpression = base.UpdateExpression = function (node, st, c) {
|
|
402
|
+
c(node.argument, st, "Expression");
|
|
403
|
+
};
|
|
404
|
+
base.BinaryExpression = base.LogicalExpression = function (node, st, c) {
|
|
405
|
+
c(node.left, st, "Expression");
|
|
406
|
+
c(node.right, st, "Expression");
|
|
407
|
+
};
|
|
408
|
+
base.AssignmentExpression = base.AssignmentPattern = function (node, st, c) {
|
|
409
|
+
c(node.left, st, "Pattern");
|
|
410
|
+
c(node.right, st, "Expression");
|
|
411
|
+
};
|
|
412
|
+
base.ConditionalExpression = function (node, st, c) {
|
|
413
|
+
c(node.test, st, "Expression");
|
|
414
|
+
c(node.consequent, st, "Expression");
|
|
415
|
+
c(node.alternate, st, "Expression");
|
|
416
|
+
};
|
|
417
|
+
base.NewExpression = base.CallExpression = function (node, st, c) {
|
|
418
|
+
c(node.callee, st, "Expression");
|
|
419
|
+
if (node.arguments)
|
|
420
|
+
{ for (var i = 0, list = node.arguments; i < list.length; i += 1)
|
|
421
|
+
{
|
|
422
|
+
var arg = list[i];
|
|
423
|
+
|
|
424
|
+
c(arg, st, "Expression");
|
|
425
|
+
} }
|
|
426
|
+
};
|
|
427
|
+
base.MemberExpression = function (node, st, c) {
|
|
428
|
+
c(node.object, st, "Expression");
|
|
429
|
+
if (node.computed) { c(node.property, st, "Expression"); }
|
|
430
|
+
};
|
|
431
|
+
base.ExportNamedDeclaration = base.ExportDefaultDeclaration = function (node, st, c) {
|
|
432
|
+
if (node.declaration)
|
|
433
|
+
{ c(node.declaration, st, node.type === "ExportNamedDeclaration" || node.declaration.id ? "Statement" : "Expression"); }
|
|
434
|
+
if (node.source) { c(node.source, st, "Expression"); }
|
|
435
|
+
};
|
|
436
|
+
base.ExportAllDeclaration = function (node, st, c) {
|
|
437
|
+
if (node.exported)
|
|
438
|
+
{ c(node.exported, st); }
|
|
439
|
+
c(node.source, st, "Expression");
|
|
440
|
+
};
|
|
441
|
+
base.ImportDeclaration = function (node, st, c) {
|
|
442
|
+
for (var i = 0, list = node.specifiers; i < list.length; i += 1)
|
|
443
|
+
{
|
|
444
|
+
var spec = list[i];
|
|
445
|
+
|
|
446
|
+
c(spec, st);
|
|
447
|
+
}
|
|
448
|
+
c(node.source, st, "Expression");
|
|
449
|
+
};
|
|
450
|
+
base.ImportExpression = function (node, st, c) {
|
|
451
|
+
c(node.source, st, "Expression");
|
|
452
|
+
};
|
|
453
|
+
base.ImportSpecifier = base.ImportDefaultSpecifier = base.ImportNamespaceSpecifier = base.Identifier = base.PrivateIdentifier = base.Literal = ignore;
|
|
454
|
+
|
|
455
|
+
base.TaggedTemplateExpression = function (node, st, c) {
|
|
456
|
+
c(node.tag, st, "Expression");
|
|
457
|
+
c(node.quasi, st, "Expression");
|
|
458
|
+
};
|
|
459
|
+
base.ClassDeclaration = base.ClassExpression = function (node, st, c) { return c(node, st, "Class"); };
|
|
460
|
+
base.Class = function (node, st, c) {
|
|
461
|
+
if (node.id) { c(node.id, st, "Pattern"); }
|
|
462
|
+
if (node.superClass) { c(node.superClass, st, "Expression"); }
|
|
463
|
+
c(node.body, st);
|
|
464
|
+
};
|
|
465
|
+
base.ClassBody = function (node, st, c) {
|
|
466
|
+
for (var i = 0, list = node.body; i < list.length; i += 1)
|
|
467
|
+
{
|
|
468
|
+
var elt = list[i];
|
|
469
|
+
|
|
470
|
+
c(elt, st);
|
|
471
|
+
}
|
|
472
|
+
};
|
|
473
|
+
base.MethodDefinition = base.PropertyDefinition = base.Property = function (node, st, c) {
|
|
474
|
+
if (node.computed) { c(node.key, st, "Expression"); }
|
|
475
|
+
if (node.value) { c(node.value, st, "Expression"); }
|
|
476
|
+
};
|
|
477
|
+
|
|
163
478
|
async function collectTests(ctx, filepath) {
|
|
164
479
|
const request = await ctx.vitenode.transformRequest(filepath, filepath);
|
|
165
480
|
if (!request)
|
|
@@ -176,8 +491,10 @@ async function collectTests(ctx, filepath) {
|
|
|
176
491
|
start: ast.start,
|
|
177
492
|
end: ast.end,
|
|
178
493
|
projectName: ctx.getName(),
|
|
179
|
-
meta: { typecheck: true }
|
|
494
|
+
meta: { typecheck: true },
|
|
495
|
+
file: null
|
|
180
496
|
};
|
|
497
|
+
file.file = file;
|
|
181
498
|
const definitions = [];
|
|
182
499
|
const getName = (callee) => {
|
|
183
500
|
var _a, _b, _c;
|
|
@@ -239,7 +556,6 @@ async function collectTests(ctx, filepath) {
|
|
|
239
556
|
name: definition.name,
|
|
240
557
|
end: definition.end,
|
|
241
558
|
start: definition.start,
|
|
242
|
-
projectName: ctx.getName(),
|
|
243
559
|
meta: {
|
|
244
560
|
typecheck: true
|
|
245
561
|
}
|
|
@@ -384,6 +700,8 @@ class Typechecker {
|
|
|
384
700
|
};
|
|
385
701
|
if (task.suite)
|
|
386
702
|
markState(task.suite, state);
|
|
703
|
+
else if (task.file && task !== task.file)
|
|
704
|
+
markState(task.file, state);
|
|
387
705
|
};
|
|
388
706
|
errors.forEach(({ error, originalError }) => {
|
|
389
707
|
var _a;
|
|
@@ -404,8 +722,12 @@ class Typechecker {
|
|
|
404
722
|
errors: errors2
|
|
405
723
|
};
|
|
406
724
|
errors2.push(error);
|
|
407
|
-
if (state === "fail"
|
|
408
|
-
|
|
725
|
+
if (state === "fail") {
|
|
726
|
+
if (suite.suite)
|
|
727
|
+
markState(suite.suite, "fail");
|
|
728
|
+
else if (suite.file && suite !== suite.file)
|
|
729
|
+
markState(suite.file, "fail");
|
|
730
|
+
}
|
|
409
731
|
});
|
|
410
732
|
this.markPassed(file);
|
|
411
733
|
});
|
|
@@ -583,9 +905,9 @@ class BaseReporter {
|
|
|
583
905
|
relative(path) {
|
|
584
906
|
return relativePath(this.ctx.config.root, path);
|
|
585
907
|
}
|
|
586
|
-
|
|
908
|
+
onFinished(files = this.ctx.state.getFiles(), errors = this.ctx.state.getUnhandledErrors()) {
|
|
587
909
|
this.end = performance.now();
|
|
588
|
-
|
|
910
|
+
this.reportSummary(files, errors);
|
|
589
911
|
if (errors.length) {
|
|
590
912
|
if (!this.ctx.config.dangerouslyIgnoreUnhandledErrors)
|
|
591
913
|
process.exitCode = 1;
|
|
@@ -631,7 +953,7 @@ class BaseReporter {
|
|
|
631
953
|
}
|
|
632
954
|
}
|
|
633
955
|
}
|
|
634
|
-
|
|
956
|
+
onWatcherStart(files = this.ctx.state.getFiles(), errors = this.ctx.state.getUnhandledErrors()) {
|
|
635
957
|
this.resetLastRunLog();
|
|
636
958
|
const failed = errors.length > 0 || hasFailed(files);
|
|
637
959
|
const failedSnap = hasFailedSnapshot(files);
|
|
@@ -677,7 +999,7 @@ class BaseReporter {
|
|
|
677
999
|
this._lastRunTimer = void 0;
|
|
678
1000
|
this.ctx.logger.logUpdate.clear();
|
|
679
1001
|
}
|
|
680
|
-
|
|
1002
|
+
onWatcherRerun(files, trigger) {
|
|
681
1003
|
this.resetLastRunLog();
|
|
682
1004
|
this.watchFilters = files;
|
|
683
1005
|
files.forEach((filepath) => {
|
|
@@ -731,14 +1053,14 @@ ${log.content}
|
|
|
731
1053
|
reason === "config" ? "\nRestarting due to config changes..." : "\nRestarting Vitest..."
|
|
732
1054
|
)));
|
|
733
1055
|
}
|
|
734
|
-
|
|
735
|
-
|
|
1056
|
+
reportSummary(files, errors) {
|
|
1057
|
+
this.printErrorsSummary(files, errors);
|
|
736
1058
|
if (this.mode === "benchmark")
|
|
737
|
-
|
|
1059
|
+
this.reportBenchmarkSummary(files);
|
|
738
1060
|
else
|
|
739
|
-
|
|
1061
|
+
this.reportTestSummary(files, errors);
|
|
740
1062
|
}
|
|
741
|
-
|
|
1063
|
+
reportTestSummary(files, errors) {
|
|
742
1064
|
const tests = getTests(files);
|
|
743
1065
|
const logger = this.ctx.logger;
|
|
744
1066
|
const executionTime = this.end - this.start;
|
|
@@ -748,7 +1070,7 @@ ${log.content}
|
|
|
748
1070
|
var _a2;
|
|
749
1071
|
return acc + Math.max(0, ((_a2 = test.result) == null ? void 0 : _a2.duration) || 0);
|
|
750
1072
|
}, 0);
|
|
751
|
-
const transformTime = this.ctx.projects.flatMap((w) =>
|
|
1073
|
+
const transformTime = this.ctx.projects.flatMap((w) => w.vitenode.getTotalDuration()).reduce((a, b) => a + b, 0);
|
|
752
1074
|
const environmentTime = files.reduce((acc, file) => acc + Math.max(0, file.environmentLoad || 0), 0);
|
|
753
1075
|
const prepareTime = files.reduce((acc, file) => acc + Math.max(0, file.prepareDuration || 0), 0);
|
|
754
1076
|
const threadTime = collectTime + testsTime + setupTime;
|
|
@@ -792,7 +1114,7 @@ ${log.content}
|
|
|
792
1114
|
}
|
|
793
1115
|
logger.log();
|
|
794
1116
|
}
|
|
795
|
-
|
|
1117
|
+
printErrorsSummary(files, errors) {
|
|
796
1118
|
const logger = this.ctx.logger;
|
|
797
1119
|
const suites = getSuites(files);
|
|
798
1120
|
const tests = getTests(files);
|
|
@@ -811,20 +1133,20 @@ ${log.content}
|
|
|
811
1133
|
if (failedSuites.length) {
|
|
812
1134
|
logger.error(c.red(divider(c.bold(c.inverse(` Failed Suites ${failedSuites.length} `)))));
|
|
813
1135
|
logger.error();
|
|
814
|
-
|
|
1136
|
+
this.printTaskErrors(failedSuites, errorDivider);
|
|
815
1137
|
}
|
|
816
1138
|
if (failedTests.length) {
|
|
817
1139
|
logger.error(c.red(divider(c.bold(c.inverse(` Failed Tests ${failedTests.length} `)))));
|
|
818
1140
|
logger.error();
|
|
819
|
-
|
|
1141
|
+
this.printTaskErrors(failedTests, errorDivider);
|
|
820
1142
|
}
|
|
821
1143
|
if (errors.length) {
|
|
822
|
-
|
|
1144
|
+
logger.printUnhandledErrors(errors);
|
|
823
1145
|
logger.error();
|
|
824
1146
|
}
|
|
825
1147
|
return tests;
|
|
826
1148
|
}
|
|
827
|
-
|
|
1149
|
+
reportBenchmarkSummary(files) {
|
|
828
1150
|
const logger = this.ctx.logger;
|
|
829
1151
|
const benches = getTests(files);
|
|
830
1152
|
const topBenches = benches.filter((i) => {
|
|
@@ -835,7 +1157,7 @@ ${log.content}
|
|
|
835
1157
|
${c.cyan(c.inverse(c.bold(" BENCH ")))} ${c.cyan("Summary")}
|
|
836
1158
|
`);
|
|
837
1159
|
for (const bench of topBenches) {
|
|
838
|
-
const group = bench.suite;
|
|
1160
|
+
const group = bench.suite || bench.file;
|
|
839
1161
|
if (!group)
|
|
840
1162
|
continue;
|
|
841
1163
|
const groupName = getFullName(group, c.dim(" > "));
|
|
@@ -855,7 +1177,7 @@ ${c.cyan(c.inverse(c.bold(" BENCH ")))} ${c.cyan("Summary")}
|
|
|
855
1177
|
logger.log("");
|
|
856
1178
|
}
|
|
857
1179
|
}
|
|
858
|
-
|
|
1180
|
+
printTaskErrors(tasks, errorDivider) {
|
|
859
1181
|
var _a2, _b, _c;
|
|
860
1182
|
const errorsQueue = [];
|
|
861
1183
|
for (const task of tasks) {
|
|
@@ -885,15 +1207,14 @@ ${c.cyan(c.inverse(c.bold(" BENCH ")))} ${c.cyan("Summary")}
|
|
|
885
1207
|
this.ctx.logger.error(`${c.red(c.bold(c.inverse(" FAIL ")))} ${formatProjectName(projectName)}${name}`);
|
|
886
1208
|
}
|
|
887
1209
|
const project = this.ctx.getProjectByTaskId(tasks2[0].id);
|
|
888
|
-
|
|
1210
|
+
this.ctx.logger.printError(error, { project });
|
|
889
1211
|
errorDivider();
|
|
890
|
-
await Promise.resolve();
|
|
891
1212
|
}
|
|
892
1213
|
}
|
|
893
1214
|
registerUnhandledRejection() {
|
|
894
1215
|
const onUnhandledRejection = async (err) => {
|
|
895
1216
|
process.exitCode = 1;
|
|
896
|
-
|
|
1217
|
+
this.ctx.logger.printError(err, { fullStack: true, type: "Unhandled Rejection" });
|
|
897
1218
|
this.ctx.logger.error("\n\n");
|
|
898
1219
|
process.exit(1);
|
|
899
1220
|
};
|
|
@@ -1871,7 +2192,7 @@ function renderTree$1(tasks, options, level = 0, maxRows) {
|
|
|
1871
2192
|
const taskOutput = [];
|
|
1872
2193
|
let suffix = "";
|
|
1873
2194
|
let prefix = ` ${getStateSymbol(task)} `;
|
|
1874
|
-
if (level === 0 && task.type === "suite" && task
|
|
2195
|
+
if (level === 0 && task.type === "suite" && "projectName" in task)
|
|
1875
2196
|
prefix += formatProjectName(task.projectName);
|
|
1876
2197
|
if (task.type === "test" && ((_a = task.result) == null ? void 0 : _a.retryCount) && task.result.retryCount > 0)
|
|
1877
2198
|
suffix += c.yellow(` (retry x${task.result.retryCount})`);
|
|
@@ -1966,7 +2287,7 @@ function createListRenderer(_tasks, options) {
|
|
|
1966
2287
|
tasks = _tasks2;
|
|
1967
2288
|
return this;
|
|
1968
2289
|
},
|
|
1969
|
-
|
|
2290
|
+
stop() {
|
|
1970
2291
|
if (timer) {
|
|
1971
2292
|
clearInterval(timer);
|
|
1972
2293
|
timer = void 0;
|
|
@@ -1999,13 +2320,13 @@ class DefaultReporter extends BaseReporter {
|
|
|
1999
2320
|
}
|
|
2000
2321
|
}
|
|
2001
2322
|
async onTestRemoved(trigger) {
|
|
2002
|
-
|
|
2323
|
+
this.stopListRender();
|
|
2003
2324
|
this.ctx.logger.clearScreen(c.yellow("Test removed...") + (trigger ? c.dim(` [ ${this.relative(trigger)} ]
|
|
2004
2325
|
`) : ""), true);
|
|
2005
2326
|
const files = this.ctx.state.getFiles(this.watchFilters);
|
|
2006
2327
|
createListRenderer(files, this.rendererOptions).stop();
|
|
2007
2328
|
this.ctx.logger.log();
|
|
2008
|
-
|
|
2329
|
+
super.reportSummary(files, this.ctx.state.getUnhandledErrors());
|
|
2009
2330
|
super.onWatcherStart();
|
|
2010
2331
|
}
|
|
2011
2332
|
onCollected() {
|
|
@@ -2021,22 +2342,22 @@ class DefaultReporter extends BaseReporter {
|
|
|
2021
2342
|
this.renderer.update(files);
|
|
2022
2343
|
}
|
|
2023
2344
|
}
|
|
2024
|
-
|
|
2025
|
-
|
|
2345
|
+
onFinished(files = this.ctx.state.getFiles(), errors = this.ctx.state.getUnhandledErrors()) {
|
|
2346
|
+
this.stopListRender();
|
|
2026
2347
|
this.ctx.logger.log();
|
|
2027
|
-
|
|
2348
|
+
super.onFinished(files, errors);
|
|
2028
2349
|
}
|
|
2029
2350
|
async onWatcherStart(files = this.ctx.state.getFiles(), errors = this.ctx.state.getUnhandledErrors()) {
|
|
2030
|
-
|
|
2351
|
+
this.stopListRender();
|
|
2031
2352
|
await super.onWatcherStart(files, errors);
|
|
2032
2353
|
}
|
|
2033
|
-
|
|
2354
|
+
stopListRender() {
|
|
2034
2355
|
var _a;
|
|
2035
|
-
|
|
2356
|
+
(_a = this.renderer) == null ? void 0 : _a.stop();
|
|
2036
2357
|
this.renderer = void 0;
|
|
2037
2358
|
}
|
|
2038
2359
|
async onWatcherRerun(files, trigger) {
|
|
2039
|
-
|
|
2360
|
+
this.stopListRender();
|
|
2040
2361
|
await super.onWatcherRerun(files, trigger);
|
|
2041
2362
|
}
|
|
2042
2363
|
onUserConsoleLog(log) {
|
|
@@ -2155,7 +2476,7 @@ class DotReporter extends BaseReporter {
|
|
|
2155
2476
|
async onFinished(files = this.ctx.state.getFiles(), errors = this.ctx.state.getUnhandledErrors()) {
|
|
2156
2477
|
await this.stopListRender();
|
|
2157
2478
|
this.ctx.logger.log();
|
|
2158
|
-
|
|
2479
|
+
super.onFinished(files, errors);
|
|
2159
2480
|
}
|
|
2160
2481
|
async onWatcherStart() {
|
|
2161
2482
|
await this.stopListRender();
|
|
@@ -2169,7 +2490,7 @@ class DotReporter extends BaseReporter {
|
|
|
2169
2490
|
}
|
|
2170
2491
|
async onWatcherRerun(files, trigger) {
|
|
2171
2492
|
await this.stopListRender();
|
|
2172
|
-
|
|
2493
|
+
super.onWatcherRerun(files, trigger);
|
|
2173
2494
|
}
|
|
2174
2495
|
onUserConsoleLog(log) {
|
|
2175
2496
|
var _a;
|
|
@@ -2186,7 +2507,7 @@ const StatusMap = {
|
|
|
2186
2507
|
skip: "skipped",
|
|
2187
2508
|
todo: "todo"
|
|
2188
2509
|
};
|
|
2189
|
-
|
|
2510
|
+
class JsonReporter {
|
|
2190
2511
|
start = 0;
|
|
2191
2512
|
ctx;
|
|
2192
2513
|
options;
|
|
@@ -2236,7 +2557,7 @@ let JsonReporter$1 = class JsonReporter {
|
|
|
2236
2557
|
var _a2, _b2;
|
|
2237
2558
|
return Math.max(prev, (((_a2 = next.result) == null ? void 0 : _a2.startTime) ?? 0) + (((_b2 = next.result) == null ? void 0 : _b2.duration) ?? 0));
|
|
2238
2559
|
}, startTime);
|
|
2239
|
-
const assertionResults =
|
|
2560
|
+
const assertionResults = tests2.map((t) => {
|
|
2240
2561
|
var _a2, _b2, _c2, _d2;
|
|
2241
2562
|
const ancestorTitles = [];
|
|
2242
2563
|
let iter = t.suite;
|
|
@@ -2247,14 +2568,14 @@ let JsonReporter$1 = class JsonReporter {
|
|
|
2247
2568
|
ancestorTitles.reverse();
|
|
2248
2569
|
return {
|
|
2249
2570
|
ancestorTitles,
|
|
2250
|
-
fullName:
|
|
2571
|
+
fullName: t.name ? [...ancestorTitles, t.name].join(" ") : ancestorTitles.join(" "),
|
|
2251
2572
|
status: StatusMap[((_a2 = t.result) == null ? void 0 : _a2.state) || t.mode] || "skipped",
|
|
2252
2573
|
title: t.name,
|
|
2253
2574
|
duration: (_b2 = t.result) == null ? void 0 : _b2.duration,
|
|
2254
|
-
failureMessages: ((_d2 = (_c2 = t.result) == null ? void 0 : _c2.errors) == null ? void 0 : _d2.map((e) => e.message)) || [],
|
|
2255
|
-
location:
|
|
2575
|
+
failureMessages: ((_d2 = (_c2 = t.result) == null ? void 0 : _c2.errors) == null ? void 0 : _d2.map((e) => e.stack || e.message)) || [],
|
|
2576
|
+
location: t.location
|
|
2256
2577
|
};
|
|
2257
|
-
})
|
|
2578
|
+
});
|
|
2258
2579
|
if (tests2.some((t) => {
|
|
2259
2580
|
var _a2;
|
|
2260
2581
|
return ((_a2 = t.result) == null ? void 0 : _a2.state) === "run";
|
|
@@ -2284,6 +2605,7 @@ let JsonReporter$1 = class JsonReporter {
|
|
|
2284
2605
|
numFailedTests,
|
|
2285
2606
|
numPendingTests,
|
|
2286
2607
|
numTodoTests,
|
|
2608
|
+
snapshot: this.ctx.snapshot.summary,
|
|
2287
2609
|
startTime: this.start,
|
|
2288
2610
|
success,
|
|
2289
2611
|
testResults
|
|
@@ -2311,22 +2633,7 @@ let JsonReporter$1 = class JsonReporter {
|
|
|
2311
2633
|
this.ctx.logger.log(report);
|
|
2312
2634
|
}
|
|
2313
2635
|
}
|
|
2314
|
-
|
|
2315
|
-
var _a, _b;
|
|
2316
|
-
const error = (_b = (_a = test.result) == null ? void 0 : _a.errors) == null ? void 0 : _b[0];
|
|
2317
|
-
if (!error)
|
|
2318
|
-
return;
|
|
2319
|
-
const project = this.ctx.getProjectByTaskId(test.id);
|
|
2320
|
-
const stack = parseErrorStacktrace(error, {
|
|
2321
|
-
getSourceMap: (file) => project.getBrowserSourceMapModuleById(file),
|
|
2322
|
-
frameFilter: this.ctx.config.onStackTrace
|
|
2323
|
-
});
|
|
2324
|
-
const frame = stack[0];
|
|
2325
|
-
if (!frame)
|
|
2326
|
-
return;
|
|
2327
|
-
return { line: frame.line, column: frame.column };
|
|
2328
|
-
}
|
|
2329
|
-
};
|
|
2636
|
+
}
|
|
2330
2637
|
|
|
2331
2638
|
class VerboseReporter extends DefaultReporter {
|
|
2332
2639
|
constructor() {
|
|
@@ -2334,15 +2641,15 @@ class VerboseReporter extends DefaultReporter {
|
|
|
2334
2641
|
this.rendererOptions.renderSucceed = true;
|
|
2335
2642
|
}
|
|
2336
2643
|
onTaskUpdate(packs) {
|
|
2337
|
-
var _a, _b, _c
|
|
2644
|
+
var _a, _b, _c;
|
|
2338
2645
|
if (this.isTTY)
|
|
2339
2646
|
return;
|
|
2340
2647
|
for (const pack of packs) {
|
|
2341
2648
|
const task = this.ctx.state.idMap.get(pack[0]);
|
|
2342
2649
|
if (task && task.type === "test" && ((_a = task.result) == null ? void 0 : _a.state) && ((_b = task.result) == null ? void 0 : _b.state) !== "run") {
|
|
2343
2650
|
let title = ` ${getStateSymbol(task)} `;
|
|
2344
|
-
if (
|
|
2345
|
-
title += formatProjectName(task.
|
|
2651
|
+
if (task.file.projectName)
|
|
2652
|
+
title += formatProjectName(task.file.projectName);
|
|
2346
2653
|
title += getFullName(task, c.dim(" > "));
|
|
2347
2654
|
if (task.result.duration != null && task.result.duration > this.ctx.config.slowTestThreshold)
|
|
2348
2655
|
title += c.yellow(` ${Math.round(task.result.duration)}${c.dim("ms")}`);
|
|
@@ -2350,7 +2657,7 @@ class VerboseReporter extends DefaultReporter {
|
|
|
2350
2657
|
title += c.magenta(` ${Math.floor(task.result.heap / 1024 / 1024)} MB heap used`);
|
|
2351
2658
|
this.ctx.logger.log(title);
|
|
2352
2659
|
if (task.result.state === "fail") {
|
|
2353
|
-
(
|
|
2660
|
+
(_c = task.result.errors) == null ? void 0 : _c.forEach((error) => {
|
|
2354
2661
|
this.ctx.logger.log(c.red(` ${F_RIGHT} ${error == null ? void 0 : error.message}`));
|
|
2355
2662
|
});
|
|
2356
2663
|
}
|
|
@@ -2449,7 +2756,7 @@ class TapReporter {
|
|
|
2449
2756
|
}
|
|
2450
2757
|
}
|
|
2451
2758
|
}
|
|
2452
|
-
|
|
2759
|
+
onFinished(files = this.ctx.state.getFiles()) {
|
|
2453
2760
|
this.logger.log("TAP version 13");
|
|
2454
2761
|
this.logTasks(files);
|
|
2455
2762
|
}
|
|
@@ -3654,8 +3961,6 @@ createLogUpdate(process$2.stdout);
|
|
|
3654
3961
|
|
|
3655
3962
|
createLogUpdate(process$2.stderr);
|
|
3656
3963
|
|
|
3657
|
-
var version = "1.5.3";
|
|
3658
|
-
|
|
3659
3964
|
const HIGHLIGHT_SUPPORTED_EXTS = new Set(["js", "ts"].flatMap((lang) => [
|
|
3660
3965
|
`.${lang}`,
|
|
3661
3966
|
`.m${lang}`,
|
|
@@ -3669,7 +3974,7 @@ function highlightCode(id, source, colors) {
|
|
|
3669
3974
|
if (!HIGHLIGHT_SUPPORTED_EXTS.has(ext))
|
|
3670
3975
|
return source;
|
|
3671
3976
|
const isJsx = ext.endsWith("x");
|
|
3672
|
-
return highlight(source, { jsx: isJsx, colors:
|
|
3977
|
+
return highlight(source, { jsx: isJsx, colors: c });
|
|
3673
3978
|
}
|
|
3674
3979
|
|
|
3675
3980
|
class BaseSequencer {
|
|
@@ -3777,10 +4082,10 @@ class Logger {
|
|
|
3777
4082
|
this._clearScreenPending = void 0;
|
|
3778
4083
|
this.console.log(`${CURSOR_TO_START}${ERASE_DOWN}${log}`);
|
|
3779
4084
|
}
|
|
3780
|
-
|
|
4085
|
+
printError(err, options = {}) {
|
|
3781
4086
|
const { fullStack = false, type } = options;
|
|
3782
4087
|
const project = options.project ?? this.ctx.getCoreWorkspaceProject() ?? this.ctx.projects[0];
|
|
3783
|
-
|
|
4088
|
+
printError(err, project, {
|
|
3784
4089
|
fullStack,
|
|
3785
4090
|
type,
|
|
3786
4091
|
showCodeFrame: true,
|
|
@@ -3824,8 +4129,6 @@ class Logger {
|
|
|
3824
4129
|
this.console.error(c.dim("typecheck exclude: ") + c.yellow(config2.typecheck.exclude.join(comma)));
|
|
3825
4130
|
}
|
|
3826
4131
|
});
|
|
3827
|
-
if (config.watchExclude)
|
|
3828
|
-
this.console.error(c.dim("watch exclude: ") + c.yellow(config.watchExclude.join(comma)));
|
|
3829
4132
|
if (config.watch && (config.changed || ((_a = config.related) == null ? void 0 : _a.length))) {
|
|
3830
4133
|
this.log(`No affected ${config.mode} files found
|
|
3831
4134
|
`);
|
|
@@ -3841,7 +4144,7 @@ No ${config.mode} files found, exiting with code 1`));
|
|
|
3841
4144
|
printBanner() {
|
|
3842
4145
|
var _a, _b;
|
|
3843
4146
|
this.log();
|
|
3844
|
-
const versionTest = this.ctx.config.watch ? c.blue(`v${version}`) : c.cyan(`v${version}`);
|
|
4147
|
+
const versionTest = this.ctx.config.watch ? c.blue(`v${this.ctx.version}`) : c.cyan(`v${this.ctx.version}`);
|
|
3845
4148
|
const mode = this.ctx.config.watch ? c.blue(" DEV ") : c.cyan(" RUN ");
|
|
3846
4149
|
this.log(`${c.inverse(c.bold(mode))} ${versionTest} ${c.gray(this.ctx.config.root)}`);
|
|
3847
4150
|
if (this.ctx.config.sequence.sequencer === RandomSequencer)
|
|
@@ -3865,9 +4168,13 @@ No ${config.mode} files found, exiting with code 1`));
|
|
|
3865
4168
|
}
|
|
3866
4169
|
if (this.ctx.coverageProvider)
|
|
3867
4170
|
this.log(c.dim(" Coverage enabled with ") + c.yellow(this.ctx.coverageProvider.name));
|
|
3868
|
-
this.
|
|
4171
|
+
if (this.ctx.config.standalone)
|
|
4172
|
+
this.log(c.yellow(`
|
|
4173
|
+
Vitest is running in standalone mode. Edit a test file to rerun tests.`));
|
|
4174
|
+
else
|
|
4175
|
+
this.log();
|
|
3869
4176
|
}
|
|
3870
|
-
|
|
4177
|
+
printUnhandledErrors(errors) {
|
|
3871
4178
|
const errorMessage = c.red(c.bold(
|
|
3872
4179
|
`
|
|
3873
4180
|
Vitest caught ${errors.length} unhandled error${errors.length > 1 ? "s" : ""} during the test run.
|
|
@@ -3875,26 +4182,26 @@ This might cause false positive tests. Resolve unhandled errors to make sure you
|
|
|
3875
4182
|
));
|
|
3876
4183
|
this.log(c.red(divider(c.bold(c.inverse(" Unhandled Errors ")))));
|
|
3877
4184
|
this.log(errorMessage);
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
})
|
|
4185
|
+
errors.forEach((err) => {
|
|
4186
|
+
this.printError(err, { fullStack: true, type: err.type || "Unhandled Error" });
|
|
4187
|
+
});
|
|
3881
4188
|
this.log(c.red(divider()));
|
|
3882
4189
|
}
|
|
3883
|
-
|
|
4190
|
+
printSourceTypeErrors(errors) {
|
|
3884
4191
|
const errorMessage = c.red(c.bold(
|
|
3885
4192
|
`
|
|
3886
4193
|
Vitest found ${errors.length} error${errors.length > 1 ? "s" : ""} not related to your test files.`
|
|
3887
4194
|
));
|
|
3888
4195
|
this.log(c.red(divider(c.bold(c.inverse(" Source Errors ")))));
|
|
3889
4196
|
this.log(errorMessage);
|
|
3890
|
-
|
|
3891
|
-
|
|
3892
|
-
})
|
|
4197
|
+
errors.forEach((err) => {
|
|
4198
|
+
this.printError(err, { fullStack: true });
|
|
4199
|
+
});
|
|
3893
4200
|
this.log(c.red(divider()));
|
|
3894
4201
|
}
|
|
3895
4202
|
}
|
|
3896
4203
|
|
|
3897
|
-
|
|
4204
|
+
function capturePrintError(error, ctx, project) {
|
|
3898
4205
|
let output = "";
|
|
3899
4206
|
const writable = new Writable({
|
|
3900
4207
|
write(chunk, _encoding, callback) {
|
|
@@ -3902,13 +4209,13 @@ async function captuerPrintError(error, ctx, project) {
|
|
|
3902
4209
|
callback();
|
|
3903
4210
|
}
|
|
3904
4211
|
});
|
|
3905
|
-
const result =
|
|
4212
|
+
const result = printError(error, project, {
|
|
3906
4213
|
showCodeFrame: false,
|
|
3907
4214
|
logger: new Logger(ctx, writable, writable)
|
|
3908
4215
|
});
|
|
3909
4216
|
return { nearest: result == null ? void 0 : result.nearest, output };
|
|
3910
4217
|
}
|
|
3911
|
-
|
|
4218
|
+
function printError(error, project, options) {
|
|
3912
4219
|
const { showCodeFrame = true, fullStack = false, type } = options;
|
|
3913
4220
|
const logger = options.logger;
|
|
3914
4221
|
let e = error;
|
|
@@ -3980,7 +4287,7 @@ async function printError(error, project, options) {
|
|
|
3980
4287
|
}
|
|
3981
4288
|
if (typeof e.cause === "object" && e.cause && "name" in e.cause) {
|
|
3982
4289
|
e.cause.name = `Caused by: ${e.cause.name}`;
|
|
3983
|
-
|
|
4290
|
+
printError(e.cause, project, { fullStack, showCodeFrame: false, logger: options.logger });
|
|
3984
4291
|
}
|
|
3985
4292
|
handleImportOutsideModuleError(e.stack || e.stackStr || "", logger);
|
|
3986
4293
|
return { nearest };
|
|
@@ -4151,7 +4458,7 @@ function flattenTasks$1(task, baseName = "") {
|
|
|
4151
4458
|
function removeInvalidXMLCharacters(value, removeDiscouragedChars) {
|
|
4152
4459
|
let regex = /((?:[\0-\x08\x0B\f\x0E-\x1F\uFFFD\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]))/g;
|
|
4153
4460
|
value = String(value || "").replace(regex, "");
|
|
4154
|
-
|
|
4461
|
+
{
|
|
4155
4462
|
regex = new RegExp(
|
|
4156
4463
|
"([\\x7F-\\x84]|[\\x86-\\x9F]|[\\uFDD0-\\uFDEF]|(?:\\uD83F[\\uDFFE\\uDFFF])|(?:\\uD87F[\\uDFFE\\uDFFF])|(?:\\uD8BF[\\uDFFE\\uDFFF])|(?:\\uD8FF[\\uDFFE\\uDFFF])|(?:\\uD93F[\\uDFFE\\uDFFF])|(?:\\uD97F[\\uDFFE\\uDFFF])|(?:\\uD9BF[\\uDFFE\\uDFFF])|(?:\\uD9FF[\\uDFFE\\uDFFF])|(?:\\uDA3F[\\uDFFE\\uDFFF])|(?:\\uDA7F[\\uDFFE\\uDFFF])|(?:\\uDABF[\\uDFFE\\uDFFF])|(?:\\uDAFF[\\uDFFE\\uDFFF])|(?:\\uDB3F[\\uDFFE\\uDFFF])|(?:\\uDB7F[\\uDFFE\\uDFFF])|(?:\\uDBBF[\\uDFFE\\uDFFF])|(?:\\uDBFF[\\uDFFE\\uDFFF])(?:[\\0-\\t\\x0B\\f\\x0E-\\u2027\\u202A-\\uD7FF\\uE000-\\uFFFF]|[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]|[\\uD800-\\uDBFF](?![\\uDC00-\\uDFFF])|(?:[^\\uD800-\\uDBFF]|^)[\\uDC00-\\uDFFF]))",
|
|
4157
4464
|
"g"
|
|
@@ -4162,9 +4469,7 @@ function removeInvalidXMLCharacters(value, removeDiscouragedChars) {
|
|
|
4162
4469
|
}
|
|
4163
4470
|
function escapeXML(value) {
|
|
4164
4471
|
return removeInvalidXMLCharacters(
|
|
4165
|
-
String(value).replace(/&/g, "&").replace(/"/g, """).replace(/'/g, "'").replace(/</g, "<").replace(/>/g, ">")
|
|
4166
|
-
true
|
|
4167
|
-
);
|
|
4472
|
+
String(value).replace(/&/g, "&").replace(/"/g, """).replace(/'/g, "'").replace(/</g, "<").replace(/>/g, ">"));
|
|
4168
4473
|
}
|
|
4169
4474
|
function executionTime(durationMS) {
|
|
4170
4475
|
return (durationMS / 1e3).toLocaleString("en-US", { useGrouping: false, maximumFractionDigits: 10 });
|
|
@@ -4183,7 +4488,9 @@ class JUnitReporter {
|
|
|
4183
4488
|
fileFd;
|
|
4184
4489
|
options;
|
|
4185
4490
|
constructor(options) {
|
|
4186
|
-
|
|
4491
|
+
var _a;
|
|
4492
|
+
this.options = { ...options };
|
|
4493
|
+
(_a = this.options).includeConsoleOutput ?? (_a.includeConsoleOutput = true);
|
|
4187
4494
|
}
|
|
4188
4495
|
async onInit(ctx) {
|
|
4189
4496
|
this.ctx = ctx;
|
|
@@ -4238,12 +4545,15 @@ class JUnitReporter {
|
|
|
4238
4545
|
await this.writeElement("testcase", {
|
|
4239
4546
|
// TODO: v2.0.0 Remove env variable in favor of custom reporter options, e.g. "reporters: [['json', { classname: 'something' }]]"
|
|
4240
4547
|
classname: this.options.classname ?? process.env.VITEST_JUNIT_CLASSNAME ?? filename,
|
|
4548
|
+
file: this.options.addFileAttribute ? filename : void 0,
|
|
4241
4549
|
name: task.name,
|
|
4242
4550
|
time: getDuration(task)
|
|
4243
4551
|
}, async () => {
|
|
4244
4552
|
var _a;
|
|
4245
|
-
|
|
4246
|
-
|
|
4553
|
+
if (this.options.includeConsoleOutput) {
|
|
4554
|
+
await this.writeLogs(task, "out");
|
|
4555
|
+
await this.writeLogs(task, "err");
|
|
4556
|
+
}
|
|
4247
4557
|
if (task.mode === "skip" || task.mode === "todo")
|
|
4248
4558
|
await this.logger.log("<skipped/>");
|
|
4249
4559
|
if (((_a = task.result) == null ? void 0 : _a.state) === "fail") {
|
|
@@ -4255,7 +4565,7 @@ class JUnitReporter {
|
|
|
4255
4565
|
}, async () => {
|
|
4256
4566
|
if (!error)
|
|
4257
4567
|
return;
|
|
4258
|
-
const result =
|
|
4568
|
+
const result = capturePrintError(
|
|
4259
4569
|
error,
|
|
4260
4570
|
this.ctx,
|
|
4261
4571
|
this.ctx.getProjectByTaskId(task.id)
|
|
@@ -4303,7 +4613,8 @@ class JUnitReporter {
|
|
|
4303
4613
|
meta: {},
|
|
4304
4614
|
// NOTE: not used in JUnitReporter
|
|
4305
4615
|
context: null,
|
|
4306
|
-
suite: null
|
|
4616
|
+
suite: null,
|
|
4617
|
+
file: null
|
|
4307
4618
|
});
|
|
4308
4619
|
}
|
|
4309
4620
|
return {
|
|
@@ -4327,8 +4638,9 @@ class JUnitReporter {
|
|
|
4327
4638
|
});
|
|
4328
4639
|
await this.writeElement("testsuites", stats, async () => {
|
|
4329
4640
|
for (const file of transformed) {
|
|
4641
|
+
const filename = relative(this.ctx.config.root, file.filepath);
|
|
4330
4642
|
await this.writeElement("testsuite", {
|
|
4331
|
-
name:
|
|
4643
|
+
name: filename,
|
|
4332
4644
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
4333
4645
|
hostname: hostname(),
|
|
4334
4646
|
tests: file.tasks.length,
|
|
@@ -4338,7 +4650,7 @@ class JUnitReporter {
|
|
|
4338
4650
|
skipped: file.stats.skipped,
|
|
4339
4651
|
time: getDuration(file)
|
|
4340
4652
|
}, async () => {
|
|
4341
|
-
await this.writeTasks(file.tasks,
|
|
4653
|
+
await this.writeTasks(file.tasks, filename);
|
|
4342
4654
|
});
|
|
4343
4655
|
}
|
|
4344
4656
|
});
|
|
@@ -4364,7 +4676,7 @@ class TapFlatReporter extends TapReporter {
|
|
|
4364
4676
|
onInit(ctx) {
|
|
4365
4677
|
super.onInit(ctx);
|
|
4366
4678
|
}
|
|
4367
|
-
|
|
4679
|
+
onFinished(files = this.ctx.state.getFiles()) {
|
|
4368
4680
|
this.ctx.logger.log("TAP version 13");
|
|
4369
4681
|
const flatTasks = files.flatMap((task) => flattenTasks(task));
|
|
4370
4682
|
this.logTasks(flatTasks);
|
|
@@ -4388,7 +4700,7 @@ class GithubActionsReporter {
|
|
|
4388
4700
|
onInit(ctx) {
|
|
4389
4701
|
this.ctx = ctx;
|
|
4390
4702
|
}
|
|
4391
|
-
|
|
4703
|
+
onFinished(files = [], errors = []) {
|
|
4392
4704
|
var _a, _b;
|
|
4393
4705
|
const projectErrors = new Array();
|
|
4394
4706
|
for (const error of errors) {
|
|
@@ -4415,7 +4727,7 @@ class GithubActionsReporter {
|
|
|
4415
4727
|
}
|
|
4416
4728
|
}
|
|
4417
4729
|
for (const { project, title, error } of projectErrors) {
|
|
4418
|
-
const result =
|
|
4730
|
+
const result = capturePrintError(error, this.ctx, project);
|
|
4419
4731
|
const stack = result == null ? void 0 : result.nearest;
|
|
4420
4732
|
if (!stack)
|
|
4421
4733
|
continue;
|
|
@@ -4454,67 +4766,6 @@ function escapeProperty(s) {
|
|
|
4454
4766
|
return s.replace(/%/g, "%25").replace(/\r/g, "%0D").replace(/\n/g, "%0A").replace(/:/g, "%3A").replace(/,/g, "%2C");
|
|
4455
4767
|
}
|
|
4456
4768
|
|
|
4457
|
-
class JsonReporter {
|
|
4458
|
-
start = 0;
|
|
4459
|
-
ctx;
|
|
4460
|
-
onInit(ctx) {
|
|
4461
|
-
this.ctx = ctx;
|
|
4462
|
-
}
|
|
4463
|
-
async logTasks(files) {
|
|
4464
|
-
var _a;
|
|
4465
|
-
const suites = getSuites(files);
|
|
4466
|
-
const numTotalTestSuites = suites.length;
|
|
4467
|
-
const tests = getTests(files);
|
|
4468
|
-
const numTotalTests = tests.length;
|
|
4469
|
-
const testResults = {};
|
|
4470
|
-
const outputFile = getOutputFile(this.ctx.config.benchmark, "json");
|
|
4471
|
-
for (const file of files) {
|
|
4472
|
-
const tests2 = getTests([file]);
|
|
4473
|
-
for (const test of tests2) {
|
|
4474
|
-
const res = (_a = test.result) == null ? void 0 : _a.benchmark;
|
|
4475
|
-
if (!res || test.mode === "skip")
|
|
4476
|
-
continue;
|
|
4477
|
-
if (!outputFile)
|
|
4478
|
-
res.samples = "ignore on terminal";
|
|
4479
|
-
testResults[test.suite.name] = (testResults[test.suite.name] || []).concat(res);
|
|
4480
|
-
}
|
|
4481
|
-
if (tests2.some((t) => {
|
|
4482
|
-
var _a2;
|
|
4483
|
-
return ((_a2 = t.result) == null ? void 0 : _a2.state) === "run";
|
|
4484
|
-
})) {
|
|
4485
|
-
this.ctx.logger.warn("WARNING: Some tests are still running when generating the json report.This is likely an internal bug in Vitest.Please report it to https://github.com/vitest-dev/vitest/issues");
|
|
4486
|
-
}
|
|
4487
|
-
}
|
|
4488
|
-
const result = {
|
|
4489
|
-
numTotalTestSuites,
|
|
4490
|
-
numTotalTests,
|
|
4491
|
-
testResults
|
|
4492
|
-
};
|
|
4493
|
-
await this.writeReport(JSON.stringify(result, null, 2));
|
|
4494
|
-
}
|
|
4495
|
-
async onFinished(files = this.ctx.state.getFiles()) {
|
|
4496
|
-
await this.logTasks(files);
|
|
4497
|
-
}
|
|
4498
|
-
/**
|
|
4499
|
-
* Writes the report to an output file if specified in the config,
|
|
4500
|
-
* or logs it to the console otherwise.
|
|
4501
|
-
* @param report
|
|
4502
|
-
*/
|
|
4503
|
-
async writeReport(report) {
|
|
4504
|
-
const outputFile = getOutputFile(this.ctx.config.benchmark, "json");
|
|
4505
|
-
if (outputFile) {
|
|
4506
|
-
const reportFile = resolve(this.ctx.config.root, outputFile);
|
|
4507
|
-
const outputDirectory = dirname(reportFile);
|
|
4508
|
-
if (!existsSync(outputDirectory))
|
|
4509
|
-
await promises.mkdir(outputDirectory, { recursive: true });
|
|
4510
|
-
await promises.writeFile(reportFile, report, "utf-8");
|
|
4511
|
-
this.ctx.logger.log(`json report written to ${reportFile}`);
|
|
4512
|
-
} else {
|
|
4513
|
-
this.ctx.logger.log(report);
|
|
4514
|
-
}
|
|
4515
|
-
}
|
|
4516
|
-
}
|
|
4517
|
-
|
|
4518
4769
|
const outputMap = /* @__PURE__ */ new WeakMap();
|
|
4519
4770
|
function formatFilepath(path) {
|
|
4520
4771
|
const lastSlash = Math.max(path.lastIndexOf("/") + 1, 0);
|
|
@@ -4530,17 +4781,6 @@ function formatNumber(number) {
|
|
|
4530
4781
|
return res[0].replace(/(?=(?:\d{3})+$)(?!\b)/g, ",") + (res[1] ? `.${res[1]}` : "");
|
|
4531
4782
|
}
|
|
4532
4783
|
const tableHead = ["name", "hz", "min", "max", "mean", "p75", "p99", "p995", "p999", "rme", "samples"];
|
|
4533
|
-
function renderTableHead(tasks) {
|
|
4534
|
-
const benches = tasks.map((i) => {
|
|
4535
|
-
var _a, _b;
|
|
4536
|
-
return ((_a = i.meta) == null ? void 0 : _a.benchmark) ? (_b = i.result) == null ? void 0 : _b.benchmark : void 0;
|
|
4537
|
-
}).filter(notNullish);
|
|
4538
|
-
const allItems = benches.map(renderBenchmarkItems).concat([tableHead]);
|
|
4539
|
-
return `${" ".repeat(3)}${tableHead.map((i, idx) => {
|
|
4540
|
-
const width = Math.max(...allItems.map((i2) => i2[idx].length));
|
|
4541
|
-
return idx ? i.padStart(width, " ") : i.padEnd(width, " ");
|
|
4542
|
-
}).map(c.bold).join(" ")}`;
|
|
4543
|
-
}
|
|
4544
4784
|
function renderBenchmarkItems(result) {
|
|
4545
4785
|
return [
|
|
4546
4786
|
result.name,
|
|
@@ -4556,21 +4796,27 @@ function renderBenchmarkItems(result) {
|
|
|
4556
4796
|
result.samples.length.toString()
|
|
4557
4797
|
];
|
|
4558
4798
|
}
|
|
4559
|
-
function
|
|
4560
|
-
|
|
4561
|
-
|
|
4562
|
-
|
|
4563
|
-
|
|
4564
|
-
|
|
4565
|
-
|
|
4566
|
-
|
|
4567
|
-
|
|
4568
|
-
|
|
4569
|
-
|
|
4570
|
-
|
|
4571
|
-
|
|
4572
|
-
|
|
4573
|
-
|
|
4799
|
+
function computeColumnWidths(results) {
|
|
4800
|
+
const rows = [
|
|
4801
|
+
tableHead,
|
|
4802
|
+
...results.map((v) => renderBenchmarkItems(v))
|
|
4803
|
+
];
|
|
4804
|
+
return Array.from(
|
|
4805
|
+
tableHead,
|
|
4806
|
+
(_, i) => Math.max(...rows.map((row) => stripAnsi(row[i]).length))
|
|
4807
|
+
);
|
|
4808
|
+
}
|
|
4809
|
+
function padRow(row, widths) {
|
|
4810
|
+
return row.map(
|
|
4811
|
+
(v, i) => i ? v.padStart(widths[i], " ") : v.padEnd(widths[i], " ")
|
|
4812
|
+
// name
|
|
4813
|
+
);
|
|
4814
|
+
}
|
|
4815
|
+
function renderTableHead(widths) {
|
|
4816
|
+
return " ".repeat(3) + padRow(tableHead, widths).map(c.bold).join(" ");
|
|
4817
|
+
}
|
|
4818
|
+
function renderBenchmark(result, widths) {
|
|
4819
|
+
const padded = padRow(renderBenchmarkItems(result), widths);
|
|
4574
4820
|
return [
|
|
4575
4821
|
padded[0],
|
|
4576
4822
|
// name
|
|
@@ -4592,20 +4838,38 @@ function renderBenchmark(task, tasks) {
|
|
|
4592
4838
|
// p999
|
|
4593
4839
|
c.dim(padded[9]),
|
|
4594
4840
|
// rem
|
|
4595
|
-
c.dim(padded[10])
|
|
4841
|
+
c.dim(padded[10])
|
|
4596
4842
|
// sample
|
|
4597
|
-
result.rank === 1 ? c.bold(c.green(" fastest")) : result.rank === benches.length && benches.length > 2 ? c.bold(c.gray(" slowest")) : ""
|
|
4598
4843
|
].join(" ");
|
|
4599
4844
|
}
|
|
4600
4845
|
function renderTree(tasks, options, level = 0, shallow = false) {
|
|
4601
|
-
var _a, _b, _c, _d, _e, _f;
|
|
4846
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
4602
4847
|
const output = [];
|
|
4848
|
+
const benchMap = {};
|
|
4849
|
+
for (const t of tasks) {
|
|
4850
|
+
if (t.meta.benchmark && ((_a = t.result) == null ? void 0 : _a.benchmark)) {
|
|
4851
|
+
benchMap[t.id] = {
|
|
4852
|
+
current: t.result.benchmark
|
|
4853
|
+
};
|
|
4854
|
+
const baseline = (_b = options.compare) == null ? void 0 : _b[t.id];
|
|
4855
|
+
if (baseline) {
|
|
4856
|
+
benchMap[t.id].baseline = {
|
|
4857
|
+
...baseline,
|
|
4858
|
+
samples: Array(baseline.sampleCount)
|
|
4859
|
+
};
|
|
4860
|
+
}
|
|
4861
|
+
}
|
|
4862
|
+
}
|
|
4863
|
+
const benchCount = Object.entries(benchMap).length;
|
|
4864
|
+
const columnWidths = computeColumnWidths(
|
|
4865
|
+
Object.values(benchMap).flatMap((v) => [v.current, v.baseline]).filter(notNullish)
|
|
4866
|
+
);
|
|
4603
4867
|
let idx = 0;
|
|
4604
4868
|
for (const task of tasks) {
|
|
4605
4869
|
const padding = " ".repeat(level ? 1 : 0);
|
|
4606
4870
|
let prefix = "";
|
|
4607
|
-
if (idx === 0 && ((
|
|
4608
|
-
prefix += `${renderTableHead(
|
|
4871
|
+
if (idx === 0 && ((_c = task.meta) == null ? void 0 : _c.benchmark))
|
|
4872
|
+
prefix += `${renderTableHead(columnWidths)}
|
|
4609
4873
|
${padding}`;
|
|
4610
4874
|
prefix += ` ${getStateSymbol(task)} `;
|
|
4611
4875
|
let suffix = "";
|
|
@@ -4613,18 +4877,43 @@ ${padding}`;
|
|
|
4613
4877
|
suffix += c.dim(` (${getTests(task).length})`);
|
|
4614
4878
|
if (task.mode === "skip" || task.mode === "todo")
|
|
4615
4879
|
suffix += ` ${c.dim(c.gray("[skipped]"))}`;
|
|
4616
|
-
if (((
|
|
4880
|
+
if (((_d = task.result) == null ? void 0 : _d.duration) != null) {
|
|
4617
4881
|
if (task.result.duration > options.slowTestThreshold)
|
|
4618
4882
|
suffix += c.yellow(` ${Math.round(task.result.duration)}${c.dim("ms")}`);
|
|
4619
4883
|
}
|
|
4620
|
-
if (options.showHeap && ((
|
|
4884
|
+
if (options.showHeap && ((_e = task.result) == null ? void 0 : _e.heap) != null)
|
|
4621
4885
|
suffix += c.magenta(` ${Math.floor(task.result.heap / 1024 / 1024)} MB heap used`);
|
|
4622
4886
|
let name = task.name;
|
|
4623
4887
|
if (level === 0)
|
|
4624
4888
|
name = formatFilepath(name);
|
|
4625
|
-
const
|
|
4626
|
-
|
|
4627
|
-
|
|
4889
|
+
const bench = benchMap[task.id];
|
|
4890
|
+
if (bench) {
|
|
4891
|
+
let body = renderBenchmark(bench.current, columnWidths);
|
|
4892
|
+
if (options.compare && bench.baseline) {
|
|
4893
|
+
if (bench.current.hz) {
|
|
4894
|
+
const diff = bench.current.hz / bench.baseline.hz;
|
|
4895
|
+
const diffFixed = diff.toFixed(2);
|
|
4896
|
+
if (diffFixed === "1.0.0")
|
|
4897
|
+
body += ` ${c.gray(`[${diffFixed}x]`)}`;
|
|
4898
|
+
if (diff > 1)
|
|
4899
|
+
body += ` ${c.blue(`[${diffFixed}x] \u21D1`)}`;
|
|
4900
|
+
else
|
|
4901
|
+
body += ` ${c.red(`[${diffFixed}x] \u21D3`)}`;
|
|
4902
|
+
}
|
|
4903
|
+
output.push(padding + prefix + body + suffix);
|
|
4904
|
+
const bodyBaseline = renderBenchmark(bench.baseline, columnWidths);
|
|
4905
|
+
output.push(`${padding} ${bodyBaseline} ${c.dim("(baseline)")}`);
|
|
4906
|
+
} else {
|
|
4907
|
+
if (bench.current.rank === 1 && benchCount > 1)
|
|
4908
|
+
body += ` ${c.bold(c.green(" fastest"))}`;
|
|
4909
|
+
if (bench.current.rank === benchCount && benchCount > 2)
|
|
4910
|
+
body += ` ${c.bold(c.gray(" slowest"))}`;
|
|
4911
|
+
output.push(padding + prefix + body + suffix);
|
|
4912
|
+
}
|
|
4913
|
+
} else {
|
|
4914
|
+
output.push(padding + prefix + name + suffix);
|
|
4915
|
+
}
|
|
4916
|
+
if (((_f = task.result) == null ? void 0 : _f.state) !== "pass" && outputMap.get(task) != null) {
|
|
4628
4917
|
let data = outputMap.get(task);
|
|
4629
4918
|
if (typeof data === "string") {
|
|
4630
4919
|
data = stripAnsi(data.trim().split("\n").filter(Boolean).pop());
|
|
@@ -4637,7 +4926,7 @@ ${padding}`;
|
|
|
4637
4926
|
}
|
|
4638
4927
|
}
|
|
4639
4928
|
if (!shallow && task.type === "suite" && task.tasks.length > 0) {
|
|
4640
|
-
if ((
|
|
4929
|
+
if ((_g = task.result) == null ? void 0 : _g.state)
|
|
4641
4930
|
output.push(renderTree(task.tasks, options, level + 1));
|
|
4642
4931
|
}
|
|
4643
4932
|
idx++;
|
|
@@ -4663,7 +4952,7 @@ function createTableRenderer(_tasks, options) {
|
|
|
4663
4952
|
update();
|
|
4664
4953
|
return this;
|
|
4665
4954
|
},
|
|
4666
|
-
|
|
4955
|
+
stop() {
|
|
4667
4956
|
if (timer) {
|
|
4668
4957
|
clearInterval(timer);
|
|
4669
4958
|
timer = void 0;
|
|
@@ -4681,21 +4970,34 @@ function createTableRenderer(_tasks, options) {
|
|
|
4681
4970
|
class TableReporter extends BaseReporter {
|
|
4682
4971
|
renderer;
|
|
4683
4972
|
rendererOptions = {};
|
|
4684
|
-
|
|
4685
|
-
|
|
4973
|
+
onTestRemoved(trigger) {
|
|
4974
|
+
this.stopListRender();
|
|
4686
4975
|
this.ctx.logger.clearScreen(c.yellow("Test removed...") + (trigger ? c.dim(` [ ${this.relative(trigger)} ]
|
|
4687
4976
|
`) : ""), true);
|
|
4688
4977
|
const files = this.ctx.state.getFiles(this.watchFilters);
|
|
4689
4978
|
createTableRenderer(files, this.rendererOptions).stop();
|
|
4690
4979
|
this.ctx.logger.log();
|
|
4691
|
-
|
|
4980
|
+
super.reportSummary(files, this.ctx.state.getUnhandledErrors());
|
|
4692
4981
|
super.onWatcherStart();
|
|
4693
4982
|
}
|
|
4694
|
-
onCollected() {
|
|
4983
|
+
async onCollected() {
|
|
4984
|
+
var _a, _b;
|
|
4985
|
+
this.rendererOptions.logger = this.ctx.logger;
|
|
4986
|
+
this.rendererOptions.showHeap = this.ctx.config.logHeapUsage;
|
|
4987
|
+
this.rendererOptions.slowTestThreshold = this.ctx.config.slowTestThreshold;
|
|
4988
|
+
if ((_a = this.ctx.config.benchmark) == null ? void 0 : _a.compare) {
|
|
4989
|
+
const compareFile = pathe.resolve(this.ctx.config.root, (_b = this.ctx.config.benchmark) == null ? void 0 : _b.compare);
|
|
4990
|
+
try {
|
|
4991
|
+
this.rendererOptions.compare = flattenFormattedBenchamrkReport(
|
|
4992
|
+
JSON.parse(
|
|
4993
|
+
await fs.promises.readFile(compareFile, "utf-8")
|
|
4994
|
+
)
|
|
4995
|
+
);
|
|
4996
|
+
} catch (e) {
|
|
4997
|
+
this.ctx.logger.error(`Failed to read '${compareFile}'`, e);
|
|
4998
|
+
}
|
|
4999
|
+
}
|
|
4695
5000
|
if (this.isTTY) {
|
|
4696
|
-
this.rendererOptions.logger = this.ctx.logger;
|
|
4697
|
-
this.rendererOptions.showHeap = this.ctx.config.logHeapUsage;
|
|
4698
|
-
this.rendererOptions.slowTestThreshold = this.ctx.config.slowTestThreshold;
|
|
4699
5001
|
const files = this.ctx.state.getFiles(this.watchFilters);
|
|
4700
5002
|
if (!this.renderer)
|
|
4701
5003
|
this.renderer = createTableRenderer(files, this.rendererOptions).start();
|
|
@@ -4725,21 +5027,32 @@ class TableReporter extends BaseReporter {
|
|
|
4725
5027
|
}
|
|
4726
5028
|
}
|
|
4727
5029
|
async onFinished(files = this.ctx.state.getFiles(), errors = this.ctx.state.getUnhandledErrors()) {
|
|
4728
|
-
|
|
5030
|
+
var _a;
|
|
5031
|
+
this.stopListRender();
|
|
4729
5032
|
this.ctx.logger.log();
|
|
4730
|
-
|
|
5033
|
+
super.onFinished(files, errors);
|
|
5034
|
+
let outputFile = (_a = this.ctx.config.benchmark) == null ? void 0 : _a.outputJson;
|
|
5035
|
+
if (outputFile) {
|
|
5036
|
+
outputFile = pathe.resolve(this.ctx.config.root, outputFile);
|
|
5037
|
+
const outputDirectory = pathe.dirname(outputFile);
|
|
5038
|
+
if (!fs.existsSync(outputDirectory))
|
|
5039
|
+
await fs.promises.mkdir(outputDirectory, { recursive: true });
|
|
5040
|
+
const output = createFormattedBenchamrkReport(files);
|
|
5041
|
+
await fs.promises.writeFile(outputFile, JSON.stringify(output, null, 2));
|
|
5042
|
+
this.ctx.logger.log(`Benchmark report written to ${outputFile}`);
|
|
5043
|
+
}
|
|
4731
5044
|
}
|
|
4732
5045
|
async onWatcherStart() {
|
|
4733
|
-
|
|
5046
|
+
this.stopListRender();
|
|
4734
5047
|
await super.onWatcherStart();
|
|
4735
5048
|
}
|
|
4736
|
-
|
|
5049
|
+
stopListRender() {
|
|
4737
5050
|
var _a;
|
|
4738
|
-
|
|
5051
|
+
(_a = this.renderer) == null ? void 0 : _a.stop();
|
|
4739
5052
|
this.renderer = void 0;
|
|
4740
5053
|
}
|
|
4741
5054
|
async onWatcherRerun(files, trigger) {
|
|
4742
|
-
|
|
5055
|
+
this.stopListRender();
|
|
4743
5056
|
await super.onWatcherRerun(files, trigger);
|
|
4744
5057
|
}
|
|
4745
5058
|
onUserConsoleLog(log) {
|
|
@@ -4750,11 +5063,54 @@ class TableReporter extends BaseReporter {
|
|
|
4750
5063
|
super.onUserConsoleLog(log);
|
|
4751
5064
|
}
|
|
4752
5065
|
}
|
|
5066
|
+
function createFormattedBenchamrkReport(files) {
|
|
5067
|
+
var _a;
|
|
5068
|
+
const report = { files: [] };
|
|
5069
|
+
for (const file of files) {
|
|
5070
|
+
const groups = [];
|
|
5071
|
+
for (const task of getTasks(file)) {
|
|
5072
|
+
if (task && task.type === "suite") {
|
|
5073
|
+
const benchmarks = [];
|
|
5074
|
+
for (const t of task.tasks) {
|
|
5075
|
+
const benchmark = t.meta.benchmark && ((_a = t.result) == null ? void 0 : _a.benchmark);
|
|
5076
|
+
if (benchmark) {
|
|
5077
|
+
const { samples, ...rest } = benchmark;
|
|
5078
|
+
benchmarks.push({
|
|
5079
|
+
id: t.id,
|
|
5080
|
+
sampleCount: samples.length,
|
|
5081
|
+
...rest
|
|
5082
|
+
});
|
|
5083
|
+
}
|
|
5084
|
+
}
|
|
5085
|
+
if (benchmarks.length) {
|
|
5086
|
+
groups.push({
|
|
5087
|
+
fullName: getFullName(task, " > "),
|
|
5088
|
+
benchmarks
|
|
5089
|
+
});
|
|
5090
|
+
}
|
|
5091
|
+
}
|
|
5092
|
+
}
|
|
5093
|
+
report.files.push({
|
|
5094
|
+
filepath: file.filepath,
|
|
5095
|
+
groups
|
|
5096
|
+
});
|
|
5097
|
+
}
|
|
5098
|
+
return report;
|
|
5099
|
+
}
|
|
5100
|
+
function flattenFormattedBenchamrkReport(report) {
|
|
5101
|
+
const flat = {};
|
|
5102
|
+
for (const file of report.files) {
|
|
5103
|
+
for (const group of file.groups) {
|
|
5104
|
+
for (const t of group.benchmarks)
|
|
5105
|
+
flat[t.id] = t;
|
|
5106
|
+
}
|
|
5107
|
+
}
|
|
5108
|
+
return flat;
|
|
5109
|
+
}
|
|
4753
5110
|
|
|
4754
5111
|
const BenchmarkReportsMap = {
|
|
4755
5112
|
default: TableReporter,
|
|
4756
|
-
verbose: VerboseReporter
|
|
4757
|
-
json: JsonReporter
|
|
5113
|
+
verbose: VerboseReporter
|
|
4758
5114
|
};
|
|
4759
5115
|
|
|
4760
5116
|
const ReportersMap = {
|
|
@@ -4762,7 +5118,7 @@ const ReportersMap = {
|
|
|
4762
5118
|
"basic": BasicReporter,
|
|
4763
5119
|
"verbose": VerboseReporter,
|
|
4764
5120
|
"dot": DotReporter,
|
|
4765
|
-
"json": JsonReporter
|
|
5121
|
+
"json": JsonReporter,
|
|
4766
5122
|
"tap": TapReporter,
|
|
4767
5123
|
"tap-flat": TapFlatReporter,
|
|
4768
5124
|
"junit": JUnitReporter,
|
|
@@ -4770,4 +5126,4 @@ const ReportersMap = {
|
|
|
4770
5126
|
"github-actions": GithubActionsReporter
|
|
4771
5127
|
};
|
|
4772
5128
|
|
|
4773
|
-
export { BaseSequencer as B, DefaultReporter as D, GithubActionsReporter as G, HangingProcessReporter as H, JsonReporter
|
|
5129
|
+
export { BaseSequencer as B, DefaultReporter as D, GithubActionsReporter as G, HangingProcessReporter as H, JsonReporter as J, Logger as L, ReportersMap as R, TapReporter as T, VerboseReporter as V, BasicReporter as a, DotReporter as b, JUnitReporter as c, TapFlatReporter as d, BenchmarkReportsMap as e, Typechecker as f, RandomSequencer as g, findNodeAround as h, generateCodeFrame as i, highlightCode as j, wrapSerializableConfig as w };
|