vitest 2.0.3 → 2.0.5
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 +21 -0
- package/dist/browser.d.ts +21 -42
- package/dist/browser.js +5 -5
- package/dist/{vendor/base.CC6UHsNs.js → chunks/base.CC5R_kgU.js} +3 -3
- package/dist/{vendor/base.CTYV4Gnz.js → chunks/base.DSsbfkDg.js} +5 -4
- package/dist/{vendor/benchmark.B6pblCp2.js → chunks/benchmark.DDmpNjj-.js} +1 -1
- package/dist/chunks/benchmark.puBFxyfE.d.ts +22 -0
- package/dist/{vendor/cac.DUiZvzF_.js → chunks/cac.DGgmCKmU.js} +18 -21
- package/dist/{vendor/cli-api.CsgSG1Ir.js → chunks/cli-api.OKfd3qJ0.js} +666 -487
- package/dist/chunks/config.DCnyCTbs.d.ts +203 -0
- package/dist/chunks/{runtime-console.C2L2zykk.js → console.Bgn7_A1x.js} +11 -14
- package/dist/{vendor/constants.CsnA4eRy.js → chunks/constants.CaAN7icJ.js} +1 -3
- package/dist/{vendor/coverage.BhYSDdTT.js → chunks/coverage.CqfT4xaf.js} +4 -7
- package/dist/chunks/{browser-creator.CyaOd8pl.js → creator.a3OfuIEW.js} +8 -8
- package/dist/{vendor/env.2ltrQNq0.js → chunks/env.BU041cs9.js} +2 -3
- package/dist/chunks/environment.0M5R1SX_.d.ts +173 -0
- package/dist/{vendor/execute.Dx503nGn.js → chunks/execute.Cjlr2CRw.js} +28 -20
- package/dist/chunks/globals.BliuJFNR.js +31 -0
- package/dist/{vendor/index.Hqvcg1pf.js → chunks/index.BfeNhc0N.js} +43 -43
- package/dist/{vendor/index.D6GZqexG.js → chunks/index.CM5UI-4O.js} +2 -2
- package/dist/{vendor/index.BJmtb_7W.js → chunks/index.DYufA6CZ.js} +2 -2
- package/dist/{vendor/index.BCwvoAaf.js → chunks/index.JbiJutJ_.js} +516 -258
- package/dist/{vendor/index.CROIsoiT.js → chunks/index.R1VjssW9.js} +11 -12
- package/dist/{vendor/index.D4nqnQWz.js → chunks/index.lVXYBqEP.js} +1 -18
- package/dist/{vendor/inspector.-FCQUzqR.js → chunks/inspector.70d6emsh.js} +4 -5
- package/dist/chunks/{environments-node.XE5FbRPQ.js → node.DS3zEPa7.js} +2 -2
- package/dist/{reporters-BECoY4-b.d.ts → chunks/reporters.C_zwCd4j.d.ts} +850 -1003
- package/dist/{vendor/rpc.BGx7q_k2.js → chunks/rpc.B7Mfb-Yf.js} +3 -5
- package/dist/{vendor/run-once.Db8Hgq9X.js → chunks/run-once.Sxe67Wng.js} +1 -1
- package/dist/chunks/{runtime-runBaseTests.hkIOeriM.js → runBaseTests.CyvqmuC9.js} +35 -27
- package/dist/{vendor/setup-common.yHaxjRhz.js → chunks/setup-common.CNzatKMx.js} +2 -2
- package/dist/{suite-BWgaIsVn.d.ts → chunks/suite.CcK46U-P.d.ts} +1 -1
- package/dist/{vendor/tasks.DhVtQBtW.js → chunks/tasks.BZnCS9aT.js} +2 -3
- package/dist/{vendor/utils.DkxLWvS1.js → chunks/utils.C3_cBsyn.js} +3 -4
- package/dist/{vendor/global.7bFbnyXl.js → chunks/utils.Ck2hJTRs.js} +1 -1
- package/dist/{vendor/utils.DyTe1Nxn.js → chunks/utils.DpP_sDwr.js} +8 -21
- package/dist/{vendor/vi.DXACdGTu.js → chunks/vi.fiQ7lMRF.js} +13 -18
- package/dist/{vendor/vm.D1T5Rxan.js → chunks/vm.DcSuuaHr.js} +40 -68
- package/dist/chunks/worker.C5iHKIaJ.d.ts +144 -0
- package/dist/chunks/worker.DKkAC4Qw.d.ts +8 -0
- package/dist/cli.js +3 -3
- package/dist/config.cjs +6 -9
- package/dist/config.d.ts +10 -8
- package/dist/config.js +6 -9
- package/dist/coverage.d.ts +10 -8
- package/dist/coverage.js +11 -7
- package/dist/environments.d.ts +3 -19
- package/dist/environments.js +1 -1
- package/dist/execute.d.ts +8 -17
- package/dist/execute.js +2 -2
- package/dist/index.d.ts +267 -34
- package/dist/index.js +12 -12
- package/dist/node.d.ts +15 -9
- package/dist/node.js +16 -19
- package/dist/reporters.d.ts +10 -8
- package/dist/reporters.js +12 -15
- package/dist/runners.d.ts +7 -19
- package/dist/runners.js +12 -13
- package/dist/snapshot.js +3 -3
- package/dist/suite.d.ts +2 -16
- package/dist/suite.js +4 -4
- package/dist/worker.js +7 -8
- package/dist/workers/forks.js +5 -5
- package/dist/workers/runVmTests.js +32 -23
- package/dist/workers/threads.js +5 -5
- package/dist/workers/vmForks.js +8 -8
- package/dist/workers/vmThreads.js +8 -8
- package/dist/workers.d.ts +13 -8
- package/dist/workers.js +13 -13
- package/package.json +15 -15
- package/dist/chunks/integrations-globals.CzYWb38r.js +0 -31
- /package/dist/{vendor → chunks}/_commonjsHelpers.BFTU3MAI.js +0 -0
- /package/dist/{vendor → chunks}/date.W2xKR2qe.js +0 -0
- /package/dist/chunks/{node-git.ZtkbKc8u.js → git.ZtkbKc8u.js} +0 -0
- /package/dist/{vendor → chunks}/index.BMmMjLIQ.js +0 -0
- /package/dist/{vendor → chunks}/index.BpSiYbpB.js +0 -0
- /package/dist/chunks/{install-pkg.DNUmWFkO.js → index.DNUmWFkO.js} +0 -0
- /package/dist/{vendor → chunks}/spy.Cf_4R5Oe.js +0 -0
|
@@ -1,17 +1,16 @@
|
|
|
1
|
+
import { g as getTestName, h as hasFailedSnapshot, a as getFullName } from './tasks.BZnCS9aT.js';
|
|
1
2
|
import fs, { existsSync, promises, readFileSync } from 'node:fs';
|
|
2
3
|
import c from 'tinyrainbow';
|
|
3
4
|
import * as pathe from 'pathe';
|
|
4
5
|
import { basename, dirname, resolve, join, relative, extname, normalize } from 'pathe';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { g as getStateSymbol, f as formatProjectName, t as taskFail, F as F_RIGHT, a as F_POINTER, r as renderSnapshotSummary, b as getStateString, c as formatTimeString, d as countTestErrors, e as divider, s as stripAnsi, h as getCols, i as getHookStateSymbol } from './utils.DyTe1Nxn.js';
|
|
6
|
+
import { notNullish, highlight, shuffle, inspect, positionToOffset, lineSplitRE } from '@vitest/utils';
|
|
7
|
+
import { i as isNode, a as isDeno } from './env.BU041cs9.js';
|
|
8
|
+
import { g as getStateSymbol, f as formatProjectName, t as taskFail, F as F_RIGHT, a as F_POINTER, r as renderSnapshotSummary, b as getStateString, c as formatTimeString, d as countTestErrors, e as divider, s as stripAnsi, h as getCols, i as getHookStateSymbol } from './utils.DpP_sDwr.js';
|
|
9
9
|
import { generateHash, calculateSuiteHash, someTasksAreOnly, interpretTaskModes, getTasks, getTests, hasFailed, getSuites } from '@vitest/runner/utils';
|
|
10
10
|
import { performance } from 'node:perf_hooks';
|
|
11
11
|
import { TraceMap, generatedPositionFor, parseStacktrace, parseErrorStacktrace } from '@vitest/utils/source-map';
|
|
12
|
-
import { r as relativePath } from './index.
|
|
13
|
-
import {
|
|
14
|
-
import { t as toArray, b as isPrimitive } from './base.CTYV4Gnz.js';
|
|
12
|
+
import { r as relativePath } from './index.DYufA6CZ.js';
|
|
13
|
+
import { t as toArray, b as isPrimitive } from './base.DSsbfkDg.js';
|
|
15
14
|
import { isCI } from 'std-env';
|
|
16
15
|
import nodeos__default, { hostname } from 'node:os';
|
|
17
16
|
import { Writable } from 'node:stream';
|
|
@@ -20,7 +19,7 @@ import { execa } from 'execa';
|
|
|
20
19
|
import url from 'node:url';
|
|
21
20
|
import p$1 from 'path';
|
|
22
21
|
import require$$0 from 'fs';
|
|
23
|
-
import
|
|
22
|
+
import ke from 'module';
|
|
24
23
|
import { parseAstAsync } from 'vite';
|
|
25
24
|
import { Console } from 'node:console';
|
|
26
25
|
import process$2 from 'node:process';
|
|
@@ -140,7 +139,7 @@ const stringify = (value, replacer, space) => {
|
|
|
140
139
|
|
|
141
140
|
const REGEXP_WRAP_PREFIX = "$$vitest:";
|
|
142
141
|
function getOutputFile(config, reporter) {
|
|
143
|
-
if (!
|
|
142
|
+
if (!config?.outputFile) {
|
|
144
143
|
return;
|
|
145
144
|
}
|
|
146
145
|
if (typeof config.outputFile === "string") {
|
|
@@ -164,21 +163,20 @@ function wrapSerializableConfig(config) {
|
|
|
164
163
|
};
|
|
165
164
|
}
|
|
166
165
|
|
|
167
|
-
const A=r=>r!==null&&typeof r=="object",a=(r,t)=>Object.assign(new Error(`[${r}]: ${t}`),{code:r}),_
|
|
166
|
+
const A=r=>r!==null&&typeof r=="object",a=(r,t)=>Object.assign(new Error(`[${r}]: ${t}`),{code:r}),_="ERR_INVALID_PACKAGE_CONFIG",E$1="ERR_INVALID_PACKAGE_TARGET",I="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$1,`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(_,"Cannot contain numeric property keys");if(n==="default"||o.includes(n))return f(r,t[n],e,o,c)}return []}throw a(E$1,`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(_,'"exports" cannot contain some keys starting with "." and some not')},void 0),u$1=/^\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,t==="."?'No "exports" main defined':`Package subpath '${t}' is not defined by "exports"`);for(const i of n)if(!i.startsWith("./")&&!u$1.test(i))throw a(E$1,`Invalid "exports" target "${i}" defined in the package config`);return n};
|
|
168
167
|
|
|
169
|
-
function
|
|
170
|
-
`;break;case 114:r+="\r";break;case 116:r+=" ";break;case 117:const
|
|
171
|
-
`),
|
|
172
|
-
`+" ".repeat(t)),new Array(
|
|
173
|
-
`+" ".repeat(t)),new Array(
|
|
174
|
-
`+" ".repeat(t)),new Array(
|
|
175
|
-
`+" ".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(p$1.resolve(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";
|
|
168
|
+
var ae=Object.defineProperty;var u=(e,t)=>ae(e,"name",{value:t,configurable:!0});function E(e){return e.startsWith("\\\\?\\")?e:e.replace(/\\/g,"/")}u(E,"slash");const h=u(e=>{const t=require$$0[e];return (i,...n)=>{const l=`${e}:${n.join(":")}`;let o=i==null?void 0:i.get(l);return o===void 0&&(o=Reflect.apply(t,require$$0,n),i==null||i.set(l,o)),o}},"cacheFs"),L=h("existsSync"),we=h("readFileSync"),P=h("statSync"),K=u((e,t,i)=>{for(;;){const n=p$1.posix.join(e,t);if(L(i,n))return n;const l=p$1.dirname(e);if(l===e)return;e=l;}},"findUp"),J=/^\.{1,2}(\/.*)?$/,M=u(e=>{const t=E(e);return J.test(t)?t:`./${t}`},"normalizePath");function Te(e,t=!1){const i=e.length;let n=0,l="",o=0,s=16,c=0,f=0,w=0,A=0,k=0;function O(r,g){let m=0,_=0;for(;m<r||!g;){let j=e.charCodeAt(n);if(j>=48&&j<=57)_=_*16+j-48;else if(j>=65&&j<=70)_=_*16+j-65+10;else if(j>=97&&j<=102)_=_*16+j-97+10;else break;n++,m++;}return m<r&&(_=-1),_}u(O,"scanHexDigits");function T(r){n=r,l="",o=0,s=16,k=0;}u(T,"setPosition");function v(){let r=n;if(e.charCodeAt(n)===48)n++;else for(n++;n<e.length&&F(e.charCodeAt(n));)n++;if(n<e.length&&e.charCodeAt(n)===46)if(n++,n<e.length&&F(e.charCodeAt(n)))for(n++;n<e.length&&F(e.charCodeAt(n));)n++;else return k=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&&F(e.charCodeAt(n))){for(n++;n<e.length&&F(e.charCodeAt(n));)n++;g=n;}else k=3;return e.substring(r,g)}u(v,"scanNumber");function b(){let r="",g=n;for(;;){if(n>=i){r+=e.substring(g,n),k=2;break}const m=e.charCodeAt(n);if(m===34){r+=e.substring(g,n),n++;break}if(m===92){if(r+=e.substring(g,n),n++,n>=i){k=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+=`
|
|
169
|
+
`;break;case 114:r+="\r";break;case 116:r+=" ";break;case 117:const j=O(4,!0);j>=0?r+=String.fromCharCode(j):k=4;break;default:k=5;}g=n;continue}if(m>=0&&m<=31)if(x(m)){r+=e.substring(g,n),k=2;break}else k=6;n++;}return r}u(b,"scanString");function B(){if(l="",k=0,o=n,f=c,A=w,n>=i)return o=i,s=17;let r=e.charCodeAt(n);if(R(r)){do n++,l+=String.fromCharCode(r),r=e.charCodeAt(n);while(R(r));return s=15}if(x(r))return n++,l+=String.fromCharCode(r),r===13&&e.charCodeAt(n)===10&&(n++,l+=`
|
|
170
|
+
`),c++,w=n,s=14;switch(r){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++,l=b(),s=10;case 47:const g=n-1;if(e.charCodeAt(n+1)===47){for(n+=2;n<i&&!x(e.charCodeAt(n));)n++;return l=e.substring(g,n),s=12}if(e.charCodeAt(n+1)===42){n+=2;const m=i-1;let _=!1;for(;n<m;){const j=e.charCodeAt(n);if(j===42&&e.charCodeAt(n+1)===47){n+=2,_=!0;break}n++,x(j)&&(j===13&&e.charCodeAt(n)===10&&n++,c++,w=n);}return _||(n++,k=1),l=e.substring(g,n),s=13}return l+=String.fromCharCode(r),n++,s=16;case 45:if(l+=String.fromCharCode(r),n++,n===i||!F(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 l+=v(),s=11;default:for(;n<i&&U(r);)n++,r=e.charCodeAt(n);if(o!==n){switch(l=e.substring(o,n),l){case"true":return s=8;case"false":return s=9;case"null":return s=7}return s=16}return l+=String.fromCharCode(r),n++,s=16}}u(B,"scanNext");function U(r){if(R(r)||x(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}u(U,"isUnknownContentCharacter");function y(){let r;do r=B();while(r>=12&&r<=15);return r}return u(y,"scanNextNonTrivia"),{setPosition:T,getPosition:()=>n,scan:t?y:B,getToken:()=>s,getTokenValue:()=>l,getTokenOffset:()=>o,getTokenLength:()=>n-o,getTokenStartLine:()=>f,getTokenStartCharacter:()=>o-A,getTokenError:()=>k}}u(Te,"createScanner");function R(e){return e===32||e===9}u(R,"isWhiteSpace");function x(e){return e===10||e===13}u(x,"isLineBreak");function F(e){return e>=48&&e<=57}u(F,"isDigit");var C;((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";}))(C||(C={})),new Array(20).fill(0).map((e,t)=>" ".repeat(t));const N=200;new Array(N).fill(0).map((e,t)=>`
|
|
171
|
+
`+" ".repeat(t)),new Array(N).fill(0).map((e,t)=>"\r"+" ".repeat(t)),new Array(N).fill(0).map((e,t)=>`\r
|
|
172
|
+
`+" ".repeat(t)),new Array(N).fill(0).map((e,t)=>`
|
|
173
|
+
`+" ".repeat(t)),new Array(N).fill(0).map((e,t)=>"\r"+" ".repeat(t)),new Array(N).fill(0).map((e,t)=>`\r
|
|
174
|
+
`+" ".repeat(t));var D;(function(e){e.DEFAULT={allowTrailingComma:!1};})(D||(D={}));function ve(e,t=[],i=D.DEFAULT){let n=null,l=[];const o=[];function s(f){Array.isArray(l)?l.push(f):n!==null&&(l[n]=f);}return u(s,"onValue"),Ae(e,{onObjectBegin:()=>{const f={};s(f),o.push(l),l=f,n=null;},onObjectProperty:f=>{n=f;},onObjectEnd:()=>{l=o.pop();},onArrayBegin:()=>{const f=[];s(f),o.push(l),l=f,n=null;},onArrayEnd:()=>{l=o.pop();},onLiteralValue:s,onError:(f,w,A)=>{t.push({error:f,offset:w,length:A});}},i),l[0]}u(ve,"parse$1");function Ae(e,t,i=D.DEFAULT){const n=Te(e,!1),l=[];function o(a){return a?()=>a(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter()):()=>!0}u(o,"toNoArgVisit");function s(a){return a?()=>a(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter(),()=>l.slice()):()=>!0}u(s,"toNoArgVisitWithPath");function c(a){return a?$=>a($,n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter()):()=>!0}u(c,"toOneArgVisit");function f(a){return a?$=>a($,n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter(),()=>l.slice()):()=>!0}u(f,"toOneArgVisitWithPath");const w=s(t.onObjectBegin),A=f(t.onObjectProperty),k=o(t.onObjectEnd),O=s(t.onArrayBegin),T=o(t.onArrayEnd),v=f(t.onLiteralValue),b=c(t.onSeparator),B=o(t.onComment),U=c(t.onError),y=i&&i.disallowComments,r=i&&i.allowTrailingComma;function g(){for(;;){const a=n.scan();switch(n.getTokenError()){case 4:m(14);break;case 5:m(15);break;case 3:m(13);break;case 1:y||m(11);break;case 2:m(12);break;case 6:m(16);break}switch(a){case 12:case 13:y?m(10):B();break;case 16:m(1);break;case 15:case 14:break;default:return a}}}u(g,"scanNext");function m(a,$=[],q=[]){if(U(a),$.length+q.length>0){let I=n.getToken();for(;I!==17;){if($.indexOf(I)!==-1){g();break}else if(q.indexOf(I)!==-1)break;I=g();}}}u(m,"handleError");function _(a){const $=n.getTokenValue();return a?v($):(A($),l.push($)),g(),!0}u(_,"parseString");function j(){switch(n.getToken()){case 11:const a=n.getTokenValue();let $=Number(a);isNaN($)&&(m(2),$=0),v($);break;case 7:v(null);break;case 8:v(!0);break;case 9:v(!1);break;default:return !1}return g(),!0}u(j,"parseLiteral");function pe(){return n.getToken()!==10?(m(3,[],[2,5]),!1):(_(!1),n.getToken()===6?(b(":"),g(),d()||m(4,[],[2,5])):m(5,[],[2,5]),l.pop(),!0)}u(pe,"parseProperty");function me(){w(),g();let a=!1;for(;n.getToken()!==2&&n.getToken()!==17;){if(n.getToken()===5){if(a||m(4,[],[]),b(","),g(),n.getToken()===2&&r)break}else a&&m(6,[],[]);pe()||m(4,[],[2,5]),a=!0;}return k(),n.getToken()!==2?m(7,[2],[]):g(),!0}u(me,"parseObject");function ge(){O(),g();let a=!0,$=!1;for(;n.getToken()!==4&&n.getToken()!==17;){if(n.getToken()===5){if($||m(4,[],[]),b(","),g(),n.getToken()===4&&r)break}else $&&m(6,[],[]);a?(l.push(0),a=!1):l[l.length-1]++,d()||m(4,[],[4,5]),$=!0;}return T(),a||l.pop(),n.getToken()!==4?m(8,[4],[]):g(),!0}u(ge,"parseArray");function d(){switch(n.getToken()){case 3:return ge();case 1:return me();case 10:return _(!0);default:return j()}}return u(d,"parseValue"),g(),n.getToken()===17?i.allowEmptyContent?!0:(m(4,[],[]),!1):d()?(n.getToken()!==17&&m(9,[],[]),!0):(m(4,[],[]),!1)}u(Ae,"visit");var ee;(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";})(ee||(ee={}));var ne;(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";})(ne||(ne={}));const Oe=ve;var te;(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";})(te||(te={}));const ie=u((e,t)=>Oe(we(t,e,"utf8")),"readJsonc"),G=Symbol("implicitBaseUrl"),je=u(()=>{const{findPnpApi:e}=ke;return e&&e(process.cwd())},"getPnpApi"),z=u((e,t,i,n)=>{const l=`resolveFromPackageJsonPath:${e}:${t}:${i}`;if(n!=null&&n.has(l))return n.get(l);const o=ie(e,n);if(!o)return;let s=t||"tsconfig.json";if(!i&&o.exports)try{const[c]=v(o.exports,t,["require","types"]);s=c;}catch{return !1}else !t&&o.tsconfig&&(s=o.tsconfig);return s=p$1.join(e,"..",s),n==null||n.set(l,s),s},"resolveFromPackageJsonPath"),Q="package.json",H="tsconfig.json",$e=u((e,t,i)=>{let n=e;if(e===".."&&(n=p$1.join(n,H)),e[0]==="."&&(n=p$1.resolve(t,n)),p$1.isAbsolute(n)){if(L(i,n)){if(P(i,n).isFile())return n}else if(!n.endsWith(".json")){const T=`${n}.json`;if(L(i,T))return T}return}const[l,...o]=e.split("/"),s=l[0]==="@"?`${l}/${o.shift()}`:l,c=o.join("/"),f=je();if(f){const{resolveRequest:T}=f;try{if(s===e){const v=T(p$1.join(s,Q),t);if(v){const b=z(v,c,!1,i);if(b&&L(i,b))return b}}else {let v;try{v=T(e,t,{extensions:[".json"]});}catch{v=T(p$1.join(e,H),t);}if(v)return v}}catch{}}const w=K(p$1.resolve(t),p$1.join("node_modules",s),i);if(!w||!P(i,w).isDirectory())return;const A=p$1.join(w,Q);if(L(i,A)){const T=z(A,c,!1,i);if(T===!1)return;if(T&&L(i,T)&&P(i,T).isFile())return T}const k=p$1.join(w,c),O=k.endsWith(".json");if(!O){const T=`${k}.json`;if(L(i,T))return T}if(L(i,k)){if(P(i,k).isDirectory()){const T=p$1.join(k,Q);if(L(i,T)){const b=z(T,"",!0,i);if(b&&L(i,b))return b}const v=p$1.join(k,H);if(L(i,v))return v}else if(O)return k}},"resolveExtendsPath"),Be=u((e,t,i,n)=>{const l=$e(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 o=p$1.dirname(l),s=le(l,n,i);delete s.references;const{compilerOptions:c}=s;if(c){const f=["baseUrl","outDir"];for(const w of f){const A=c[w];A&&(c[w]=E(p$1.relative(t,p$1.join(o,A)))||"./");}}return s.files&&(s.files=s.files.map(f=>E(p$1.relative(t,p$1.join(o,f))))),s.include&&(s.include=s.include.map(f=>E(p$1.relative(t,p$1.join(o,f))))),s.exclude&&(s.exclude=s.exclude.map(f=>E(p$1.relative(t,p$1.join(o,f))))),s},"resolveExtends"),le=u((e,t,i=new Set)=>{let n;try{n=ie(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:o}=n;o.paths&&!o.baseUrl&&(o[G]=l);}if(n.extends){const o=Array.isArray(n.extends)?n.extends:[n.extends];delete n.extends;for(const s of o.reverse()){const c=Be(s,l,new Set(i),t),f={...c,...n,compilerOptions:{...c.compilerOptions,...n.compilerOptions}};c.watchOptions&&(f.watchOptions={...c.watchOptions,...n.watchOptions}),n=f;}}if(n.compilerOptions){const{compilerOptions:o}=n,s=["baseUrl","rootDir"];for(const f of s){const w=o[f];if(w){const A=p$1.resolve(l,w),k=M(p$1.relative(l,A));o[f]=k;}}const{outDir:c}=o;c&&(Array.isArray(n.exclude)||(n.exclude=[]),n.exclude.includes(c)||n.exclude.push(c),o.outDir=M(c));}else n.compilerOptions={};if(n.files&&(n.files=n.files.map(M)),n.include&&(n.include=n.include.map(E)),n.watchOptions){const{watchOptions:o}=n;o.excludeDirectories&&(o.excludeDirectories=o.excludeDirectories.map(s=>E(p$1.resolve(l,s))));}return n},"_parseTsconfig"),se=u((e,t=new Map)=>le(p$1.resolve(e),t),"parseTsconfig"),_e=u((e=process.cwd(),t="tsconfig.json",i=new Map)=>{const n=K(E(e),t,i);if(!n)return null;const l=se(n,i);return {path:n,config:l}},"getTsconfig"),Ee=/\*/g,oe=u((e,t)=>{const i=e.match(Ee);if(i&&i.length>1)throw new Error(t)},"assertStarCount"),Le=u(e=>{if(e.includes("*")){const[t,i]=e.split("*");return {prefix:t,suffix:i}}return e},"parsePattern"),Ue=u(({prefix:e,suffix:t},i)=>i.startsWith(e)&&i.endsWith(t),"isPatternMatch"),ye=u((e,t,i)=>Object.entries(e).map(([n,l])=>(oe(n,`Pattern '${n}' can have at most one '*' character.`),{pattern:Le(n),substitutions:l.map(o=>{if(oe(o,`Substitution '${o}' in pattern '${n}' can have at most one '*' character.`),!t&&!J.test(o))throw new Error("Non-relative paths are not allowed when 'baseUrl' is not set. Did you forget a leading './'?");return p$1.resolve(i,o)})})),"parsePaths");u(e=>{const{compilerOptions:t}=e.config;if(!t)return null;const{baseUrl:i,paths:n}=t;if(!i&&!n)return null;const l=G in t&&t[G],o=p$1.resolve(p$1.dirname(e.path),i||l||"."),s=n?ye(n,i,o):[];return c=>{if(J.test(c))return [];const f=[];for(const O of s){if(O.pattern===c)return O.substitutions.map(E);typeof O.pattern!="string"&&f.push(O);}let w,A=-1;for(const O of f)Ue(O.pattern,c)&&O.pattern.prefix.length>A&&(A=O.pattern.prefix.length,w=O);if(!w)return i?[E(p$1.join(o,c))]:[];const k=c.slice(w.pattern.prefix.length,c.length-w.pattern.suffix.length);return w.substitutions.map(O=>E(O.replace("*",k)))}},"createPathsMatcher");const re=u(e=>{let t="";for(let i=0;i<e.length;i+=1){const n=e[i],l=n.toUpperCase();t+=n===l?n.toLowerCase():l;}return t},"s"),Ne=65,xe=97,Ie=u(()=>Math.floor(Math.random()*26),"m"),Pe=u(e=>Array.from({length:e},()=>String.fromCodePoint(Ie()+(Math.random()>.5?Ne:xe))).join(""),"S"),De=u((e=require$$0)=>{const t=process.execPath;if(e.existsSync(t))return !e.existsSync(re(t));const i=`/${Pe(10)}`;e.writeFileSync(i,"");const n=!e.existsSync(re(i));return e.unlinkSync(i),n},"l"),{join:V}=p$1.posix,X={ts:[".ts",".tsx",".d.ts"],cts:[".cts",".d.cts"],mts:[".mts",".d.mts"]},Ve=u(e=>{const t=[...X.ts],i=[...X.cts],n=[...X.mts];return e!=null&&e.allowJs&&(t.push(".js",".jsx"),i.push(".cjs"),n.push(".mjs")),[...t,...i,...n]},"getSupportedExtensions"),Se=u(e=>{const t=[];if(!e)return t;const{outDir:i,declarationDir:n}=e;return i&&t.push(i),n&&t.push(n),t},"getDefaultExcludeSpec"),ue=u(e=>e.replaceAll(/[.*+?^${}()|[\]\\]/g,"\\$&"),"escapeForRegexp"),de=["node_modules","bower_components","jspm_packages"],Y=`(?!(${de.join("|")})(/|$))`,We=/(?:^|\/)[^.*?]+$/,fe="**/*",S="[^/]",Z="[^./]",ce=process.platform==="win32";u(({config:e,path:t},i=De())=>{if("extends"in e)throw new Error("tsconfig#extends must be resolved. Use getTsconfig or parseTsconfig to resolve it.");if(!p$1.isAbsolute(t))throw new Error("The tsconfig path must be absolute");ce&&(t=E(t));const n=p$1.dirname(t),{files:l,include:o,exclude:s,compilerOptions:c}=e,f=l==null?void 0:l.map(b=>V(n,b)),w=Ve(c),A=i?"":"i",O=(s||Se(c)).map(b=>{const B=V(n,b),U=ue(B).replaceAll("\\*\\*/","(.+/)?").replaceAll("\\*",`${S}*`).replaceAll("\\?",S);return new RegExp(`^${U}($|/)`,A)}),T=l||o?o:[fe],v=T?T.map(b=>{let B=V(n,b);We.test(B)&&(B=V(B,fe));const U=ue(B).replaceAll("/\\*\\*",`(/${Y}${Z}${S}*)*?`).replaceAll(/(\/)?\\\*/g,(y,r)=>{const g=`(${Z}|(\\.(?!min\\.js$))?)*`;return r?`/${Y}${Z}${g}`:g}).replaceAll(/(\/)?\\\?/g,(y,r)=>{const g=S;return r?`/${Y}${g}`:g});return new RegExp(`^${U}$`,A)}):void 0;return b=>{if(!p$1.isAbsolute(b))throw new Error("filePath must be absolute");if(ce&&(b=E(b)),f!=null&&f.includes(b))return e;if(!(!w.some(B=>b.endsWith(B))||O.some(B=>B.test(b)))&&v&&v.some(B=>B.test(b)))return e}},"createFilesMatcher");
|
|
176
175
|
|
|
177
176
|
const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
|
|
178
177
|
const newLineRegExp = /\r?\n/;
|
|
179
178
|
const errCodeRegExp = /error TS(?<errCode>\d+)/;
|
|
180
179
|
async function makeTscErrorInfo(errInfo) {
|
|
181
|
-
var _a;
|
|
182
180
|
const [errFilePathPos = "", ...errMsgRawArr] = errInfo.split(":");
|
|
183
181
|
if (!errFilePathPos || errMsgRawArr.length === 0 || errMsgRawArr.join("").length === 0) {
|
|
184
182
|
return ["unknown filepath", null];
|
|
@@ -196,7 +194,7 @@ async function makeTscErrorInfo(errInfo) {
|
|
|
196
194
|
if (!execArr) {
|
|
197
195
|
return [errFilePath, null];
|
|
198
196
|
}
|
|
199
|
-
const errCodeStr =
|
|
197
|
+
const errCodeStr = execArr.groups?.errCode ?? "";
|
|
200
198
|
if (!errCodeStr) {
|
|
201
199
|
return [errFilePath, null];
|
|
202
200
|
}
|
|
@@ -217,7 +215,7 @@ async function makeTscErrorInfo(errInfo) {
|
|
|
217
215
|
async function getTsconfig(root, config) {
|
|
218
216
|
const configName = config.tsconfig ? basename(config.tsconfig) : void 0;
|
|
219
217
|
const configSearchPath = config.tsconfig ? dirname(resolve(root, config.tsconfig)) : root;
|
|
220
|
-
const tsconfig =
|
|
218
|
+
const tsconfig = _e(configSearchPath, configName);
|
|
221
219
|
if (!tsconfig) {
|
|
222
220
|
throw new Error("no tsconfig.json found");
|
|
223
221
|
}
|
|
@@ -257,14 +255,13 @@ ${next}`;
|
|
|
257
255
|
}, []).map((errInfoLine) => makeTscErrorInfo(errInfoLine))
|
|
258
256
|
);
|
|
259
257
|
infos.forEach(([errFilePath, errInfo]) => {
|
|
260
|
-
var _a;
|
|
261
258
|
if (!errInfo) {
|
|
262
259
|
return;
|
|
263
260
|
}
|
|
264
261
|
if (!rawErrsMap.has(errFilePath)) {
|
|
265
262
|
rawErrsMap.set(errFilePath, [errInfo]);
|
|
266
263
|
} else {
|
|
267
|
-
|
|
264
|
+
rawErrsMap.get(errFilePath)?.push(errInfo);
|
|
268
265
|
}
|
|
269
266
|
});
|
|
270
267
|
return rawErrsMap;
|
|
@@ -621,7 +618,6 @@ async function collectTests(ctx, filepath) {
|
|
|
621
618
|
file.file = file;
|
|
622
619
|
const definitions = [];
|
|
623
620
|
const getName = (callee) => {
|
|
624
|
-
var _a, _b, _c;
|
|
625
621
|
if (!callee) {
|
|
626
622
|
return null;
|
|
627
623
|
}
|
|
@@ -629,16 +625,15 @@ async function collectTests(ctx, filepath) {
|
|
|
629
625
|
return callee.name;
|
|
630
626
|
}
|
|
631
627
|
if (callee.type === "MemberExpression") {
|
|
632
|
-
if (
|
|
628
|
+
if (callee.object?.name?.startsWith("__vite_ssr_")) {
|
|
633
629
|
return getName(callee.property);
|
|
634
630
|
}
|
|
635
|
-
return getName(
|
|
631
|
+
return getName(callee.object?.property);
|
|
636
632
|
}
|
|
637
633
|
return null;
|
|
638
634
|
};
|
|
639
635
|
ancestor(ast, {
|
|
640
636
|
CallExpression(node) {
|
|
641
|
-
var _a;
|
|
642
637
|
const { callee } = node;
|
|
643
638
|
const name = getName(callee);
|
|
644
639
|
if (!name) {
|
|
@@ -650,7 +645,7 @@ async function collectTests(ctx, filepath) {
|
|
|
650
645
|
const {
|
|
651
646
|
arguments: [{ value: message }]
|
|
652
647
|
} = node;
|
|
653
|
-
const property =
|
|
648
|
+
const property = callee?.property?.name;
|
|
654
649
|
let mode = !property || property === name ? "run" : property;
|
|
655
650
|
if (!["run", "skip", "todo", "only", "skipIf", "runIf"].includes(mode)) {
|
|
656
651
|
throw new Error(
|
|
@@ -800,19 +795,17 @@ class Typechecker {
|
|
|
800
795
|
return tests;
|
|
801
796
|
}
|
|
802
797
|
markPassed(file) {
|
|
803
|
-
|
|
804
|
-
if (!((_a = file.result) == null ? void 0 : _a.state)) {
|
|
798
|
+
if (!file.result?.state) {
|
|
805
799
|
file.result = {
|
|
806
800
|
state: "pass"
|
|
807
801
|
};
|
|
808
802
|
}
|
|
809
803
|
const markTasks = (tasks) => {
|
|
810
|
-
var _a2;
|
|
811
804
|
for (const task of tasks) {
|
|
812
805
|
if ("tasks" in task) {
|
|
813
806
|
markTasks(task.tasks);
|
|
814
807
|
}
|
|
815
|
-
if (!
|
|
808
|
+
if (!task.result?.state && task.mode === "run") {
|
|
816
809
|
task.result = {
|
|
817
810
|
state: "pass"
|
|
818
811
|
};
|
|
@@ -853,7 +846,6 @@ class Typechecker {
|
|
|
853
846
|
}
|
|
854
847
|
};
|
|
855
848
|
errors.forEach(({ error, originalError }) => {
|
|
856
|
-
var _a;
|
|
857
849
|
const processedPos = traceMap ? generatedPositionFor(traceMap, {
|
|
858
850
|
line: originalError.line,
|
|
859
851
|
column: originalError.column,
|
|
@@ -867,7 +859,7 @@ class Typechecker {
|
|
|
867
859
|
);
|
|
868
860
|
const suite = definition ? definition.task : file;
|
|
869
861
|
const state = suite.mode === "run" || suite.mode === "only" ? "fail" : suite.mode;
|
|
870
|
-
const errors2 =
|
|
862
|
+
const errors2 = suite.result?.errors || [];
|
|
871
863
|
suite.result = {
|
|
872
864
|
state,
|
|
873
865
|
errors: errors2
|
|
@@ -937,9 +929,8 @@ class Typechecker {
|
|
|
937
929
|
}
|
|
938
930
|
}
|
|
939
931
|
async stop() {
|
|
940
|
-
var _a;
|
|
941
932
|
await this.clear();
|
|
942
|
-
|
|
933
|
+
this.process?.kill();
|
|
943
934
|
this.process = void 0;
|
|
944
935
|
}
|
|
945
936
|
async ensurePackageInstalled(ctx, checker) {
|
|
@@ -956,14 +947,12 @@ class Typechecker {
|
|
|
956
947
|
this.allowJs = typecheck.allowJs || config.allowJs || false;
|
|
957
948
|
}
|
|
958
949
|
getExitCode() {
|
|
959
|
-
|
|
960
|
-
return ((_a = this.process) == null ? void 0 : _a.exitCode) != null && this.process.exitCode;
|
|
950
|
+
return this.process?.exitCode != null && this.process.exitCode;
|
|
961
951
|
}
|
|
962
952
|
getOutput() {
|
|
963
953
|
return this._output;
|
|
964
954
|
}
|
|
965
955
|
async start() {
|
|
966
|
-
var _a, _b, _c;
|
|
967
956
|
if (this.process) {
|
|
968
957
|
return;
|
|
969
958
|
}
|
|
@@ -986,16 +975,15 @@ class Typechecker {
|
|
|
986
975
|
reject: false
|
|
987
976
|
});
|
|
988
977
|
this.process = child;
|
|
989
|
-
await
|
|
978
|
+
await this._onParseStart?.();
|
|
990
979
|
let rerunTriggered = false;
|
|
991
|
-
|
|
992
|
-
var _a2;
|
|
980
|
+
child.stdout?.on("data", (chunk) => {
|
|
993
981
|
this._output += chunk;
|
|
994
982
|
if (!watch) {
|
|
995
983
|
return;
|
|
996
984
|
}
|
|
997
985
|
if (this._output.includes("File change detected") && !rerunTriggered) {
|
|
998
|
-
|
|
986
|
+
this._onWatcherRerun?.();
|
|
999
987
|
this._startTime = performance.now();
|
|
1000
988
|
this._result.sourceErrors = [];
|
|
1001
989
|
this._result.files = [];
|
|
@@ -1005,9 +993,8 @@ class Typechecker {
|
|
|
1005
993
|
if (/Found \w+ errors*. Watching for/.test(this._output)) {
|
|
1006
994
|
rerunTriggered = false;
|
|
1007
995
|
this.prepareResults(this._output).then((result) => {
|
|
1008
|
-
var _a3;
|
|
1009
996
|
this._result = result;
|
|
1010
|
-
|
|
997
|
+
this._onParseEnd?.(result);
|
|
1011
998
|
});
|
|
1012
999
|
this._output = "";
|
|
1013
1000
|
}
|
|
@@ -1015,7 +1002,7 @@ class Typechecker {
|
|
|
1015
1002
|
if (!watch) {
|
|
1016
1003
|
await child;
|
|
1017
1004
|
this._result = await this.prepareResults(this._output);
|
|
1018
|
-
await
|
|
1005
|
+
await this._onParseEnd?.(this._result);
|
|
1019
1006
|
}
|
|
1020
1007
|
}
|
|
1021
1008
|
getResult() {
|
|
@@ -1061,8 +1048,7 @@ class BaseReporter {
|
|
|
1061
1048
|
_timeStart = /* @__PURE__ */ new Date();
|
|
1062
1049
|
_offUnhandledRejection;
|
|
1063
1050
|
constructor(options = {}) {
|
|
1064
|
-
|
|
1065
|
-
this.isTTY = options.isTTY ?? ((isNode || isDeno) && ((_a = process.stdout) == null ? void 0 : _a.isTTY) && !isCI);
|
|
1051
|
+
this.isTTY = options.isTTY ?? ((isNode || isDeno) && process.stdout?.isTTY && !isCI);
|
|
1066
1052
|
this.registerUnhandledRejection();
|
|
1067
1053
|
}
|
|
1068
1054
|
get mode() {
|
|
@@ -1071,8 +1057,7 @@ class BaseReporter {
|
|
|
1071
1057
|
onInit(ctx) {
|
|
1072
1058
|
this.ctx = ctx;
|
|
1073
1059
|
ctx.onClose(() => {
|
|
1074
|
-
|
|
1075
|
-
(_a = this._offUnhandledRejection) == null ? void 0 : _a.call(this);
|
|
1060
|
+
this._offUnhandledRejection?.();
|
|
1076
1061
|
});
|
|
1077
1062
|
ctx.logger.printBanner();
|
|
1078
1063
|
this.start = performance.now();
|
|
@@ -1101,16 +1086,12 @@ class BaseReporter {
|
|
|
1101
1086
|
}
|
|
1102
1087
|
}
|
|
1103
1088
|
printTask(task) {
|
|
1104
|
-
|
|
1105
|
-
if (!("filepath" in task) || !((_a = task.result) == null ? void 0 : _a.state) || ((_b = task.result) == null ? void 0 : _b.state) === "run") {
|
|
1089
|
+
if (!("filepath" in task) || !task.result?.state || task.result?.state === "run") {
|
|
1106
1090
|
return;
|
|
1107
1091
|
}
|
|
1108
1092
|
const logger = this.ctx.logger;
|
|
1109
1093
|
const tests = getTests(task);
|
|
1110
|
-
const failed = tests.filter((t) =>
|
|
1111
|
-
var _a2;
|
|
1112
|
-
return ((_a2 = t.result) == null ? void 0 : _a2.state) === "fail";
|
|
1113
|
-
});
|
|
1094
|
+
const failed = tests.filter((t) => t.result?.state === "fail");
|
|
1114
1095
|
const skipped = tests.filter(
|
|
1115
1096
|
(t) => t.mode === "skip" || t.mode === "todo"
|
|
1116
1097
|
);
|
|
@@ -1139,8 +1120,8 @@ class BaseReporter {
|
|
|
1139
1120
|
logger.log(title);
|
|
1140
1121
|
for (const test of failed) {
|
|
1141
1122
|
logger.log(c.red(` ${taskFail} ${getTestName(test, c.dim(" > "))}`));
|
|
1142
|
-
|
|
1143
|
-
logger.log(c.red(` ${F_RIGHT} ${e
|
|
1123
|
+
test.result?.errors?.forEach((e) => {
|
|
1124
|
+
logger.log(c.red(` ${F_RIGHT} ${e?.message}`));
|
|
1144
1125
|
});
|
|
1145
1126
|
}
|
|
1146
1127
|
}
|
|
@@ -1173,7 +1154,6 @@ class BaseReporter {
|
|
|
1173
1154
|
];
|
|
1174
1155
|
this.ctx.logger.logUpdate(BADGE_PADDING + LAST_RUN_TEXTS[0]);
|
|
1175
1156
|
this._lastRunTimeout = 0;
|
|
1176
|
-
const { setInterval } = getSafeTimers();
|
|
1177
1157
|
this._lastRunTimer = setInterval(() => {
|
|
1178
1158
|
this._lastRunTimeout += 1;
|
|
1179
1159
|
if (this._lastRunTimeout >= LAST_RUN_TEXTS.length) {
|
|
@@ -1187,7 +1167,6 @@ class BaseReporter {
|
|
|
1187
1167
|
}
|
|
1188
1168
|
}
|
|
1189
1169
|
resetLastRunLog() {
|
|
1190
|
-
const { clearInterval } = getSafeTimers();
|
|
1191
1170
|
clearInterval(this._lastRunTimer);
|
|
1192
1171
|
this._lastRunTimer = void 0;
|
|
1193
1172
|
this.ctx.logger.logUpdate.clear();
|
|
@@ -1243,14 +1222,13 @@ ${PROJECT_FILTER}${FILENAME_PATTERN}${TESTNAME_PATTERN}`
|
|
|
1243
1222
|
this.start = performance.now();
|
|
1244
1223
|
}
|
|
1245
1224
|
onUserConsoleLog(log) {
|
|
1246
|
-
var _a;
|
|
1247
1225
|
if (!this.shouldLog(log)) {
|
|
1248
1226
|
return;
|
|
1249
1227
|
}
|
|
1250
1228
|
const task = log.taskId ? this.ctx.state.idMap.get(log.taskId) : void 0;
|
|
1251
1229
|
const header = c.gray(
|
|
1252
1230
|
log.type + c.dim(
|
|
1253
|
-
` | ${task ? getFullName(task, c.dim(" > ")) : log.taskId !==
|
|
1231
|
+
` | ${task ? getFullName(task, c.dim(" > ")) : log.taskId !== "__vitest__unknown_test__" ? log.taskId : "unknown test"}`
|
|
1254
1232
|
)
|
|
1255
1233
|
);
|
|
1256
1234
|
const output = log.type === "stdout" ? this.ctx.logger.outputStream : this.ctx.logger.errorStream;
|
|
@@ -1262,7 +1240,7 @@ ${log.content}`);
|
|
|
1262
1240
|
write("\n");
|
|
1263
1241
|
}
|
|
1264
1242
|
const project = log.taskId ? this.ctx.getProjectByTaskId(log.taskId) : this.ctx.getCoreWorkspaceProject();
|
|
1265
|
-
const stack = log.browser ?
|
|
1243
|
+
const stack = log.browser ? project.browser?.parseStacktrace(log.origin) || [] : parseStacktrace(log.origin);
|
|
1266
1244
|
const highlight = task ? stack.find((i) => i.file === task.file.filepath) : null;
|
|
1267
1245
|
for (const frame of stack) {
|
|
1268
1246
|
const color = frame === highlight ? c.cyan : c.gray;
|
|
@@ -1281,11 +1259,10 @@ ${log.content}`);
|
|
|
1281
1259
|
write("\n");
|
|
1282
1260
|
}
|
|
1283
1261
|
shouldLog(log) {
|
|
1284
|
-
var _a, _b;
|
|
1285
1262
|
if (this.ctx.config.silent) {
|
|
1286
1263
|
return false;
|
|
1287
1264
|
}
|
|
1288
|
-
const shouldLog =
|
|
1265
|
+
const shouldLog = this.ctx.config.onConsoleLog?.(log.content, log.type);
|
|
1289
1266
|
if (shouldLog === false) {
|
|
1290
1267
|
return shouldLog;
|
|
1291
1268
|
}
|
|
@@ -1325,10 +1302,7 @@ ${log.content}`);
|
|
|
1325
1302
|
0
|
|
1326
1303
|
);
|
|
1327
1304
|
const testsTime = files.reduce(
|
|
1328
|
-
(acc, test) =>
|
|
1329
|
-
var _a;
|
|
1330
|
-
return acc + Math.max(0, ((_a = test.result) == null ? void 0 : _a.duration) || 0);
|
|
1331
|
-
},
|
|
1305
|
+
(acc, test) => acc + Math.max(0, test.result?.duration || 0),
|
|
1332
1306
|
0
|
|
1333
1307
|
);
|
|
1334
1308
|
const transformTime = this.ctx.projects.flatMap((w) => w.vitenode.getTotalDuration()).reduce((a, b) => a + b, 0);
|
|
@@ -1366,10 +1340,7 @@ ${log.content}`);
|
|
|
1366
1340
|
logger.log(padTitle("Tests"), getStateString(tests));
|
|
1367
1341
|
if (this.ctx.projects.some((c2) => c2.config.typecheck.enabled)) {
|
|
1368
1342
|
const failed = tests.filter(
|
|
1369
|
-
(t) =>
|
|
1370
|
-
var _a, _b, _c;
|
|
1371
|
-
return ((_a = t.meta) == null ? void 0 : _a.typecheck) && ((_c = (_b = t.result) == null ? void 0 : _b.errors) == null ? void 0 : _c.length);
|
|
1372
|
-
}
|
|
1343
|
+
(t) => t.meta?.typecheck && t.result?.errors?.length
|
|
1373
1344
|
);
|
|
1374
1345
|
logger.log(
|
|
1375
1346
|
padTitle("Type Errors"),
|
|
@@ -1392,10 +1363,7 @@ ${log.content}`);
|
|
|
1392
1363
|
testsTime
|
|
1393
1364
|
)}, environment ${time(environmentTime)}, prepare ${time(prepareTime)}`;
|
|
1394
1365
|
const typecheck = this.ctx.projects.reduce(
|
|
1395
|
-
(acc, c2) =>
|
|
1396
|
-
var _a;
|
|
1397
|
-
return acc + (((_a = c2.typechecker) == null ? void 0 : _a.getResult().time) || 0);
|
|
1398
|
-
},
|
|
1366
|
+
(acc, c2) => acc + (c2.typechecker?.getResult().time || 0),
|
|
1399
1367
|
0
|
|
1400
1368
|
);
|
|
1401
1369
|
if (typecheck) {
|
|
@@ -1412,14 +1380,8 @@ ${log.content}`);
|
|
|
1412
1380
|
const logger = this.ctx.logger;
|
|
1413
1381
|
const suites = getSuites(files);
|
|
1414
1382
|
const tests = getTests(files);
|
|
1415
|
-
const failedSuites = suites.filter((i) =>
|
|
1416
|
-
|
|
1417
|
-
return (_a = i.result) == null ? void 0 : _a.errors;
|
|
1418
|
-
});
|
|
1419
|
-
const failedTests = tests.filter((i) => {
|
|
1420
|
-
var _a;
|
|
1421
|
-
return ((_a = i.result) == null ? void 0 : _a.state) === "fail";
|
|
1422
|
-
});
|
|
1383
|
+
const failedSuites = suites.filter((i) => i.result?.errors);
|
|
1384
|
+
const failedTests = tests.filter((i) => i.result?.state === "fail");
|
|
1423
1385
|
const failedTotal = countTestErrors(failedSuites) + countTestErrors(failedTests);
|
|
1424
1386
|
let current = 1;
|
|
1425
1387
|
const errorDivider = () => logger.error(
|
|
@@ -1455,10 +1417,7 @@ ${log.content}`);
|
|
|
1455
1417
|
reportBenchmarkSummary(files) {
|
|
1456
1418
|
const logger = this.ctx.logger;
|
|
1457
1419
|
const benches = getTests(files);
|
|
1458
|
-
const topBenches = benches.filter((i) =>
|
|
1459
|
-
var _a, _b;
|
|
1460
|
-
return ((_b = (_a = i.result) == null ? void 0 : _a.benchmark) == null ? void 0 : _b.rank) === 1;
|
|
1461
|
-
});
|
|
1420
|
+
const topBenches = benches.filter((i) => i.result?.benchmark?.rank === 1);
|
|
1462
1421
|
logger.log(
|
|
1463
1422
|
`
|
|
1464
1423
|
${c.cyan(c.inverse(c.bold(" BENCH ")))} ${c.cyan("Summary")}
|
|
@@ -1471,10 +1430,7 @@ ${c.cyan(c.inverse(c.bold(" BENCH ")))} ${c.cyan("Summary")}
|
|
|
1471
1430
|
}
|
|
1472
1431
|
const groupName = getFullName(group, c.dim(" > "));
|
|
1473
1432
|
logger.log(` ${bench.name}${c.dim(` - ${groupName}`)}`);
|
|
1474
|
-
const siblings = group.tasks.filter((i) =>
|
|
1475
|
-
var _a;
|
|
1476
|
-
return i.meta.benchmark && ((_a = i.result) == null ? void 0 : _a.benchmark) && i !== bench;
|
|
1477
|
-
}).sort((a, b) => a.result.benchmark.rank - b.result.benchmark.rank);
|
|
1433
|
+
const siblings = group.tasks.filter((i) => i.meta.benchmark && i.result?.benchmark && i !== bench).sort((a, b) => a.result.benchmark.rank - b.result.benchmark.rank);
|
|
1478
1434
|
if (siblings.length === 0) {
|
|
1479
1435
|
logger.log("");
|
|
1480
1436
|
continue;
|
|
@@ -1489,18 +1445,16 @@ ${c.cyan(c.inverse(c.bold(" BENCH ")))} ${c.cyan("Summary")}
|
|
|
1489
1445
|
}
|
|
1490
1446
|
}
|
|
1491
1447
|
printTaskErrors(tasks, errorDivider) {
|
|
1492
|
-
var _a, _b, _c;
|
|
1493
1448
|
const errorsQueue = [];
|
|
1494
1449
|
for (const task of tasks) {
|
|
1495
|
-
|
|
1496
|
-
const errorItem =
|
|
1497
|
-
|
|
1498
|
-
const hasStr = ((_a2 = i[0]) == null ? void 0 : _a2.stackStr) === error.stackStr;
|
|
1450
|
+
task.result?.errors?.forEach((error) => {
|
|
1451
|
+
const errorItem = error?.stackStr && errorsQueue.find((i) => {
|
|
1452
|
+
const hasStr = i[0]?.stackStr === error.stackStr;
|
|
1499
1453
|
if (!hasStr) {
|
|
1500
1454
|
return false;
|
|
1501
1455
|
}
|
|
1502
|
-
const currentProjectName =
|
|
1503
|
-
const projectName =
|
|
1456
|
+
const currentProjectName = task?.projectName || task.file?.projectName || "";
|
|
1457
|
+
const projectName = i[1][0]?.projectName || i[1][0].file?.projectName || "";
|
|
1504
1458
|
return projectName === currentProjectName;
|
|
1505
1459
|
});
|
|
1506
1460
|
if (errorItem) {
|
|
@@ -1512,8 +1466,8 @@ ${c.cyan(c.inverse(c.bold(" BENCH ")))} ${c.cyan("Summary")}
|
|
|
1512
1466
|
}
|
|
1513
1467
|
for (const [error, tasks2] of errorsQueue) {
|
|
1514
1468
|
for (const task of tasks2) {
|
|
1515
|
-
const filepath =
|
|
1516
|
-
const projectName =
|
|
1469
|
+
const filepath = task?.filepath || "";
|
|
1470
|
+
const projectName = task?.projectName || task.file?.projectName || "";
|
|
1517
1471
|
let name = getFullName(task, c.dim(" > "));
|
|
1518
1472
|
if (filepath) {
|
|
1519
1473
|
name = `${name} ${c.dim(`[ ${this.relative(filepath)} ]`)}`;
|
|
@@ -1524,13 +1478,7 @@ ${c.cyan(c.inverse(c.bold(" BENCH ")))} ${c.cyan("Summary")}
|
|
|
1524
1478
|
)}${name}`
|
|
1525
1479
|
);
|
|
1526
1480
|
}
|
|
1527
|
-
const screenshots = tasks2.filter((t) =>
|
|
1528
|
-
var _a2;
|
|
1529
|
-
return (_a2 = t.meta) == null ? void 0 : _a2.failScreenshotPath;
|
|
1530
|
-
}).map((t) => {
|
|
1531
|
-
var _a2;
|
|
1532
|
-
return (_a2 = t.meta) == null ? void 0 : _a2.failScreenshotPath;
|
|
1533
|
-
});
|
|
1481
|
+
const screenshots = tasks2.filter((t) => t.meta?.failScreenshotPath).map((t) => t.meta?.failScreenshotPath);
|
|
1534
1482
|
const project = this.ctx.getProjectByTaskId(tasks2[0].id);
|
|
1535
1483
|
this.ctx.logger.printError(error, {
|
|
1536
1484
|
project,
|
|
@@ -2480,8 +2428,7 @@ function formatNumber$1(number) {
|
|
|
2480
2428
|
return res[0].replace(/(?=(?:\d{3})+$)\B/g, ",") + (res[1] ? `.${res[1]}` : "");
|
|
2481
2429
|
}
|
|
2482
2430
|
function renderHookState(task, hookName, level = 0) {
|
|
2483
|
-
|
|
2484
|
-
const state = (_b = (_a = task.result) == null ? void 0 : _a.hooks) == null ? void 0 : _b[hookName];
|
|
2431
|
+
const state = task.result?.hooks?.[hookName];
|
|
2485
2432
|
if (state && state === "run") {
|
|
2486
2433
|
return `${" ".repeat(level)} ${getHookStateSymbol(task, hookName)} ${c.dim(
|
|
2487
2434
|
`[ ${hookName} ]`
|
|
@@ -2499,15 +2446,11 @@ function renderBenchmarkItems$1(result) {
|
|
|
2499
2446
|
];
|
|
2500
2447
|
}
|
|
2501
2448
|
function renderBenchmark$1(task, tasks) {
|
|
2502
|
-
|
|
2503
|
-
const result = (_a = task.result) == null ? void 0 : _a.benchmark;
|
|
2449
|
+
const result = task.result?.benchmark;
|
|
2504
2450
|
if (!result) {
|
|
2505
2451
|
return task.name;
|
|
2506
2452
|
}
|
|
2507
|
-
const benches = tasks.map((i) =>
|
|
2508
|
-
var _a2, _b;
|
|
2509
|
-
return ((_a2 = i.meta) == null ? void 0 : _a2.benchmark) ? (_b = i.result) == null ? void 0 : _b.benchmark : void 0;
|
|
2510
|
-
}).filter(notNullish);
|
|
2453
|
+
const benches = tasks.map((i) => i.meta?.benchmark ? i.result?.benchmark : void 0).filter(notNullish);
|
|
2511
2454
|
const allItems = benches.map(renderBenchmarkItems$1);
|
|
2512
2455
|
const items = renderBenchmarkItems$1(result);
|
|
2513
2456
|
const padded = items.map((i, idx) => {
|
|
@@ -2526,7 +2469,6 @@ function renderBenchmark$1(task, tasks) {
|
|
|
2526
2469
|
].join("");
|
|
2527
2470
|
}
|
|
2528
2471
|
function renderTree$1(tasks, options, level = 0, maxRows) {
|
|
2529
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
2530
2472
|
const output = [];
|
|
2531
2473
|
let currentRowCount = 0;
|
|
2532
2474
|
for (const task of [...tasks].reverse()) {
|
|
@@ -2536,7 +2478,7 @@ function renderTree$1(tasks, options, level = 0, maxRows) {
|
|
|
2536
2478
|
if (level === 0 && task.type === "suite" && "projectName" in task) {
|
|
2537
2479
|
prefix += formatProjectName(task.projectName);
|
|
2538
2480
|
}
|
|
2539
|
-
if (task.type === "test" &&
|
|
2481
|
+
if (task.type === "test" && task.result?.retryCount && task.result.retryCount > 0) {
|
|
2540
2482
|
suffix += c.yellow(` (retry x${task.result.retryCount})`);
|
|
2541
2483
|
}
|
|
2542
2484
|
if (task.type === "suite") {
|
|
@@ -2546,17 +2488,17 @@ function renderTree$1(tasks, options, level = 0, maxRows) {
|
|
|
2546
2488
|
if (task.mode === "skip" || task.mode === "todo") {
|
|
2547
2489
|
suffix += ` ${c.dim(c.gray("[skipped]"))}`;
|
|
2548
2490
|
}
|
|
2549
|
-
if (task.type === "test" &&
|
|
2491
|
+
if (task.type === "test" && task.result?.repeatCount && task.result.repeatCount > 0) {
|
|
2550
2492
|
suffix += c.yellow(` (repeat x${task.result.repeatCount})`);
|
|
2551
2493
|
}
|
|
2552
|
-
if (
|
|
2494
|
+
if (task.result?.duration != null) {
|
|
2553
2495
|
if (task.result.duration > options.slowTestThreshold) {
|
|
2554
2496
|
suffix += c.yellow(
|
|
2555
2497
|
` ${Math.round(task.result.duration)}${c.dim("ms")}`
|
|
2556
2498
|
);
|
|
2557
2499
|
}
|
|
2558
2500
|
}
|
|
2559
|
-
if (options.showHeap &&
|
|
2501
|
+
if (options.showHeap && task.result?.heap != null) {
|
|
2560
2502
|
suffix += c.magenta(
|
|
2561
2503
|
` ${Math.floor(task.result.heap / 1024 / 1024)} MB heap used`
|
|
2562
2504
|
);
|
|
@@ -2566,9 +2508,9 @@ function renderTree$1(tasks, options, level = 0, maxRows) {
|
|
|
2566
2508
|
name = formatFilepath$1(name);
|
|
2567
2509
|
}
|
|
2568
2510
|
const padding = " ".repeat(level);
|
|
2569
|
-
const body =
|
|
2511
|
+
const body = task.meta?.benchmark ? renderBenchmark$1(task, tasks) : name;
|
|
2570
2512
|
taskOutput.push(padding + prefix + body + suffix);
|
|
2571
|
-
if (
|
|
2513
|
+
if (task.result?.state !== "pass" && outputMap$1.get(task) != null) {
|
|
2572
2514
|
let data = outputMap$1.get(task);
|
|
2573
2515
|
if (typeof data === "string") {
|
|
2574
2516
|
data = stripAnsi(data.trim().split("\n").filter(Boolean).pop());
|
|
@@ -2584,7 +2526,7 @@ function renderTree$1(tasks, options, level = 0, maxRows) {
|
|
|
2584
2526
|
taskOutput.push(renderHookState(task, "beforeAll", level + 1));
|
|
2585
2527
|
taskOutput.push(renderHookState(task, "beforeEach", level + 1));
|
|
2586
2528
|
if (task.type === "suite" && task.tasks.length > 0) {
|
|
2587
|
-
if (
|
|
2529
|
+
if (task.result?.state === "fail" || task.result?.state === "run" || options.renderSucceed) {
|
|
2588
2530
|
if (options.logger.ctx.config.hideSkippedTests) {
|
|
2589
2531
|
const filteredTasks = task.tasks.filter(
|
|
2590
2532
|
(t) => t.mode !== "skip" && t.mode !== "todo"
|
|
@@ -2716,8 +2658,7 @@ class DefaultReporter extends BaseReporter {
|
|
|
2716
2658
|
}
|
|
2717
2659
|
}
|
|
2718
2660
|
onFinished(files = this.ctx.state.getFiles(), errors = this.ctx.state.getUnhandledErrors()) {
|
|
2719
|
-
|
|
2720
|
-
(_a = this.renderer) == null ? void 0 : _a.update([
|
|
2661
|
+
this.renderer?.update([
|
|
2721
2662
|
...this.failedUnwatchedFiles,
|
|
2722
2663
|
...files
|
|
2723
2664
|
]);
|
|
@@ -2730,8 +2671,7 @@ class DefaultReporter extends BaseReporter {
|
|
|
2730
2671
|
await super.onWatcherStart(files, errors);
|
|
2731
2672
|
}
|
|
2732
2673
|
stopListRender() {
|
|
2733
|
-
|
|
2734
|
-
(_a = this.renderer) == null ? void 0 : _a.stop();
|
|
2674
|
+
this.renderer?.stop();
|
|
2735
2675
|
this.renderer = void 0;
|
|
2736
2676
|
}
|
|
2737
2677
|
async onWatcherRerun(files, trigger) {
|
|
@@ -2739,11 +2679,10 @@ class DefaultReporter extends BaseReporter {
|
|
|
2739
2679
|
await super.onWatcherRerun(files, trigger);
|
|
2740
2680
|
}
|
|
2741
2681
|
onUserConsoleLog(log) {
|
|
2742
|
-
var _a;
|
|
2743
2682
|
if (!this.shouldLog(log)) {
|
|
2744
2683
|
return;
|
|
2745
2684
|
}
|
|
2746
|
-
|
|
2685
|
+
this.renderer?.clear();
|
|
2747
2686
|
super.onUserConsoleLog(log);
|
|
2748
2687
|
}
|
|
2749
2688
|
}
|
|
@@ -2753,11 +2692,10 @@ const cross = { char: "x", color: c.red };
|
|
|
2753
2692
|
const pending = { char: "*", color: c.yellow };
|
|
2754
2693
|
const skip = { char: "-", color: (char) => c.dim(c.gray(char)) };
|
|
2755
2694
|
function getIcon(task) {
|
|
2756
|
-
var _a;
|
|
2757
2695
|
if (task.mode === "skip" || task.mode === "todo") {
|
|
2758
2696
|
return skip;
|
|
2759
2697
|
}
|
|
2760
|
-
switch (
|
|
2698
|
+
switch (task.result?.state) {
|
|
2761
2699
|
case "pass":
|
|
2762
2700
|
return check;
|
|
2763
2701
|
case "fail":
|
|
@@ -2867,8 +2805,7 @@ class DotReporter extends BaseReporter {
|
|
|
2867
2805
|
super.onWatcherStart();
|
|
2868
2806
|
}
|
|
2869
2807
|
async stopListRender() {
|
|
2870
|
-
|
|
2871
|
-
(_a = this.renderer) == null ? void 0 : _a.stop();
|
|
2808
|
+
this.renderer?.stop();
|
|
2872
2809
|
this.renderer = void 0;
|
|
2873
2810
|
await new Promise((resolve) => setTimeout(resolve, 10));
|
|
2874
2811
|
}
|
|
@@ -2877,8 +2814,7 @@ class DotReporter extends BaseReporter {
|
|
|
2877
2814
|
super.onWatcherRerun(files, trigger);
|
|
2878
2815
|
}
|
|
2879
2816
|
onUserConsoleLog(log) {
|
|
2880
|
-
|
|
2881
|
-
(_a = this.renderer) == null ? void 0 : _a.clear();
|
|
2817
|
+
this.renderer?.clear();
|
|
2882
2818
|
super.onUserConsoleLog(log);
|
|
2883
2819
|
}
|
|
2884
2820
|
}
|
|
@@ -2903,34 +2839,21 @@ class JsonReporter {
|
|
|
2903
2839
|
this.start = Date.now();
|
|
2904
2840
|
}
|
|
2905
2841
|
async logTasks(files) {
|
|
2906
|
-
var _a, _b, _c, _d;
|
|
2907
2842
|
const suites = getSuites(files);
|
|
2908
2843
|
const numTotalTestSuites = suites.length;
|
|
2909
2844
|
const tests = getTests(files);
|
|
2910
2845
|
const numTotalTests = tests.length;
|
|
2911
|
-
const numFailedTestSuites = suites.filter((s) =>
|
|
2912
|
-
var _a2;
|
|
2913
|
-
return (_a2 = s.result) == null ? void 0 : _a2.errors;
|
|
2914
|
-
}).length;
|
|
2846
|
+
const numFailedTestSuites = suites.filter((s) => s.result?.errors).length;
|
|
2915
2847
|
const numPassedTestSuites = numTotalTestSuites - numFailedTestSuites;
|
|
2916
2848
|
const numPendingTestSuites = suites.filter(
|
|
2917
|
-
(s) =>
|
|
2918
|
-
var _a2;
|
|
2919
|
-
return ((_a2 = s.result) == null ? void 0 : _a2.state) === "run";
|
|
2920
|
-
}
|
|
2849
|
+
(s) => s.result?.state === "run"
|
|
2921
2850
|
).length;
|
|
2922
2851
|
const numFailedTests = tests.filter(
|
|
2923
|
-
(t) =>
|
|
2924
|
-
var _a2;
|
|
2925
|
-
return ((_a2 = t.result) == null ? void 0 : _a2.state) === "fail";
|
|
2926
|
-
}
|
|
2852
|
+
(t) => t.result?.state === "fail"
|
|
2927
2853
|
).length;
|
|
2928
2854
|
const numPassedTests = numTotalTests - numFailedTests;
|
|
2929
2855
|
const numPendingTests = tests.filter(
|
|
2930
|
-
(t) =>
|
|
2931
|
-
var _a2;
|
|
2932
|
-
return ((_a2 = t.result) == null ? void 0 : _a2.state) === "run";
|
|
2933
|
-
}
|
|
2856
|
+
(t) => t.result?.state === "run"
|
|
2934
2857
|
).length;
|
|
2935
2858
|
const numTodoTests = tests.filter((t) => t.mode === "todo").length;
|
|
2936
2859
|
const testResults = [];
|
|
@@ -2938,27 +2861,20 @@ class JsonReporter {
|
|
|
2938
2861
|
for (const file of files) {
|
|
2939
2862
|
const tests2 = getTests([file]);
|
|
2940
2863
|
let startTime = tests2.reduce(
|
|
2941
|
-
(prev, next) =>
|
|
2942
|
-
var _a2;
|
|
2943
|
-
return Math.min(prev, ((_a2 = next.result) == null ? void 0 : _a2.startTime) ?? Number.POSITIVE_INFINITY);
|
|
2944
|
-
},
|
|
2864
|
+
(prev, next) => Math.min(prev, next.result?.startTime ?? Number.POSITIVE_INFINITY),
|
|
2945
2865
|
Number.POSITIVE_INFINITY
|
|
2946
2866
|
);
|
|
2947
2867
|
if (startTime === Number.POSITIVE_INFINITY) {
|
|
2948
2868
|
startTime = this.start;
|
|
2949
2869
|
}
|
|
2950
2870
|
const endTime = tests2.reduce(
|
|
2951
|
-
(prev, next) =>
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
(((_a2 = next.result) == null ? void 0 : _a2.startTime) ?? 0) + (((_b2 = next.result) == null ? void 0 : _b2.duration) ?? 0)
|
|
2956
|
-
);
|
|
2957
|
-
},
|
|
2871
|
+
(prev, next) => Math.max(
|
|
2872
|
+
prev,
|
|
2873
|
+
(next.result?.startTime ?? 0) + (next.result?.duration ?? 0)
|
|
2874
|
+
),
|
|
2958
2875
|
startTime
|
|
2959
2876
|
);
|
|
2960
2877
|
const assertionResults = tests2.map((t) => {
|
|
2961
|
-
var _a2, _b2, _c2, _d2;
|
|
2962
2878
|
const ancestorTitles = [];
|
|
2963
2879
|
let iter = t.suite;
|
|
2964
2880
|
while (iter) {
|
|
@@ -2969,32 +2885,26 @@ class JsonReporter {
|
|
|
2969
2885
|
return {
|
|
2970
2886
|
ancestorTitles,
|
|
2971
2887
|
fullName: t.name ? [...ancestorTitles, t.name].join(" ") : ancestorTitles.join(" "),
|
|
2972
|
-
status: StatusMap[
|
|
2888
|
+
status: StatusMap[t.result?.state || t.mode] || "skipped",
|
|
2973
2889
|
title: t.name,
|
|
2974
|
-
duration:
|
|
2975
|
-
failureMessages:
|
|
2890
|
+
duration: t.result?.duration,
|
|
2891
|
+
failureMessages: t.result?.errors?.map((e) => e.stack || e.message) || [],
|
|
2976
2892
|
location: t.location,
|
|
2977
2893
|
meta: t.meta
|
|
2978
2894
|
};
|
|
2979
2895
|
});
|
|
2980
|
-
if (tests2.some((t) => {
|
|
2981
|
-
var _a2;
|
|
2982
|
-
return ((_a2 = t.result) == null ? void 0 : _a2.state) === "run";
|
|
2983
|
-
})) {
|
|
2896
|
+
if (tests2.some((t) => t.result?.state === "run")) {
|
|
2984
2897
|
this.ctx.logger.warn(
|
|
2985
2898
|
"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"
|
|
2986
2899
|
);
|
|
2987
2900
|
}
|
|
2988
|
-
const hasFailedTests = tests2.some((t) =>
|
|
2989
|
-
var _a2;
|
|
2990
|
-
return ((_a2 = t.result) == null ? void 0 : _a2.state) === "fail";
|
|
2991
|
-
});
|
|
2901
|
+
const hasFailedTests = tests2.some((t) => t.result?.state === "fail");
|
|
2992
2902
|
testResults.push({
|
|
2993
2903
|
assertionResults,
|
|
2994
2904
|
startTime,
|
|
2995
2905
|
endTime,
|
|
2996
|
-
status:
|
|
2997
|
-
message:
|
|
2906
|
+
status: file.result?.state === "fail" || hasFailedTests ? "failed" : "passed",
|
|
2907
|
+
message: file.result?.errors?.[0]?.message ?? "",
|
|
2998
2908
|
name: file.filepath
|
|
2999
2909
|
});
|
|
3000
2910
|
}
|
|
@@ -3046,13 +2956,12 @@ class VerboseReporter extends DefaultReporter {
|
|
|
3046
2956
|
this.rendererOptions.renderSucceed = true;
|
|
3047
2957
|
}
|
|
3048
2958
|
onTaskUpdate(packs) {
|
|
3049
|
-
var _a, _b, _c;
|
|
3050
2959
|
if (this.isTTY) {
|
|
3051
2960
|
return;
|
|
3052
2961
|
}
|
|
3053
2962
|
for (const pack of packs) {
|
|
3054
2963
|
const task = this.ctx.state.idMap.get(pack[0]);
|
|
3055
|
-
if (task && task.type === "test" &&
|
|
2964
|
+
if (task && task.type === "test" && task.result?.state && task.result?.state !== "run") {
|
|
3056
2965
|
let title = ` ${getStateSymbol(task)} `;
|
|
3057
2966
|
if (task.file.projectName) {
|
|
3058
2967
|
title += formatProjectName(task.file.projectName);
|
|
@@ -3070,8 +2979,8 @@ class VerboseReporter extends DefaultReporter {
|
|
|
3070
2979
|
}
|
|
3071
2980
|
this.ctx.logger.log(title);
|
|
3072
2981
|
if (task.result.state === "fail") {
|
|
3073
|
-
|
|
3074
|
-
this.ctx.logger.log(c.red(` ${F_RIGHT} ${error
|
|
2982
|
+
task.result.errors?.forEach((error) => {
|
|
2983
|
+
this.ctx.logger.log(c.red(` ${F_RIGHT} ${error?.message}`));
|
|
3075
2984
|
});
|
|
3076
2985
|
}
|
|
3077
2986
|
}
|
|
@@ -3112,12 +3021,11 @@ class TapReporter {
|
|
|
3112
3021
|
this.logger = new IndentedLogger(ctx.logger.log.bind(ctx.logger));
|
|
3113
3022
|
}
|
|
3114
3023
|
static getComment(task) {
|
|
3115
|
-
var _a;
|
|
3116
3024
|
if (task.mode === "skip") {
|
|
3117
3025
|
return " # SKIP";
|
|
3118
3026
|
} else if (task.mode === "todo") {
|
|
3119
3027
|
return " # TODO";
|
|
3120
|
-
} else if (
|
|
3028
|
+
} else if (task.result?.duration != null) {
|
|
3121
3029
|
return ` # time=${task.result.duration.toFixed(2)}ms`;
|
|
3122
3030
|
} else {
|
|
3123
3031
|
return "";
|
|
@@ -3134,11 +3042,10 @@ class TapReporter {
|
|
|
3134
3042
|
}
|
|
3135
3043
|
}
|
|
3136
3044
|
logTasks(tasks) {
|
|
3137
|
-
var _a, _b;
|
|
3138
3045
|
this.logger.log(`1..${tasks.length}`);
|
|
3139
3046
|
for (const [i, task] of tasks.entries()) {
|
|
3140
3047
|
const id = i + 1;
|
|
3141
|
-
const ok =
|
|
3048
|
+
const ok = task.result?.state === "pass" || task.mode === "skip" || task.mode === "todo" ? "ok" : "not ok";
|
|
3142
3049
|
const comment = TapReporter.getComment(task);
|
|
3143
3050
|
if (task.type === "suite" && task.tasks.length > 0) {
|
|
3144
3051
|
this.logger.log(`${ok} ${id} - ${tapString(task.name)}${comment} {`);
|
|
@@ -3149,11 +3056,10 @@ class TapReporter {
|
|
|
3149
3056
|
} else {
|
|
3150
3057
|
this.logger.log(`${ok} ${id} - ${tapString(task.name)}${comment}`);
|
|
3151
3058
|
const project = this.ctx.getProjectByTaskId(task.id);
|
|
3152
|
-
if (
|
|
3059
|
+
if (task.result?.state === "fail" && task.result.errors) {
|
|
3153
3060
|
this.logger.indent();
|
|
3154
3061
|
task.result.errors.forEach((error) => {
|
|
3155
|
-
|
|
3156
|
-
const stacks = task.file.pool === "browser" ? ((_a2 = project.browser) == null ? void 0 : _a2.parseErrorStacktrace(error)) || [] : parseErrorStacktrace(error, {
|
|
3062
|
+
const stacks = task.file.pool === "browser" ? project.browser?.parseErrorStacktrace(error) || [] : parseErrorStacktrace(error, {
|
|
3157
3063
|
frameFilter: this.ctx.config.onStackTrace
|
|
3158
3064
|
});
|
|
3159
3065
|
const stack = stacks[0];
|
|
@@ -4418,7 +4324,7 @@ class BaseSequencer {
|
|
|
4418
4324
|
const shardEnd = shardSize * index;
|
|
4419
4325
|
return [...files].map((spec) => {
|
|
4420
4326
|
const fullPath = resolve(slash(config.root), slash(spec[1]));
|
|
4421
|
-
const specPath = fullPath
|
|
4327
|
+
const specPath = fullPath?.slice(config.root.length);
|
|
4422
4328
|
return {
|
|
4423
4329
|
spec,
|
|
4424
4330
|
hash: createHash("sha1").update(specPath).digest("hex")
|
|
@@ -4524,8 +4430,7 @@ class Logger {
|
|
|
4524
4430
|
printProperties: options.verbose,
|
|
4525
4431
|
screenshotPaths: options.screenshotPaths,
|
|
4526
4432
|
parseErrorStacktrace: (error) => {
|
|
4527
|
-
|
|
4528
|
-
if (((_a = options.task) == null ? void 0 : _a.file.pool) === "browser" && project.browser) {
|
|
4433
|
+
if (options.task?.file.pool === "browser" && project.browser) {
|
|
4529
4434
|
return project.browser.parseErrorStacktrace(error, {
|
|
4530
4435
|
ignoreStackEntries: fullStack ? [] : void 0
|
|
4531
4436
|
});
|
|
@@ -4553,10 +4458,9 @@ class Logger {
|
|
|
4553
4458
|
return code;
|
|
4554
4459
|
}
|
|
4555
4460
|
printNoTestFound(filters) {
|
|
4556
|
-
var _a;
|
|
4557
4461
|
const config = this.ctx.config;
|
|
4558
4462
|
const comma = c.dim(", ");
|
|
4559
|
-
if (filters
|
|
4463
|
+
if (filters?.length) {
|
|
4560
4464
|
this.console.error(c.dim("filter: ") + c.yellow(filters.join(comma)));
|
|
4561
4465
|
}
|
|
4562
4466
|
const projectsFilter = toArray(config.project);
|
|
@@ -4591,7 +4495,7 @@ class Logger {
|
|
|
4591
4495
|
);
|
|
4592
4496
|
}
|
|
4593
4497
|
});
|
|
4594
|
-
if (config.watch && (config.changed ||
|
|
4498
|
+
if (config.watch && (config.changed || config.related?.length)) {
|
|
4595
4499
|
this.log(`No affected ${config.mode} files found
|
|
4596
4500
|
`);
|
|
4597
4501
|
} else {
|
|
@@ -4607,7 +4511,6 @@ No ${config.mode} files found, exiting with code 1`)
|
|
|
4607
4511
|
}
|
|
4608
4512
|
}
|
|
4609
4513
|
printBanner() {
|
|
4610
|
-
var _a, _b;
|
|
4611
4514
|
this.log();
|
|
4612
4515
|
const versionTest = this.ctx.config.watch ? c.blue(`v${this.ctx.version}`) : c.cyan(`v${this.ctx.version}`);
|
|
4613
4516
|
const mode = this.ctx.config.watch ? c.blue(" DEV ") : c.cyan(" RUN ");
|
|
@@ -4630,7 +4533,7 @@ No ${config.mode} files found, exiting with code 1`)
|
|
|
4630
4533
|
const name = project.getName();
|
|
4631
4534
|
const output = project.isCore() ? "" : ` [${name}]`;
|
|
4632
4535
|
const resolvedUrls = project.browser.vite.resolvedUrls;
|
|
4633
|
-
const origin =
|
|
4536
|
+
const origin = resolvedUrls?.local[0] ?? resolvedUrls?.network[0];
|
|
4634
4537
|
this.log(
|
|
4635
4538
|
c.dim(
|
|
4636
4539
|
c.green(
|
|
@@ -4643,14 +4546,14 @@ No ${config.mode} files found, exiting with code 1`)
|
|
|
4643
4546
|
this.log(
|
|
4644
4547
|
c.dim(
|
|
4645
4548
|
c.green(
|
|
4646
|
-
` UI started at http://${
|
|
4549
|
+
` UI started at http://${this.ctx.config.api?.host || "localhost"}:${c.bold(`${this.ctx.server.config.server.port}`)}${this.ctx.config.uiBase}`
|
|
4647
4550
|
)
|
|
4648
4551
|
)
|
|
4649
4552
|
);
|
|
4650
|
-
} else if (
|
|
4553
|
+
} else if (this.ctx.config.api?.port) {
|
|
4651
4554
|
const resolvedUrls = this.ctx.server.resolvedUrls;
|
|
4652
4555
|
const fallbackUrl = `http://${this.ctx.config.api.host || "localhost"}:${this.ctx.config.api.port}`;
|
|
4653
|
-
const origin =
|
|
4556
|
+
const origin = resolvedUrls?.local[0] ?? resolvedUrls?.network[0] ?? fallbackUrl;
|
|
4654
4557
|
this.log(c.dim(c.green(` API started at ${new URL("/", origin)}`)));
|
|
4655
4558
|
}
|
|
4656
4559
|
if (this.ctx.coverageProvider) {
|
|
@@ -4716,10 +4619,9 @@ function capturePrintError(error, ctx, options) {
|
|
|
4716
4619
|
showCodeFrame: false,
|
|
4717
4620
|
...options
|
|
4718
4621
|
});
|
|
4719
|
-
return { nearest: result
|
|
4622
|
+
return { nearest: result?.nearest, output };
|
|
4720
4623
|
}
|
|
4721
4624
|
function printError(error, project, options) {
|
|
4722
|
-
var _a;
|
|
4723
4625
|
const { showCodeFrame = true, type, printProperties = true } = options;
|
|
4724
4626
|
const logger = options.logger;
|
|
4725
4627
|
let e = error;
|
|
@@ -4752,7 +4654,7 @@ function printError(error, project, options) {
|
|
|
4752
4654
|
printErrorType(type, project.ctx);
|
|
4753
4655
|
}
|
|
4754
4656
|
printErrorMessage(e, logger);
|
|
4755
|
-
if (
|
|
4657
|
+
if (options.screenshotPaths?.length) {
|
|
4756
4658
|
const length = options.screenshotPaths.length;
|
|
4757
4659
|
logger.error(`
|
|
4758
4660
|
Failure screenshot${length > 1 ? "s" : ""}:`);
|
|
@@ -4873,7 +4775,7 @@ function handleImportOutsideModuleError(stack, logger) {
|
|
|
4873
4775
|
}
|
|
4874
4776
|
const path = normalize(stack.split("\n")[0].trim());
|
|
4875
4777
|
let name = path.split("/node_modules/").pop() || "";
|
|
4876
|
-
if (name
|
|
4778
|
+
if (name?.startsWith("@")) {
|
|
4877
4779
|
name = name.split("/").slice(0, 2).join("/");
|
|
4878
4780
|
} else {
|
|
4879
4781
|
name = name.split("/")[0];
|
|
@@ -4946,7 +4848,7 @@ function printStack(logger, project, stack, highlight, errorProperties, onStack)
|
|
|
4946
4848
|
].filter(Boolean).join(" ")}`
|
|
4947
4849
|
)
|
|
4948
4850
|
);
|
|
4949
|
-
onStack
|
|
4851
|
+
onStack?.(frame);
|
|
4950
4852
|
}
|
|
4951
4853
|
if (stack.length) {
|
|
4952
4854
|
logger.error();
|
|
@@ -4964,14 +4866,13 @@ function hasProperties(obj) {
|
|
|
4964
4866
|
return false;
|
|
4965
4867
|
}
|
|
4966
4868
|
function generateCodeFrame(source, indent = 0, loc, range = 2) {
|
|
4967
|
-
var _a;
|
|
4968
4869
|
const start = typeof loc === "object" ? positionToOffset(source, loc.line, loc.column) : loc;
|
|
4969
4870
|
const end = start;
|
|
4970
4871
|
const lines = source.split(lineSplitRE);
|
|
4971
4872
|
const nl = /\r\n/.test(source) ? 2 : 1;
|
|
4972
4873
|
let count = 0;
|
|
4973
4874
|
let res = [];
|
|
4974
|
-
const columns =
|
|
4875
|
+
const columns = process.stdout?.columns || 80;
|
|
4975
4876
|
function lineNo(no = "") {
|
|
4976
4877
|
return c.gray(`${String(no).padStart(3, " ")}| `);
|
|
4977
4878
|
}
|
|
@@ -5053,8 +4954,7 @@ function executionTime(durationMS) {
|
|
|
5053
4954
|
});
|
|
5054
4955
|
}
|
|
5055
4956
|
function getDuration(task) {
|
|
5056
|
-
|
|
5057
|
-
const duration = ((_a = task.result) == null ? void 0 : _a.duration) ?? 0;
|
|
4957
|
+
const duration = task.result?.duration ?? 0;
|
|
5058
4958
|
return executionTime(duration);
|
|
5059
4959
|
}
|
|
5060
4960
|
class JUnitReporter {
|
|
@@ -5066,9 +4966,8 @@ class JUnitReporter {
|
|
|
5066
4966
|
fileFd;
|
|
5067
4967
|
options;
|
|
5068
4968
|
constructor(options) {
|
|
5069
|
-
var _a;
|
|
5070
4969
|
this.options = { ...options };
|
|
5071
|
-
|
|
4970
|
+
this.options.includeConsoleOutput ??= true;
|
|
5072
4971
|
}
|
|
5073
4972
|
async onInit(ctx) {
|
|
5074
4973
|
this.ctx = ctx;
|
|
@@ -5137,7 +5036,6 @@ class JUnitReporter {
|
|
|
5137
5036
|
time: getDuration(task)
|
|
5138
5037
|
},
|
|
5139
5038
|
async () => {
|
|
5140
|
-
var _a;
|
|
5141
5039
|
if (this.options.includeConsoleOutput) {
|
|
5142
5040
|
await this.writeLogs(task, "out");
|
|
5143
5041
|
await this.writeLogs(task, "err");
|
|
@@ -5145,14 +5043,14 @@ class JUnitReporter {
|
|
|
5145
5043
|
if (task.mode === "skip" || task.mode === "todo") {
|
|
5146
5044
|
await this.logger.log("<skipped/>");
|
|
5147
5045
|
}
|
|
5148
|
-
if (
|
|
5046
|
+
if (task.result?.state === "fail") {
|
|
5149
5047
|
const errors = task.result.errors || [];
|
|
5150
5048
|
for (const error of errors) {
|
|
5151
5049
|
await this.writeElement(
|
|
5152
5050
|
"failure",
|
|
5153
5051
|
{
|
|
5154
|
-
message: error
|
|
5155
|
-
type:
|
|
5052
|
+
message: error?.message,
|
|
5053
|
+
type: error?.name ?? error?.nameStr
|
|
5156
5054
|
},
|
|
5157
5055
|
async () => {
|
|
5158
5056
|
if (!error) {
|
|
@@ -5175,17 +5073,14 @@ class JUnitReporter {
|
|
|
5175
5073
|
}
|
|
5176
5074
|
}
|
|
5177
5075
|
async onFinished(files = this.ctx.state.getFiles()) {
|
|
5178
|
-
var _a;
|
|
5179
5076
|
await this.logger.log('<?xml version="1.0" encoding="UTF-8" ?>');
|
|
5180
5077
|
const transformed = files.map((file) => {
|
|
5181
|
-
var _a2, _b;
|
|
5182
5078
|
const tasks = file.tasks.flatMap((task) => flattenTasks$1(task));
|
|
5183
5079
|
const stats2 = tasks.reduce(
|
|
5184
5080
|
(stats3, task) => {
|
|
5185
|
-
var _a3, _b2;
|
|
5186
5081
|
return {
|
|
5187
|
-
passed: stats3.passed + Number(
|
|
5188
|
-
failures: stats3.failures + Number(
|
|
5082
|
+
passed: stats3.passed + Number(task.result?.state === "pass"),
|
|
5083
|
+
failures: stats3.failures + Number(task.result?.state === "fail"),
|
|
5189
5084
|
skipped: stats3.skipped + Number(task.mode === "skip" || task.mode === "todo")
|
|
5190
5085
|
};
|
|
5191
5086
|
},
|
|
@@ -5197,12 +5092,12 @@ class JUnitReporter {
|
|
|
5197
5092
|
);
|
|
5198
5093
|
const suites = getSuites(file);
|
|
5199
5094
|
for (const suite of suites) {
|
|
5200
|
-
if (
|
|
5095
|
+
if (suite.result?.errors) {
|
|
5201
5096
|
tasks.push(suite);
|
|
5202
5097
|
stats2.failures += 1;
|
|
5203
5098
|
}
|
|
5204
5099
|
}
|
|
5205
|
-
if (tasks.length === 0 &&
|
|
5100
|
+
if (tasks.length === 0 && file.result?.state === "fail") {
|
|
5206
5101
|
stats2.failures = 1;
|
|
5207
5102
|
tasks.push({
|
|
5208
5103
|
id: file.id,
|
|
@@ -5263,7 +5158,7 @@ class JUnitReporter {
|
|
|
5263
5158
|
if (this.reportFile) {
|
|
5264
5159
|
this.ctx.logger.log(`JUNIT report written to ${this.reportFile}`);
|
|
5265
5160
|
}
|
|
5266
|
-
await
|
|
5161
|
+
await this.fileFd?.close();
|
|
5267
5162
|
this.fileFd = void 0;
|
|
5268
5163
|
}
|
|
5269
5164
|
}
|
|
@@ -5301,8 +5196,7 @@ class HangingProcessReporter {
|
|
|
5301
5196
|
this.whyRunning = _require("why-is-node-running");
|
|
5302
5197
|
}
|
|
5303
5198
|
onProcessTimeout() {
|
|
5304
|
-
|
|
5305
|
-
(_a = this.whyRunning) == null ? void 0 : _a.call(this);
|
|
5199
|
+
this.whyRunning?.();
|
|
5306
5200
|
}
|
|
5307
5201
|
}
|
|
5308
5202
|
|
|
@@ -5312,7 +5206,6 @@ class GithubActionsReporter {
|
|
|
5312
5206
|
this.ctx = ctx;
|
|
5313
5207
|
}
|
|
5314
5208
|
onFinished(files = [], errors = []) {
|
|
5315
|
-
var _a, _b;
|
|
5316
5209
|
const projectErrors = new Array();
|
|
5317
5210
|
for (const error of errors) {
|
|
5318
5211
|
projectErrors.push({
|
|
@@ -5325,11 +5218,11 @@ class GithubActionsReporter {
|
|
|
5325
5218
|
const tasks = getTasks(file);
|
|
5326
5219
|
const project = this.ctx.getProjectByTaskId(file.id);
|
|
5327
5220
|
for (const task of tasks) {
|
|
5328
|
-
if (
|
|
5221
|
+
if (task.result?.state !== "fail") {
|
|
5329
5222
|
continue;
|
|
5330
5223
|
}
|
|
5331
5224
|
const title = getFullName(task, " > ");
|
|
5332
|
-
for (const error of
|
|
5225
|
+
for (const error of task.result?.errors ?? []) {
|
|
5333
5226
|
projectErrors.push({
|
|
5334
5227
|
project,
|
|
5335
5228
|
title,
|
|
@@ -5341,7 +5234,7 @@ class GithubActionsReporter {
|
|
|
5341
5234
|
}
|
|
5342
5235
|
for (const { project, title, error, file } of projectErrors) {
|
|
5343
5236
|
const result = capturePrintError(error, this.ctx, { project, task: file });
|
|
5344
|
-
const stack = result
|
|
5237
|
+
const stack = result?.nearest;
|
|
5345
5238
|
if (!stack) {
|
|
5346
5239
|
continue;
|
|
5347
5240
|
}
|
|
@@ -5471,9 +5364,8 @@ async function readBlobs(blobsDirectory, projectsArray) {
|
|
|
5471
5364
|
});
|
|
5472
5365
|
});
|
|
5473
5366
|
const files = blobs.flatMap((blob) => blob.files).sort((f1, f2) => {
|
|
5474
|
-
|
|
5475
|
-
const
|
|
5476
|
-
const time2 = ((_b = f2.result) == null ? void 0 : _b.startTime) || 0;
|
|
5367
|
+
const time1 = f1.result?.startTime || 0;
|
|
5368
|
+
const time2 = f2.result?.startTime || 0;
|
|
5477
5369
|
return time1 - time2;
|
|
5478
5370
|
});
|
|
5479
5371
|
const errors = blobs.flatMap((blob) => blob.errors);
|
|
@@ -5485,6 +5377,382 @@ async function readBlobs(blobsDirectory, projectsArray) {
|
|
|
5485
5377
|
};
|
|
5486
5378
|
}
|
|
5487
5379
|
|
|
5380
|
+
class TestProject {
|
|
5381
|
+
/**
|
|
5382
|
+
* The global vitest instance.
|
|
5383
|
+
* @experimental The public Vitest API is experimental and does not follow semver.
|
|
5384
|
+
*/
|
|
5385
|
+
vitest;
|
|
5386
|
+
/**
|
|
5387
|
+
* The workspace project this test project is associated with.
|
|
5388
|
+
* @experimental The public Vitest API is experimental and does not follow semver.
|
|
5389
|
+
*/
|
|
5390
|
+
workspaceProject;
|
|
5391
|
+
/**
|
|
5392
|
+
* Resolved project configuration.
|
|
5393
|
+
*/
|
|
5394
|
+
config;
|
|
5395
|
+
/**
|
|
5396
|
+
* Resolved global configuration. If there are no workspace projects, this will be the same as `config`.
|
|
5397
|
+
*/
|
|
5398
|
+
globalConfig;
|
|
5399
|
+
/**
|
|
5400
|
+
* The name of the project or an empty string if not set.
|
|
5401
|
+
*/
|
|
5402
|
+
name;
|
|
5403
|
+
constructor(workspaceProject) {
|
|
5404
|
+
this.workspaceProject = workspaceProject;
|
|
5405
|
+
this.vitest = workspaceProject.ctx;
|
|
5406
|
+
this.globalConfig = workspaceProject.ctx.config;
|
|
5407
|
+
this.config = workspaceProject.config;
|
|
5408
|
+
this.name = workspaceProject.getName();
|
|
5409
|
+
}
|
|
5410
|
+
/**
|
|
5411
|
+
* Serialized project configuration. This is the config that tests receive.
|
|
5412
|
+
*/
|
|
5413
|
+
get serializedConfig() {
|
|
5414
|
+
return this.workspaceProject.getSerializableConfig();
|
|
5415
|
+
}
|
|
5416
|
+
/**
|
|
5417
|
+
* Custom context provided to the project.
|
|
5418
|
+
*/
|
|
5419
|
+
context() {
|
|
5420
|
+
return this.workspaceProject.getProvidedContext();
|
|
5421
|
+
}
|
|
5422
|
+
/**
|
|
5423
|
+
* Provide a custom serializable context to the project. This context will be available for tests once they run.
|
|
5424
|
+
*/
|
|
5425
|
+
provide(key, value) {
|
|
5426
|
+
this.workspaceProject.provide(key, value);
|
|
5427
|
+
}
|
|
5428
|
+
toJSON() {
|
|
5429
|
+
return {
|
|
5430
|
+
name: this.name,
|
|
5431
|
+
serializedConfig: this.serializedConfig,
|
|
5432
|
+
context: this.context()
|
|
5433
|
+
};
|
|
5434
|
+
}
|
|
5435
|
+
}
|
|
5436
|
+
|
|
5437
|
+
class ReportedTaskImplementation {
|
|
5438
|
+
/**
|
|
5439
|
+
* Task instance.
|
|
5440
|
+
* @experimental Public runner task API is experimental and does not follow semver.
|
|
5441
|
+
*/
|
|
5442
|
+
task;
|
|
5443
|
+
/**
|
|
5444
|
+
* The project assosiacted with the test or suite.
|
|
5445
|
+
*/
|
|
5446
|
+
project;
|
|
5447
|
+
/**
|
|
5448
|
+
* Unique identifier.
|
|
5449
|
+
* This ID is deterministic and will be the same for the same test across multiple runs.
|
|
5450
|
+
* The ID is based on the project name, file path and test position.
|
|
5451
|
+
*/
|
|
5452
|
+
id;
|
|
5453
|
+
/**
|
|
5454
|
+
* Location in the file where the test or suite is defined.
|
|
5455
|
+
*/
|
|
5456
|
+
location;
|
|
5457
|
+
constructor(task, project) {
|
|
5458
|
+
this.task = task;
|
|
5459
|
+
this.project = project.testProject || (project.testProject = new TestProject(project));
|
|
5460
|
+
this.id = task.id;
|
|
5461
|
+
this.location = task.location;
|
|
5462
|
+
}
|
|
5463
|
+
/**
|
|
5464
|
+
* Creates a new reported task instance and stores it in the project's state for future use.
|
|
5465
|
+
*/
|
|
5466
|
+
static register(task, project) {
|
|
5467
|
+
const state = new this(task, project);
|
|
5468
|
+
storeTask(project, task, state);
|
|
5469
|
+
return state;
|
|
5470
|
+
}
|
|
5471
|
+
}
|
|
5472
|
+
class TestCase extends ReportedTaskImplementation {
|
|
5473
|
+
#fullName;
|
|
5474
|
+
type = "test";
|
|
5475
|
+
/**
|
|
5476
|
+
* Direct reference to the test file where the test or suite is defined.
|
|
5477
|
+
*/
|
|
5478
|
+
file;
|
|
5479
|
+
/**
|
|
5480
|
+
* Name of the test.
|
|
5481
|
+
*/
|
|
5482
|
+
name;
|
|
5483
|
+
/**
|
|
5484
|
+
* Options that the test was initiated with.
|
|
5485
|
+
*/
|
|
5486
|
+
options;
|
|
5487
|
+
/**
|
|
5488
|
+
* Parent suite. If the test was called directly inside the file, the parent will be the file.
|
|
5489
|
+
*/
|
|
5490
|
+
parent;
|
|
5491
|
+
constructor(task, project) {
|
|
5492
|
+
super(task, project);
|
|
5493
|
+
this.name = task.name;
|
|
5494
|
+
this.file = getReportedTask(project, task.file);
|
|
5495
|
+
const suite = this.task.suite;
|
|
5496
|
+
if (suite) {
|
|
5497
|
+
this.parent = getReportedTask(project, suite);
|
|
5498
|
+
} else {
|
|
5499
|
+
this.parent = this.file;
|
|
5500
|
+
}
|
|
5501
|
+
this.options = buildOptions(task);
|
|
5502
|
+
}
|
|
5503
|
+
/**
|
|
5504
|
+
* Full name of the test including all parent suites separated with `>`.
|
|
5505
|
+
*/
|
|
5506
|
+
get fullName() {
|
|
5507
|
+
if (this.#fullName === void 0) {
|
|
5508
|
+
this.#fullName = getTestName(this.task, " > ");
|
|
5509
|
+
}
|
|
5510
|
+
return this.#fullName;
|
|
5511
|
+
}
|
|
5512
|
+
/**
|
|
5513
|
+
* Test results. Will be `undefined` if test is not finished yet or was just collected.
|
|
5514
|
+
*/
|
|
5515
|
+
result() {
|
|
5516
|
+
const result = this.task.result;
|
|
5517
|
+
if (!result || result.state === "run") {
|
|
5518
|
+
return void 0;
|
|
5519
|
+
}
|
|
5520
|
+
const state = result.state === "fail" ? "failed" : result.state === "pass" ? "passed" : "skipped";
|
|
5521
|
+
return {
|
|
5522
|
+
state,
|
|
5523
|
+
errors: result.errors
|
|
5524
|
+
};
|
|
5525
|
+
}
|
|
5526
|
+
/**
|
|
5527
|
+
* Checks if the test did not fail the suite.
|
|
5528
|
+
* If the test is not finished yet or was skipped, it will return `true`.
|
|
5529
|
+
*/
|
|
5530
|
+
ok() {
|
|
5531
|
+
const result = this.result();
|
|
5532
|
+
return !result || result.state !== "failed";
|
|
5533
|
+
}
|
|
5534
|
+
/**
|
|
5535
|
+
* Custom metadata that was attached to the test during its execution.
|
|
5536
|
+
*/
|
|
5537
|
+
meta() {
|
|
5538
|
+
return this.task.meta;
|
|
5539
|
+
}
|
|
5540
|
+
/**
|
|
5541
|
+
* Useful information about the test like duration, memory usage, etc.
|
|
5542
|
+
* Diagnostic is only available after the test has finished.
|
|
5543
|
+
*/
|
|
5544
|
+
diagnostic() {
|
|
5545
|
+
const result = this.task.result;
|
|
5546
|
+
if (!result || result.state === "run" || !result.startTime) {
|
|
5547
|
+
return void 0;
|
|
5548
|
+
}
|
|
5549
|
+
return {
|
|
5550
|
+
heap: result.heap,
|
|
5551
|
+
duration: result.duration,
|
|
5552
|
+
startTime: result.startTime,
|
|
5553
|
+
retryCount: result.retryCount ?? 0,
|
|
5554
|
+
repeatCount: result.repeatCount ?? 0,
|
|
5555
|
+
flaky: !!result.retryCount && result.state === "pass" && result.retryCount > 0
|
|
5556
|
+
};
|
|
5557
|
+
}
|
|
5558
|
+
}
|
|
5559
|
+
class TestCollection {
|
|
5560
|
+
#task;
|
|
5561
|
+
#project;
|
|
5562
|
+
constructor(task, project) {
|
|
5563
|
+
this.#task = task;
|
|
5564
|
+
this.#project = project;
|
|
5565
|
+
}
|
|
5566
|
+
/**
|
|
5567
|
+
* Returns the test or suite at a specific index in the array.
|
|
5568
|
+
*/
|
|
5569
|
+
at(index) {
|
|
5570
|
+
if (index < 0) {
|
|
5571
|
+
index = this.size + index;
|
|
5572
|
+
}
|
|
5573
|
+
return getReportedTask(this.#project, this.#task.tasks[index]);
|
|
5574
|
+
}
|
|
5575
|
+
/**
|
|
5576
|
+
* The number of tests and suites in the collection.
|
|
5577
|
+
*/
|
|
5578
|
+
get size() {
|
|
5579
|
+
return this.#task.tasks.length;
|
|
5580
|
+
}
|
|
5581
|
+
/**
|
|
5582
|
+
* Returns the collection in array form for easier manipulation.
|
|
5583
|
+
*/
|
|
5584
|
+
array() {
|
|
5585
|
+
return Array.from(this);
|
|
5586
|
+
}
|
|
5587
|
+
/**
|
|
5588
|
+
* Filters all tests that are part of this collection and its children.
|
|
5589
|
+
*/
|
|
5590
|
+
*allTests(state) {
|
|
5591
|
+
for (const child of this) {
|
|
5592
|
+
if (child.type === "suite") {
|
|
5593
|
+
yield* child.children.allTests(state);
|
|
5594
|
+
} else if (state) {
|
|
5595
|
+
const testState = getTestState(child);
|
|
5596
|
+
if (state === testState) {
|
|
5597
|
+
yield child;
|
|
5598
|
+
}
|
|
5599
|
+
} else {
|
|
5600
|
+
yield child;
|
|
5601
|
+
}
|
|
5602
|
+
}
|
|
5603
|
+
}
|
|
5604
|
+
/**
|
|
5605
|
+
* Filters only the tests that are part of this collection.
|
|
5606
|
+
*/
|
|
5607
|
+
*tests(state) {
|
|
5608
|
+
for (const child of this) {
|
|
5609
|
+
if (child.type !== "test") {
|
|
5610
|
+
continue;
|
|
5611
|
+
}
|
|
5612
|
+
if (state) {
|
|
5613
|
+
const testState = getTestState(child);
|
|
5614
|
+
if (state === testState) {
|
|
5615
|
+
yield child;
|
|
5616
|
+
}
|
|
5617
|
+
} else {
|
|
5618
|
+
yield child;
|
|
5619
|
+
}
|
|
5620
|
+
}
|
|
5621
|
+
}
|
|
5622
|
+
/**
|
|
5623
|
+
* Filters only the suites that are part of this collection.
|
|
5624
|
+
*/
|
|
5625
|
+
*suites() {
|
|
5626
|
+
for (const child of this) {
|
|
5627
|
+
if (child.type === "suite") {
|
|
5628
|
+
yield child;
|
|
5629
|
+
}
|
|
5630
|
+
}
|
|
5631
|
+
}
|
|
5632
|
+
/**
|
|
5633
|
+
* Filters all suites that are part of this collection and its children.
|
|
5634
|
+
*/
|
|
5635
|
+
*allSuites() {
|
|
5636
|
+
for (const child of this) {
|
|
5637
|
+
if (child.type === "suite") {
|
|
5638
|
+
yield child;
|
|
5639
|
+
yield* child.children.allSuites();
|
|
5640
|
+
}
|
|
5641
|
+
}
|
|
5642
|
+
}
|
|
5643
|
+
*[Symbol.iterator]() {
|
|
5644
|
+
for (const task of this.#task.tasks) {
|
|
5645
|
+
yield getReportedTask(this.#project, task);
|
|
5646
|
+
}
|
|
5647
|
+
}
|
|
5648
|
+
}
|
|
5649
|
+
class SuiteImplementation extends ReportedTaskImplementation {
|
|
5650
|
+
/**
|
|
5651
|
+
* Collection of suites and tests that are part of this suite.
|
|
5652
|
+
*/
|
|
5653
|
+
children;
|
|
5654
|
+
constructor(task, project) {
|
|
5655
|
+
super(task, project);
|
|
5656
|
+
this.children = new TestCollection(task, project);
|
|
5657
|
+
}
|
|
5658
|
+
}
|
|
5659
|
+
class TestSuite extends SuiteImplementation {
|
|
5660
|
+
#fullName;
|
|
5661
|
+
type = "suite";
|
|
5662
|
+
/**
|
|
5663
|
+
* Name of the test or the suite.
|
|
5664
|
+
*/
|
|
5665
|
+
name;
|
|
5666
|
+
/**
|
|
5667
|
+
* Direct reference to the test file where the test or suite is defined.
|
|
5668
|
+
*/
|
|
5669
|
+
file;
|
|
5670
|
+
/**
|
|
5671
|
+
* Parent suite. If suite was called directly inside the file, the parent will be the file.
|
|
5672
|
+
*/
|
|
5673
|
+
parent;
|
|
5674
|
+
/**
|
|
5675
|
+
* Options that suite was initiated with.
|
|
5676
|
+
*/
|
|
5677
|
+
options;
|
|
5678
|
+
constructor(task, project) {
|
|
5679
|
+
super(task, project);
|
|
5680
|
+
this.name = task.name;
|
|
5681
|
+
this.file = getReportedTask(project, task.file);
|
|
5682
|
+
const suite = this.task.suite;
|
|
5683
|
+
if (suite) {
|
|
5684
|
+
this.parent = getReportedTask(project, suite);
|
|
5685
|
+
} else {
|
|
5686
|
+
this.parent = this.file;
|
|
5687
|
+
}
|
|
5688
|
+
this.options = buildOptions(task);
|
|
5689
|
+
}
|
|
5690
|
+
/**
|
|
5691
|
+
* Full name of the suite including all parent suites separated with `>`.
|
|
5692
|
+
*/
|
|
5693
|
+
get fullName() {
|
|
5694
|
+
if (this.#fullName === void 0) {
|
|
5695
|
+
this.#fullName = getTestName(this.task, " > ");
|
|
5696
|
+
}
|
|
5697
|
+
return this.#fullName;
|
|
5698
|
+
}
|
|
5699
|
+
}
|
|
5700
|
+
class TestFile extends SuiteImplementation {
|
|
5701
|
+
type = "file";
|
|
5702
|
+
/**
|
|
5703
|
+
* This is usually an absolute UNIX file path.
|
|
5704
|
+
* It can be a virtual id if the file is not on the disk.
|
|
5705
|
+
* This value corresponds to Vite's `ModuleGraph` id.
|
|
5706
|
+
*/
|
|
5707
|
+
moduleId;
|
|
5708
|
+
constructor(task, project) {
|
|
5709
|
+
super(task, project);
|
|
5710
|
+
this.moduleId = task.filepath;
|
|
5711
|
+
}
|
|
5712
|
+
/**
|
|
5713
|
+
* Useful information about the file like duration, memory usage, etc.
|
|
5714
|
+
* If the file was not executed yet, all diagnostic values will return `0`.
|
|
5715
|
+
*/
|
|
5716
|
+
diagnostic() {
|
|
5717
|
+
const setupDuration = this.task.setupDuration || 0;
|
|
5718
|
+
const collectDuration = this.task.collectDuration || 0;
|
|
5719
|
+
const prepareDuration = this.task.prepareDuration || 0;
|
|
5720
|
+
const environmentSetupDuration = this.task.environmentLoad || 0;
|
|
5721
|
+
const duration = this.task.result?.duration || 0;
|
|
5722
|
+
return {
|
|
5723
|
+
environmentSetupDuration,
|
|
5724
|
+
prepareDuration,
|
|
5725
|
+
collectDuration,
|
|
5726
|
+
setupDuration,
|
|
5727
|
+
duration
|
|
5728
|
+
};
|
|
5729
|
+
}
|
|
5730
|
+
}
|
|
5731
|
+
function buildOptions(task) {
|
|
5732
|
+
return {
|
|
5733
|
+
each: task.each,
|
|
5734
|
+
concurrent: task.concurrent,
|
|
5735
|
+
shuffle: task.shuffle,
|
|
5736
|
+
retry: task.retry,
|
|
5737
|
+
repeats: task.repeats,
|
|
5738
|
+
mode: task.mode
|
|
5739
|
+
};
|
|
5740
|
+
}
|
|
5741
|
+
function getTestState(test) {
|
|
5742
|
+
const result = test.result();
|
|
5743
|
+
return result ? result.state : "running";
|
|
5744
|
+
}
|
|
5745
|
+
function storeTask(project, runnerTask, reportedTask) {
|
|
5746
|
+
project.ctx.state.reportedTasksMap.set(runnerTask, reportedTask);
|
|
5747
|
+
}
|
|
5748
|
+
function getReportedTask(project, runnerTask) {
|
|
5749
|
+
const reportedTask = project.ctx.state.getReportedEntity(runnerTask);
|
|
5750
|
+
if (!reportedTask) {
|
|
5751
|
+
throw new Error(`Task instance was not found for ${runnerTask.type} "${runnerTask.name}"`);
|
|
5752
|
+
}
|
|
5753
|
+
return reportedTask;
|
|
5754
|
+
}
|
|
5755
|
+
|
|
5488
5756
|
const outputMap = /* @__PURE__ */ new WeakMap();
|
|
5489
5757
|
function formatFilepath(path) {
|
|
5490
5758
|
const lastSlash = Math.max(path.lastIndexOf("/") + 1, 0);
|
|
@@ -5569,15 +5837,14 @@ function renderBenchmark(result, widths) {
|
|
|
5569
5837
|
].join(" ");
|
|
5570
5838
|
}
|
|
5571
5839
|
function renderTree(tasks, options, level = 0, shallow = false) {
|
|
5572
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
5573
5840
|
const output = [];
|
|
5574
5841
|
const benchMap = {};
|
|
5575
5842
|
for (const t of tasks) {
|
|
5576
|
-
if (t.meta.benchmark &&
|
|
5843
|
+
if (t.meta.benchmark && t.result?.benchmark) {
|
|
5577
5844
|
benchMap[t.id] = {
|
|
5578
5845
|
current: t.result.benchmark
|
|
5579
5846
|
};
|
|
5580
|
-
const baseline =
|
|
5847
|
+
const baseline = options.compare?.[t.id];
|
|
5581
5848
|
if (baseline) {
|
|
5582
5849
|
benchMap[t.id].baseline = {
|
|
5583
5850
|
...baseline,
|
|
@@ -5594,7 +5861,7 @@ function renderTree(tasks, options, level = 0, shallow = false) {
|
|
|
5594
5861
|
for (const task of tasks) {
|
|
5595
5862
|
const padding = " ".repeat(level ? 1 : 0);
|
|
5596
5863
|
let prefix = "";
|
|
5597
|
-
if (idx === 0 &&
|
|
5864
|
+
if (idx === 0 && task.meta?.benchmark) {
|
|
5598
5865
|
prefix += `${renderTableHead(columnWidths)}
|
|
5599
5866
|
${padding}`;
|
|
5600
5867
|
}
|
|
@@ -5606,14 +5873,14 @@ ${padding}`;
|
|
|
5606
5873
|
if (task.mode === "skip" || task.mode === "todo") {
|
|
5607
5874
|
suffix += ` ${c.dim(c.gray("[skipped]"))}`;
|
|
5608
5875
|
}
|
|
5609
|
-
if (
|
|
5876
|
+
if (task.result?.duration != null) {
|
|
5610
5877
|
if (task.result.duration > options.slowTestThreshold) {
|
|
5611
5878
|
suffix += c.yellow(
|
|
5612
5879
|
` ${Math.round(task.result.duration)}${c.dim("ms")}`
|
|
5613
5880
|
);
|
|
5614
5881
|
}
|
|
5615
5882
|
}
|
|
5616
|
-
if (options.showHeap &&
|
|
5883
|
+
if (options.showHeap && task.result?.heap != null) {
|
|
5617
5884
|
suffix += c.magenta(
|
|
5618
5885
|
` ${Math.floor(task.result.heap / 1024 / 1024)} MB heap used`
|
|
5619
5886
|
);
|
|
@@ -5653,7 +5920,7 @@ ${padding}`;
|
|
|
5653
5920
|
} else {
|
|
5654
5921
|
output.push(padding + prefix + name + suffix);
|
|
5655
5922
|
}
|
|
5656
|
-
if (
|
|
5923
|
+
if (task.result?.state !== "pass" && outputMap.get(task) != null) {
|
|
5657
5924
|
let data = outputMap.get(task);
|
|
5658
5925
|
if (typeof data === "string") {
|
|
5659
5926
|
data = stripAnsi(data.trim().split("\n").filter(Boolean).pop());
|
|
@@ -5667,7 +5934,7 @@ ${padding}`;
|
|
|
5667
5934
|
}
|
|
5668
5935
|
}
|
|
5669
5936
|
if (!shallow && task.type === "suite" && task.tasks.length > 0) {
|
|
5670
|
-
if (
|
|
5937
|
+
if (task.result?.state) {
|
|
5671
5938
|
output.push(renderTree(task.tasks, options, level + 1));
|
|
5672
5939
|
}
|
|
5673
5940
|
}
|
|
@@ -5727,14 +5994,13 @@ class TableReporter extends BaseReporter {
|
|
|
5727
5994
|
super.onWatcherStart();
|
|
5728
5995
|
}
|
|
5729
5996
|
async onCollected() {
|
|
5730
|
-
var _a, _b;
|
|
5731
5997
|
this.rendererOptions.logger = this.ctx.logger;
|
|
5732
5998
|
this.rendererOptions.showHeap = this.ctx.config.logHeapUsage;
|
|
5733
5999
|
this.rendererOptions.slowTestThreshold = this.ctx.config.slowTestThreshold;
|
|
5734
|
-
if (
|
|
6000
|
+
if (this.ctx.config.benchmark?.compare) {
|
|
5735
6001
|
const compareFile = pathe.resolve(
|
|
5736
6002
|
this.ctx.config.root,
|
|
5737
|
-
|
|
6003
|
+
this.ctx.config.benchmark?.compare
|
|
5738
6004
|
);
|
|
5739
6005
|
try {
|
|
5740
6006
|
this.rendererOptions.compare = flattenFormattedBenchmarkReport(
|
|
@@ -5759,18 +6025,14 @@ class TableReporter extends BaseReporter {
|
|
|
5759
6025
|
}
|
|
5760
6026
|
}
|
|
5761
6027
|
onTaskUpdate(packs) {
|
|
5762
|
-
var _a, _b;
|
|
5763
6028
|
if (this.isTTY) {
|
|
5764
6029
|
return;
|
|
5765
6030
|
}
|
|
5766
6031
|
for (const pack of packs) {
|
|
5767
6032
|
const task = this.ctx.state.idMap.get(pack[0]);
|
|
5768
|
-
if (task && task.type === "suite" &&
|
|
6033
|
+
if (task && task.type === "suite" && task.result?.state && task.result?.state !== "run") {
|
|
5769
6034
|
const benches = task.tasks.filter((t) => t.meta.benchmark);
|
|
5770
|
-
if (benches.length > 0 && benches.every((t) => {
|
|
5771
|
-
var _a2;
|
|
5772
|
-
return ((_a2 = t.result) == null ? void 0 : _a2.state) !== "run";
|
|
5773
|
-
})) {
|
|
6035
|
+
if (benches.length > 0 && benches.every((t) => t.result?.state !== "run")) {
|
|
5774
6036
|
let title = ` ${getStateSymbol(task)} ${getFullName(
|
|
5775
6037
|
task,
|
|
5776
6038
|
c.dim(" > ")
|
|
@@ -5789,11 +6051,10 @@ class TableReporter extends BaseReporter {
|
|
|
5789
6051
|
}
|
|
5790
6052
|
}
|
|
5791
6053
|
async onFinished(files = this.ctx.state.getFiles(), errors = this.ctx.state.getUnhandledErrors()) {
|
|
5792
|
-
var _a;
|
|
5793
6054
|
this.stopListRender();
|
|
5794
6055
|
this.ctx.logger.log();
|
|
5795
6056
|
super.onFinished(files, errors);
|
|
5796
|
-
let outputFile =
|
|
6057
|
+
let outputFile = this.ctx.config.benchmark?.outputJson;
|
|
5797
6058
|
if (outputFile) {
|
|
5798
6059
|
outputFile = pathe.resolve(this.ctx.config.root, outputFile);
|
|
5799
6060
|
const outputDirectory = pathe.dirname(outputFile);
|
|
@@ -5810,8 +6071,7 @@ class TableReporter extends BaseReporter {
|
|
|
5810
6071
|
await super.onWatcherStart();
|
|
5811
6072
|
}
|
|
5812
6073
|
stopListRender() {
|
|
5813
|
-
|
|
5814
|
-
(_a = this.renderer) == null ? void 0 : _a.stop();
|
|
6074
|
+
this.renderer?.stop();
|
|
5815
6075
|
this.renderer = void 0;
|
|
5816
6076
|
}
|
|
5817
6077
|
async onWatcherRerun(files, trigger) {
|
|
@@ -5819,16 +6079,14 @@ class TableReporter extends BaseReporter {
|
|
|
5819
6079
|
await super.onWatcherRerun(files, trigger);
|
|
5820
6080
|
}
|
|
5821
6081
|
onUserConsoleLog(log) {
|
|
5822
|
-
var _a;
|
|
5823
6082
|
if (!this.shouldLog(log)) {
|
|
5824
6083
|
return;
|
|
5825
6084
|
}
|
|
5826
|
-
|
|
6085
|
+
this.renderer?.clear();
|
|
5827
6086
|
super.onUserConsoleLog(log);
|
|
5828
6087
|
}
|
|
5829
6088
|
}
|
|
5830
6089
|
function createFormattedBenchmarkReport(files) {
|
|
5831
|
-
var _a;
|
|
5832
6090
|
const report = { files: [] };
|
|
5833
6091
|
for (const file of files) {
|
|
5834
6092
|
const groups = [];
|
|
@@ -5836,7 +6094,7 @@ function createFormattedBenchmarkReport(files) {
|
|
|
5836
6094
|
if (task && task.type === "suite") {
|
|
5837
6095
|
const benchmarks = [];
|
|
5838
6096
|
for (const t of task.tasks) {
|
|
5839
|
-
const benchmark = t.meta.benchmark &&
|
|
6097
|
+
const benchmark = t.meta.benchmark && t.result?.benchmark;
|
|
5840
6098
|
if (benchmark) {
|
|
5841
6099
|
const { samples, ...rest } = benchmark;
|
|
5842
6100
|
benchmarks.push({
|
|
@@ -5893,4 +6151,4 @@ const ReportersMap = {
|
|
|
5893
6151
|
"github-actions": GithubActionsReporter
|
|
5894
6152
|
};
|
|
5895
6153
|
|
|
5896
|
-
export { BasicReporter 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, DotReporter as a, JUnitReporter as b, TapFlatReporter as c,
|
|
6154
|
+
export { BasicReporter 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, DotReporter as a, JUnitReporter as b, TapFlatReporter as c, TestCase as d, TestFile as e, TestSuite as f, BenchmarkReportsMap as g, BaseSequencer as h, TestProject as i, Typechecker as j, RandomSequencer as k, findNodeAround as l, generateCodeFrame as m, highlightCode as n, BlobReporter as o, parse as p, readBlobs as r, stringify as s, wrapSerializableConfig as w };
|