vitest 2.0.4 → 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/dist/browser.d.ts +21 -42
- package/dist/browser.js +5 -5
- package/dist/{vendor/base.Csk7BT3h.js → chunks/base.CC5R_kgU.js} +3 -3
- package/dist/{vendor/base.DRHPZCCj.js → chunks/base.DSsbfkDg.js} +1 -1
- 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.DFtWvZc2.js → chunks/cac.DGgmCKmU.js} +17 -20
- package/dist/{vendor/cli-api.CTkP2Ier.js → chunks/cli-api.OKfd3qJ0.js} +416 -423
- 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.jzOWtys_.js → chunks/execute.Cjlr2CRw.js} +27 -19
- package/dist/chunks/globals.BliuJFNR.js +31 -0
- package/dist/{vendor/index.DI9daj1Q.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.CuuL9y4g.js → chunks/index.JbiJutJ_.js} +515 -255
- package/dist/{vendor/index.CVqMv71L.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-B7ebVMkT.d.ts → chunks/reporters.C_zwCd4j.d.ts} +847 -1000
- 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.Dq_sJZq9.js → runBaseTests.CyvqmuC9.js} +21 -23
- package/dist/{vendor/setup-common.symvFZPh.js → chunks/setup-common.CNzatKMx.js} +2 -2
- package/dist/{suite-CRLAhsm0.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.BySfPUwy.js → chunks/utils.DpP_sDwr.js} +8 -21
- package/dist/{vendor/vi.Elqer9-7.js → chunks/vi.fiQ7lMRF.js} +13 -18
- package/dist/{vendor/vm.img-AOox.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 -8
- package/dist/config.d.ts +10 -8
- package/dist/config.js +6 -8
- package/dist/coverage.d.ts +10 -8
- package/dist/coverage.js +2 -2
- package/dist/environments.d.ts +3 -19
- package/dist/environments.js +1 -1
- package/dist/execute.d.ts +5 -14
- 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 +18 -19
- 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 +13 -13
- package/dist/chunks/integrations-globals.nDMtdOcn.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 { g as getTestName, h as hasFailedSnapshot, a as getFullName } from './tasks.DhVtQBtW.js';
|
|
6
6
|
import { notNullish, highlight, shuffle, inspect, positionToOffset, lineSplitRE } from '@vitest/utils';
|
|
7
|
-
import { i as isNode, a as isDeno } from './env.
|
|
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.
|
|
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.DRHPZCCj.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
|
}
|
|
@@ -1241,14 +1222,13 @@ ${PROJECT_FILTER}${FILENAME_PATTERN}${TESTNAME_PATTERN}`
|
|
|
1241
1222
|
this.start = performance.now();
|
|
1242
1223
|
}
|
|
1243
1224
|
onUserConsoleLog(log) {
|
|
1244
|
-
var _a;
|
|
1245
1225
|
if (!this.shouldLog(log)) {
|
|
1246
1226
|
return;
|
|
1247
1227
|
}
|
|
1248
1228
|
const task = log.taskId ? this.ctx.state.idMap.get(log.taskId) : void 0;
|
|
1249
1229
|
const header = c.gray(
|
|
1250
1230
|
log.type + c.dim(
|
|
1251
|
-
` | ${task ? getFullName(task, c.dim(" > ")) : log.taskId !==
|
|
1231
|
+
` | ${task ? getFullName(task, c.dim(" > ")) : log.taskId !== "__vitest__unknown_test__" ? log.taskId : "unknown test"}`
|
|
1252
1232
|
)
|
|
1253
1233
|
);
|
|
1254
1234
|
const output = log.type === "stdout" ? this.ctx.logger.outputStream : this.ctx.logger.errorStream;
|
|
@@ -1260,7 +1240,7 @@ ${log.content}`);
|
|
|
1260
1240
|
write("\n");
|
|
1261
1241
|
}
|
|
1262
1242
|
const project = log.taskId ? this.ctx.getProjectByTaskId(log.taskId) : this.ctx.getCoreWorkspaceProject();
|
|
1263
|
-
const stack = log.browser ?
|
|
1243
|
+
const stack = log.browser ? project.browser?.parseStacktrace(log.origin) || [] : parseStacktrace(log.origin);
|
|
1264
1244
|
const highlight = task ? stack.find((i) => i.file === task.file.filepath) : null;
|
|
1265
1245
|
for (const frame of stack) {
|
|
1266
1246
|
const color = frame === highlight ? c.cyan : c.gray;
|
|
@@ -1279,11 +1259,10 @@ ${log.content}`);
|
|
|
1279
1259
|
write("\n");
|
|
1280
1260
|
}
|
|
1281
1261
|
shouldLog(log) {
|
|
1282
|
-
var _a, _b;
|
|
1283
1262
|
if (this.ctx.config.silent) {
|
|
1284
1263
|
return false;
|
|
1285
1264
|
}
|
|
1286
|
-
const shouldLog =
|
|
1265
|
+
const shouldLog = this.ctx.config.onConsoleLog?.(log.content, log.type);
|
|
1287
1266
|
if (shouldLog === false) {
|
|
1288
1267
|
return shouldLog;
|
|
1289
1268
|
}
|
|
@@ -1323,10 +1302,7 @@ ${log.content}`);
|
|
|
1323
1302
|
0
|
|
1324
1303
|
);
|
|
1325
1304
|
const testsTime = files.reduce(
|
|
1326
|
-
(acc, test) =>
|
|
1327
|
-
var _a;
|
|
1328
|
-
return acc + Math.max(0, ((_a = test.result) == null ? void 0 : _a.duration) || 0);
|
|
1329
|
-
},
|
|
1305
|
+
(acc, test) => acc + Math.max(0, test.result?.duration || 0),
|
|
1330
1306
|
0
|
|
1331
1307
|
);
|
|
1332
1308
|
const transformTime = this.ctx.projects.flatMap((w) => w.vitenode.getTotalDuration()).reduce((a, b) => a + b, 0);
|
|
@@ -1364,10 +1340,7 @@ ${log.content}`);
|
|
|
1364
1340
|
logger.log(padTitle("Tests"), getStateString(tests));
|
|
1365
1341
|
if (this.ctx.projects.some((c2) => c2.config.typecheck.enabled)) {
|
|
1366
1342
|
const failed = tests.filter(
|
|
1367
|
-
(t) =>
|
|
1368
|
-
var _a, _b, _c;
|
|
1369
|
-
return ((_a = t.meta) == null ? void 0 : _a.typecheck) && ((_c = (_b = t.result) == null ? void 0 : _b.errors) == null ? void 0 : _c.length);
|
|
1370
|
-
}
|
|
1343
|
+
(t) => t.meta?.typecheck && t.result?.errors?.length
|
|
1371
1344
|
);
|
|
1372
1345
|
logger.log(
|
|
1373
1346
|
padTitle("Type Errors"),
|
|
@@ -1390,10 +1363,7 @@ ${log.content}`);
|
|
|
1390
1363
|
testsTime
|
|
1391
1364
|
)}, environment ${time(environmentTime)}, prepare ${time(prepareTime)}`;
|
|
1392
1365
|
const typecheck = this.ctx.projects.reduce(
|
|
1393
|
-
(acc, c2) =>
|
|
1394
|
-
var _a;
|
|
1395
|
-
return acc + (((_a = c2.typechecker) == null ? void 0 : _a.getResult().time) || 0);
|
|
1396
|
-
},
|
|
1366
|
+
(acc, c2) => acc + (c2.typechecker?.getResult().time || 0),
|
|
1397
1367
|
0
|
|
1398
1368
|
);
|
|
1399
1369
|
if (typecheck) {
|
|
@@ -1410,14 +1380,8 @@ ${log.content}`);
|
|
|
1410
1380
|
const logger = this.ctx.logger;
|
|
1411
1381
|
const suites = getSuites(files);
|
|
1412
1382
|
const tests = getTests(files);
|
|
1413
|
-
const failedSuites = suites.filter((i) =>
|
|
1414
|
-
|
|
1415
|
-
return (_a = i.result) == null ? void 0 : _a.errors;
|
|
1416
|
-
});
|
|
1417
|
-
const failedTests = tests.filter((i) => {
|
|
1418
|
-
var _a;
|
|
1419
|
-
return ((_a = i.result) == null ? void 0 : _a.state) === "fail";
|
|
1420
|
-
});
|
|
1383
|
+
const failedSuites = suites.filter((i) => i.result?.errors);
|
|
1384
|
+
const failedTests = tests.filter((i) => i.result?.state === "fail");
|
|
1421
1385
|
const failedTotal = countTestErrors(failedSuites) + countTestErrors(failedTests);
|
|
1422
1386
|
let current = 1;
|
|
1423
1387
|
const errorDivider = () => logger.error(
|
|
@@ -1453,10 +1417,7 @@ ${log.content}`);
|
|
|
1453
1417
|
reportBenchmarkSummary(files) {
|
|
1454
1418
|
const logger = this.ctx.logger;
|
|
1455
1419
|
const benches = getTests(files);
|
|
1456
|
-
const topBenches = benches.filter((i) =>
|
|
1457
|
-
var _a, _b;
|
|
1458
|
-
return ((_b = (_a = i.result) == null ? void 0 : _a.benchmark) == null ? void 0 : _b.rank) === 1;
|
|
1459
|
-
});
|
|
1420
|
+
const topBenches = benches.filter((i) => i.result?.benchmark?.rank === 1);
|
|
1460
1421
|
logger.log(
|
|
1461
1422
|
`
|
|
1462
1423
|
${c.cyan(c.inverse(c.bold(" BENCH ")))} ${c.cyan("Summary")}
|
|
@@ -1469,10 +1430,7 @@ ${c.cyan(c.inverse(c.bold(" BENCH ")))} ${c.cyan("Summary")}
|
|
|
1469
1430
|
}
|
|
1470
1431
|
const groupName = getFullName(group, c.dim(" > "));
|
|
1471
1432
|
logger.log(` ${bench.name}${c.dim(` - ${groupName}`)}`);
|
|
1472
|
-
const siblings = group.tasks.filter((i) =>
|
|
1473
|
-
var _a;
|
|
1474
|
-
return i.meta.benchmark && ((_a = i.result) == null ? void 0 : _a.benchmark) && i !== bench;
|
|
1475
|
-
}).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);
|
|
1476
1434
|
if (siblings.length === 0) {
|
|
1477
1435
|
logger.log("");
|
|
1478
1436
|
continue;
|
|
@@ -1487,18 +1445,16 @@ ${c.cyan(c.inverse(c.bold(" BENCH ")))} ${c.cyan("Summary")}
|
|
|
1487
1445
|
}
|
|
1488
1446
|
}
|
|
1489
1447
|
printTaskErrors(tasks, errorDivider) {
|
|
1490
|
-
var _a, _b, _c;
|
|
1491
1448
|
const errorsQueue = [];
|
|
1492
1449
|
for (const task of tasks) {
|
|
1493
|
-
|
|
1494
|
-
const errorItem =
|
|
1495
|
-
|
|
1496
|
-
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;
|
|
1497
1453
|
if (!hasStr) {
|
|
1498
1454
|
return false;
|
|
1499
1455
|
}
|
|
1500
|
-
const currentProjectName =
|
|
1501
|
-
const projectName =
|
|
1456
|
+
const currentProjectName = task?.projectName || task.file?.projectName || "";
|
|
1457
|
+
const projectName = i[1][0]?.projectName || i[1][0].file?.projectName || "";
|
|
1502
1458
|
return projectName === currentProjectName;
|
|
1503
1459
|
});
|
|
1504
1460
|
if (errorItem) {
|
|
@@ -1510,8 +1466,8 @@ ${c.cyan(c.inverse(c.bold(" BENCH ")))} ${c.cyan("Summary")}
|
|
|
1510
1466
|
}
|
|
1511
1467
|
for (const [error, tasks2] of errorsQueue) {
|
|
1512
1468
|
for (const task of tasks2) {
|
|
1513
|
-
const filepath =
|
|
1514
|
-
const projectName =
|
|
1469
|
+
const filepath = task?.filepath || "";
|
|
1470
|
+
const projectName = task?.projectName || task.file?.projectName || "";
|
|
1515
1471
|
let name = getFullName(task, c.dim(" > "));
|
|
1516
1472
|
if (filepath) {
|
|
1517
1473
|
name = `${name} ${c.dim(`[ ${this.relative(filepath)} ]`)}`;
|
|
@@ -1522,13 +1478,7 @@ ${c.cyan(c.inverse(c.bold(" BENCH ")))} ${c.cyan("Summary")}
|
|
|
1522
1478
|
)}${name}`
|
|
1523
1479
|
);
|
|
1524
1480
|
}
|
|
1525
|
-
const screenshots = tasks2.filter((t) =>
|
|
1526
|
-
var _a2;
|
|
1527
|
-
return (_a2 = t.meta) == null ? void 0 : _a2.failScreenshotPath;
|
|
1528
|
-
}).map((t) => {
|
|
1529
|
-
var _a2;
|
|
1530
|
-
return (_a2 = t.meta) == null ? void 0 : _a2.failScreenshotPath;
|
|
1531
|
-
});
|
|
1481
|
+
const screenshots = tasks2.filter((t) => t.meta?.failScreenshotPath).map((t) => t.meta?.failScreenshotPath);
|
|
1532
1482
|
const project = this.ctx.getProjectByTaskId(tasks2[0].id);
|
|
1533
1483
|
this.ctx.logger.printError(error, {
|
|
1534
1484
|
project,
|
|
@@ -2478,8 +2428,7 @@ function formatNumber$1(number) {
|
|
|
2478
2428
|
return res[0].replace(/(?=(?:\d{3})+$)\B/g, ",") + (res[1] ? `.${res[1]}` : "");
|
|
2479
2429
|
}
|
|
2480
2430
|
function renderHookState(task, hookName, level = 0) {
|
|
2481
|
-
|
|
2482
|
-
const state = (_b = (_a = task.result) == null ? void 0 : _a.hooks) == null ? void 0 : _b[hookName];
|
|
2431
|
+
const state = task.result?.hooks?.[hookName];
|
|
2483
2432
|
if (state && state === "run") {
|
|
2484
2433
|
return `${" ".repeat(level)} ${getHookStateSymbol(task, hookName)} ${c.dim(
|
|
2485
2434
|
`[ ${hookName} ]`
|
|
@@ -2497,15 +2446,11 @@ function renderBenchmarkItems$1(result) {
|
|
|
2497
2446
|
];
|
|
2498
2447
|
}
|
|
2499
2448
|
function renderBenchmark$1(task, tasks) {
|
|
2500
|
-
|
|
2501
|
-
const result = (_a = task.result) == null ? void 0 : _a.benchmark;
|
|
2449
|
+
const result = task.result?.benchmark;
|
|
2502
2450
|
if (!result) {
|
|
2503
2451
|
return task.name;
|
|
2504
2452
|
}
|
|
2505
|
-
const benches = tasks.map((i) =>
|
|
2506
|
-
var _a2, _b;
|
|
2507
|
-
return ((_a2 = i.meta) == null ? void 0 : _a2.benchmark) ? (_b = i.result) == null ? void 0 : _b.benchmark : void 0;
|
|
2508
|
-
}).filter(notNullish);
|
|
2453
|
+
const benches = tasks.map((i) => i.meta?.benchmark ? i.result?.benchmark : void 0).filter(notNullish);
|
|
2509
2454
|
const allItems = benches.map(renderBenchmarkItems$1);
|
|
2510
2455
|
const items = renderBenchmarkItems$1(result);
|
|
2511
2456
|
const padded = items.map((i, idx) => {
|
|
@@ -2524,7 +2469,6 @@ function renderBenchmark$1(task, tasks) {
|
|
|
2524
2469
|
].join("");
|
|
2525
2470
|
}
|
|
2526
2471
|
function renderTree$1(tasks, options, level = 0, maxRows) {
|
|
2527
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
2528
2472
|
const output = [];
|
|
2529
2473
|
let currentRowCount = 0;
|
|
2530
2474
|
for (const task of [...tasks].reverse()) {
|
|
@@ -2534,7 +2478,7 @@ function renderTree$1(tasks, options, level = 0, maxRows) {
|
|
|
2534
2478
|
if (level === 0 && task.type === "suite" && "projectName" in task) {
|
|
2535
2479
|
prefix += formatProjectName(task.projectName);
|
|
2536
2480
|
}
|
|
2537
|
-
if (task.type === "test" &&
|
|
2481
|
+
if (task.type === "test" && task.result?.retryCount && task.result.retryCount > 0) {
|
|
2538
2482
|
suffix += c.yellow(` (retry x${task.result.retryCount})`);
|
|
2539
2483
|
}
|
|
2540
2484
|
if (task.type === "suite") {
|
|
@@ -2544,17 +2488,17 @@ function renderTree$1(tasks, options, level = 0, maxRows) {
|
|
|
2544
2488
|
if (task.mode === "skip" || task.mode === "todo") {
|
|
2545
2489
|
suffix += ` ${c.dim(c.gray("[skipped]"))}`;
|
|
2546
2490
|
}
|
|
2547
|
-
if (task.type === "test" &&
|
|
2491
|
+
if (task.type === "test" && task.result?.repeatCount && task.result.repeatCount > 0) {
|
|
2548
2492
|
suffix += c.yellow(` (repeat x${task.result.repeatCount})`);
|
|
2549
2493
|
}
|
|
2550
|
-
if (
|
|
2494
|
+
if (task.result?.duration != null) {
|
|
2551
2495
|
if (task.result.duration > options.slowTestThreshold) {
|
|
2552
2496
|
suffix += c.yellow(
|
|
2553
2497
|
` ${Math.round(task.result.duration)}${c.dim("ms")}`
|
|
2554
2498
|
);
|
|
2555
2499
|
}
|
|
2556
2500
|
}
|
|
2557
|
-
if (options.showHeap &&
|
|
2501
|
+
if (options.showHeap && task.result?.heap != null) {
|
|
2558
2502
|
suffix += c.magenta(
|
|
2559
2503
|
` ${Math.floor(task.result.heap / 1024 / 1024)} MB heap used`
|
|
2560
2504
|
);
|
|
@@ -2564,9 +2508,9 @@ function renderTree$1(tasks, options, level = 0, maxRows) {
|
|
|
2564
2508
|
name = formatFilepath$1(name);
|
|
2565
2509
|
}
|
|
2566
2510
|
const padding = " ".repeat(level);
|
|
2567
|
-
const body =
|
|
2511
|
+
const body = task.meta?.benchmark ? renderBenchmark$1(task, tasks) : name;
|
|
2568
2512
|
taskOutput.push(padding + prefix + body + suffix);
|
|
2569
|
-
if (
|
|
2513
|
+
if (task.result?.state !== "pass" && outputMap$1.get(task) != null) {
|
|
2570
2514
|
let data = outputMap$1.get(task);
|
|
2571
2515
|
if (typeof data === "string") {
|
|
2572
2516
|
data = stripAnsi(data.trim().split("\n").filter(Boolean).pop());
|
|
@@ -2582,7 +2526,7 @@ function renderTree$1(tasks, options, level = 0, maxRows) {
|
|
|
2582
2526
|
taskOutput.push(renderHookState(task, "beforeAll", level + 1));
|
|
2583
2527
|
taskOutput.push(renderHookState(task, "beforeEach", level + 1));
|
|
2584
2528
|
if (task.type === "suite" && task.tasks.length > 0) {
|
|
2585
|
-
if (
|
|
2529
|
+
if (task.result?.state === "fail" || task.result?.state === "run" || options.renderSucceed) {
|
|
2586
2530
|
if (options.logger.ctx.config.hideSkippedTests) {
|
|
2587
2531
|
const filteredTasks = task.tasks.filter(
|
|
2588
2532
|
(t) => t.mode !== "skip" && t.mode !== "todo"
|
|
@@ -2714,8 +2658,7 @@ class DefaultReporter extends BaseReporter {
|
|
|
2714
2658
|
}
|
|
2715
2659
|
}
|
|
2716
2660
|
onFinished(files = this.ctx.state.getFiles(), errors = this.ctx.state.getUnhandledErrors()) {
|
|
2717
|
-
|
|
2718
|
-
(_a = this.renderer) == null ? void 0 : _a.update([
|
|
2661
|
+
this.renderer?.update([
|
|
2719
2662
|
...this.failedUnwatchedFiles,
|
|
2720
2663
|
...files
|
|
2721
2664
|
]);
|
|
@@ -2728,8 +2671,7 @@ class DefaultReporter extends BaseReporter {
|
|
|
2728
2671
|
await super.onWatcherStart(files, errors);
|
|
2729
2672
|
}
|
|
2730
2673
|
stopListRender() {
|
|
2731
|
-
|
|
2732
|
-
(_a = this.renderer) == null ? void 0 : _a.stop();
|
|
2674
|
+
this.renderer?.stop();
|
|
2733
2675
|
this.renderer = void 0;
|
|
2734
2676
|
}
|
|
2735
2677
|
async onWatcherRerun(files, trigger) {
|
|
@@ -2737,11 +2679,10 @@ class DefaultReporter extends BaseReporter {
|
|
|
2737
2679
|
await super.onWatcherRerun(files, trigger);
|
|
2738
2680
|
}
|
|
2739
2681
|
onUserConsoleLog(log) {
|
|
2740
|
-
var _a;
|
|
2741
2682
|
if (!this.shouldLog(log)) {
|
|
2742
2683
|
return;
|
|
2743
2684
|
}
|
|
2744
|
-
|
|
2685
|
+
this.renderer?.clear();
|
|
2745
2686
|
super.onUserConsoleLog(log);
|
|
2746
2687
|
}
|
|
2747
2688
|
}
|
|
@@ -2751,11 +2692,10 @@ const cross = { char: "x", color: c.red };
|
|
|
2751
2692
|
const pending = { char: "*", color: c.yellow };
|
|
2752
2693
|
const skip = { char: "-", color: (char) => c.dim(c.gray(char)) };
|
|
2753
2694
|
function getIcon(task) {
|
|
2754
|
-
var _a;
|
|
2755
2695
|
if (task.mode === "skip" || task.mode === "todo") {
|
|
2756
2696
|
return skip;
|
|
2757
2697
|
}
|
|
2758
|
-
switch (
|
|
2698
|
+
switch (task.result?.state) {
|
|
2759
2699
|
case "pass":
|
|
2760
2700
|
return check;
|
|
2761
2701
|
case "fail":
|
|
@@ -2865,8 +2805,7 @@ class DotReporter extends BaseReporter {
|
|
|
2865
2805
|
super.onWatcherStart();
|
|
2866
2806
|
}
|
|
2867
2807
|
async stopListRender() {
|
|
2868
|
-
|
|
2869
|
-
(_a = this.renderer) == null ? void 0 : _a.stop();
|
|
2808
|
+
this.renderer?.stop();
|
|
2870
2809
|
this.renderer = void 0;
|
|
2871
2810
|
await new Promise((resolve) => setTimeout(resolve, 10));
|
|
2872
2811
|
}
|
|
@@ -2875,8 +2814,7 @@ class DotReporter extends BaseReporter {
|
|
|
2875
2814
|
super.onWatcherRerun(files, trigger);
|
|
2876
2815
|
}
|
|
2877
2816
|
onUserConsoleLog(log) {
|
|
2878
|
-
|
|
2879
|
-
(_a = this.renderer) == null ? void 0 : _a.clear();
|
|
2817
|
+
this.renderer?.clear();
|
|
2880
2818
|
super.onUserConsoleLog(log);
|
|
2881
2819
|
}
|
|
2882
2820
|
}
|
|
@@ -2901,34 +2839,21 @@ class JsonReporter {
|
|
|
2901
2839
|
this.start = Date.now();
|
|
2902
2840
|
}
|
|
2903
2841
|
async logTasks(files) {
|
|
2904
|
-
var _a, _b, _c, _d;
|
|
2905
2842
|
const suites = getSuites(files);
|
|
2906
2843
|
const numTotalTestSuites = suites.length;
|
|
2907
2844
|
const tests = getTests(files);
|
|
2908
2845
|
const numTotalTests = tests.length;
|
|
2909
|
-
const numFailedTestSuites = suites.filter((s) =>
|
|
2910
|
-
var _a2;
|
|
2911
|
-
return (_a2 = s.result) == null ? void 0 : _a2.errors;
|
|
2912
|
-
}).length;
|
|
2846
|
+
const numFailedTestSuites = suites.filter((s) => s.result?.errors).length;
|
|
2913
2847
|
const numPassedTestSuites = numTotalTestSuites - numFailedTestSuites;
|
|
2914
2848
|
const numPendingTestSuites = suites.filter(
|
|
2915
|
-
(s) =>
|
|
2916
|
-
var _a2;
|
|
2917
|
-
return ((_a2 = s.result) == null ? void 0 : _a2.state) === "run";
|
|
2918
|
-
}
|
|
2849
|
+
(s) => s.result?.state === "run"
|
|
2919
2850
|
).length;
|
|
2920
2851
|
const numFailedTests = tests.filter(
|
|
2921
|
-
(t) =>
|
|
2922
|
-
var _a2;
|
|
2923
|
-
return ((_a2 = t.result) == null ? void 0 : _a2.state) === "fail";
|
|
2924
|
-
}
|
|
2852
|
+
(t) => t.result?.state === "fail"
|
|
2925
2853
|
).length;
|
|
2926
2854
|
const numPassedTests = numTotalTests - numFailedTests;
|
|
2927
2855
|
const numPendingTests = tests.filter(
|
|
2928
|
-
(t) =>
|
|
2929
|
-
var _a2;
|
|
2930
|
-
return ((_a2 = t.result) == null ? void 0 : _a2.state) === "run";
|
|
2931
|
-
}
|
|
2856
|
+
(t) => t.result?.state === "run"
|
|
2932
2857
|
).length;
|
|
2933
2858
|
const numTodoTests = tests.filter((t) => t.mode === "todo").length;
|
|
2934
2859
|
const testResults = [];
|
|
@@ -2936,27 +2861,20 @@ class JsonReporter {
|
|
|
2936
2861
|
for (const file of files) {
|
|
2937
2862
|
const tests2 = getTests([file]);
|
|
2938
2863
|
let startTime = tests2.reduce(
|
|
2939
|
-
(prev, next) =>
|
|
2940
|
-
var _a2;
|
|
2941
|
-
return Math.min(prev, ((_a2 = next.result) == null ? void 0 : _a2.startTime) ?? Number.POSITIVE_INFINITY);
|
|
2942
|
-
},
|
|
2864
|
+
(prev, next) => Math.min(prev, next.result?.startTime ?? Number.POSITIVE_INFINITY),
|
|
2943
2865
|
Number.POSITIVE_INFINITY
|
|
2944
2866
|
);
|
|
2945
2867
|
if (startTime === Number.POSITIVE_INFINITY) {
|
|
2946
2868
|
startTime = this.start;
|
|
2947
2869
|
}
|
|
2948
2870
|
const endTime = tests2.reduce(
|
|
2949
|
-
(prev, next) =>
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
(((_a2 = next.result) == null ? void 0 : _a2.startTime) ?? 0) + (((_b2 = next.result) == null ? void 0 : _b2.duration) ?? 0)
|
|
2954
|
-
);
|
|
2955
|
-
},
|
|
2871
|
+
(prev, next) => Math.max(
|
|
2872
|
+
prev,
|
|
2873
|
+
(next.result?.startTime ?? 0) + (next.result?.duration ?? 0)
|
|
2874
|
+
),
|
|
2956
2875
|
startTime
|
|
2957
2876
|
);
|
|
2958
2877
|
const assertionResults = tests2.map((t) => {
|
|
2959
|
-
var _a2, _b2, _c2, _d2;
|
|
2960
2878
|
const ancestorTitles = [];
|
|
2961
2879
|
let iter = t.suite;
|
|
2962
2880
|
while (iter) {
|
|
@@ -2967,32 +2885,26 @@ class JsonReporter {
|
|
|
2967
2885
|
return {
|
|
2968
2886
|
ancestorTitles,
|
|
2969
2887
|
fullName: t.name ? [...ancestorTitles, t.name].join(" ") : ancestorTitles.join(" "),
|
|
2970
|
-
status: StatusMap[
|
|
2888
|
+
status: StatusMap[t.result?.state || t.mode] || "skipped",
|
|
2971
2889
|
title: t.name,
|
|
2972
|
-
duration:
|
|
2973
|
-
failureMessages:
|
|
2890
|
+
duration: t.result?.duration,
|
|
2891
|
+
failureMessages: t.result?.errors?.map((e) => e.stack || e.message) || [],
|
|
2974
2892
|
location: t.location,
|
|
2975
2893
|
meta: t.meta
|
|
2976
2894
|
};
|
|
2977
2895
|
});
|
|
2978
|
-
if (tests2.some((t) => {
|
|
2979
|
-
var _a2;
|
|
2980
|
-
return ((_a2 = t.result) == null ? void 0 : _a2.state) === "run";
|
|
2981
|
-
})) {
|
|
2896
|
+
if (tests2.some((t) => t.result?.state === "run")) {
|
|
2982
2897
|
this.ctx.logger.warn(
|
|
2983
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"
|
|
2984
2899
|
);
|
|
2985
2900
|
}
|
|
2986
|
-
const hasFailedTests = tests2.some((t) =>
|
|
2987
|
-
var _a2;
|
|
2988
|
-
return ((_a2 = t.result) == null ? void 0 : _a2.state) === "fail";
|
|
2989
|
-
});
|
|
2901
|
+
const hasFailedTests = tests2.some((t) => t.result?.state === "fail");
|
|
2990
2902
|
testResults.push({
|
|
2991
2903
|
assertionResults,
|
|
2992
2904
|
startTime,
|
|
2993
2905
|
endTime,
|
|
2994
|
-
status:
|
|
2995
|
-
message:
|
|
2906
|
+
status: file.result?.state === "fail" || hasFailedTests ? "failed" : "passed",
|
|
2907
|
+
message: file.result?.errors?.[0]?.message ?? "",
|
|
2996
2908
|
name: file.filepath
|
|
2997
2909
|
});
|
|
2998
2910
|
}
|
|
@@ -3044,13 +2956,12 @@ class VerboseReporter extends DefaultReporter {
|
|
|
3044
2956
|
this.rendererOptions.renderSucceed = true;
|
|
3045
2957
|
}
|
|
3046
2958
|
onTaskUpdate(packs) {
|
|
3047
|
-
var _a, _b, _c;
|
|
3048
2959
|
if (this.isTTY) {
|
|
3049
2960
|
return;
|
|
3050
2961
|
}
|
|
3051
2962
|
for (const pack of packs) {
|
|
3052
2963
|
const task = this.ctx.state.idMap.get(pack[0]);
|
|
3053
|
-
if (task && task.type === "test" &&
|
|
2964
|
+
if (task && task.type === "test" && task.result?.state && task.result?.state !== "run") {
|
|
3054
2965
|
let title = ` ${getStateSymbol(task)} `;
|
|
3055
2966
|
if (task.file.projectName) {
|
|
3056
2967
|
title += formatProjectName(task.file.projectName);
|
|
@@ -3068,8 +2979,8 @@ class VerboseReporter extends DefaultReporter {
|
|
|
3068
2979
|
}
|
|
3069
2980
|
this.ctx.logger.log(title);
|
|
3070
2981
|
if (task.result.state === "fail") {
|
|
3071
|
-
|
|
3072
|
-
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}`));
|
|
3073
2984
|
});
|
|
3074
2985
|
}
|
|
3075
2986
|
}
|
|
@@ -3110,12 +3021,11 @@ class TapReporter {
|
|
|
3110
3021
|
this.logger = new IndentedLogger(ctx.logger.log.bind(ctx.logger));
|
|
3111
3022
|
}
|
|
3112
3023
|
static getComment(task) {
|
|
3113
|
-
var _a;
|
|
3114
3024
|
if (task.mode === "skip") {
|
|
3115
3025
|
return " # SKIP";
|
|
3116
3026
|
} else if (task.mode === "todo") {
|
|
3117
3027
|
return " # TODO";
|
|
3118
|
-
} else if (
|
|
3028
|
+
} else if (task.result?.duration != null) {
|
|
3119
3029
|
return ` # time=${task.result.duration.toFixed(2)}ms`;
|
|
3120
3030
|
} else {
|
|
3121
3031
|
return "";
|
|
@@ -3132,11 +3042,10 @@ class TapReporter {
|
|
|
3132
3042
|
}
|
|
3133
3043
|
}
|
|
3134
3044
|
logTasks(tasks) {
|
|
3135
|
-
var _a, _b;
|
|
3136
3045
|
this.logger.log(`1..${tasks.length}`);
|
|
3137
3046
|
for (const [i, task] of tasks.entries()) {
|
|
3138
3047
|
const id = i + 1;
|
|
3139
|
-
const ok =
|
|
3048
|
+
const ok = task.result?.state === "pass" || task.mode === "skip" || task.mode === "todo" ? "ok" : "not ok";
|
|
3140
3049
|
const comment = TapReporter.getComment(task);
|
|
3141
3050
|
if (task.type === "suite" && task.tasks.length > 0) {
|
|
3142
3051
|
this.logger.log(`${ok} ${id} - ${tapString(task.name)}${comment} {`);
|
|
@@ -3147,11 +3056,10 @@ class TapReporter {
|
|
|
3147
3056
|
} else {
|
|
3148
3057
|
this.logger.log(`${ok} ${id} - ${tapString(task.name)}${comment}`);
|
|
3149
3058
|
const project = this.ctx.getProjectByTaskId(task.id);
|
|
3150
|
-
if (
|
|
3059
|
+
if (task.result?.state === "fail" && task.result.errors) {
|
|
3151
3060
|
this.logger.indent();
|
|
3152
3061
|
task.result.errors.forEach((error) => {
|
|
3153
|
-
|
|
3154
|
-
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, {
|
|
3155
3063
|
frameFilter: this.ctx.config.onStackTrace
|
|
3156
3064
|
});
|
|
3157
3065
|
const stack = stacks[0];
|
|
@@ -4416,7 +4324,7 @@ class BaseSequencer {
|
|
|
4416
4324
|
const shardEnd = shardSize * index;
|
|
4417
4325
|
return [...files].map((spec) => {
|
|
4418
4326
|
const fullPath = resolve(slash(config.root), slash(spec[1]));
|
|
4419
|
-
const specPath = fullPath
|
|
4327
|
+
const specPath = fullPath?.slice(config.root.length);
|
|
4420
4328
|
return {
|
|
4421
4329
|
spec,
|
|
4422
4330
|
hash: createHash("sha1").update(specPath).digest("hex")
|
|
@@ -4522,8 +4430,7 @@ class Logger {
|
|
|
4522
4430
|
printProperties: options.verbose,
|
|
4523
4431
|
screenshotPaths: options.screenshotPaths,
|
|
4524
4432
|
parseErrorStacktrace: (error) => {
|
|
4525
|
-
|
|
4526
|
-
if (((_a = options.task) == null ? void 0 : _a.file.pool) === "browser" && project.browser) {
|
|
4433
|
+
if (options.task?.file.pool === "browser" && project.browser) {
|
|
4527
4434
|
return project.browser.parseErrorStacktrace(error, {
|
|
4528
4435
|
ignoreStackEntries: fullStack ? [] : void 0
|
|
4529
4436
|
});
|
|
@@ -4551,10 +4458,9 @@ class Logger {
|
|
|
4551
4458
|
return code;
|
|
4552
4459
|
}
|
|
4553
4460
|
printNoTestFound(filters) {
|
|
4554
|
-
var _a;
|
|
4555
4461
|
const config = this.ctx.config;
|
|
4556
4462
|
const comma = c.dim(", ");
|
|
4557
|
-
if (filters
|
|
4463
|
+
if (filters?.length) {
|
|
4558
4464
|
this.console.error(c.dim("filter: ") + c.yellow(filters.join(comma)));
|
|
4559
4465
|
}
|
|
4560
4466
|
const projectsFilter = toArray(config.project);
|
|
@@ -4589,7 +4495,7 @@ class Logger {
|
|
|
4589
4495
|
);
|
|
4590
4496
|
}
|
|
4591
4497
|
});
|
|
4592
|
-
if (config.watch && (config.changed ||
|
|
4498
|
+
if (config.watch && (config.changed || config.related?.length)) {
|
|
4593
4499
|
this.log(`No affected ${config.mode} files found
|
|
4594
4500
|
`);
|
|
4595
4501
|
} else {
|
|
@@ -4605,7 +4511,6 @@ No ${config.mode} files found, exiting with code 1`)
|
|
|
4605
4511
|
}
|
|
4606
4512
|
}
|
|
4607
4513
|
printBanner() {
|
|
4608
|
-
var _a, _b;
|
|
4609
4514
|
this.log();
|
|
4610
4515
|
const versionTest = this.ctx.config.watch ? c.blue(`v${this.ctx.version}`) : c.cyan(`v${this.ctx.version}`);
|
|
4611
4516
|
const mode = this.ctx.config.watch ? c.blue(" DEV ") : c.cyan(" RUN ");
|
|
@@ -4628,7 +4533,7 @@ No ${config.mode} files found, exiting with code 1`)
|
|
|
4628
4533
|
const name = project.getName();
|
|
4629
4534
|
const output = project.isCore() ? "" : ` [${name}]`;
|
|
4630
4535
|
const resolvedUrls = project.browser.vite.resolvedUrls;
|
|
4631
|
-
const origin =
|
|
4536
|
+
const origin = resolvedUrls?.local[0] ?? resolvedUrls?.network[0];
|
|
4632
4537
|
this.log(
|
|
4633
4538
|
c.dim(
|
|
4634
4539
|
c.green(
|
|
@@ -4641,14 +4546,14 @@ No ${config.mode} files found, exiting with code 1`)
|
|
|
4641
4546
|
this.log(
|
|
4642
4547
|
c.dim(
|
|
4643
4548
|
c.green(
|
|
4644
|
-
` 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}`
|
|
4645
4550
|
)
|
|
4646
4551
|
)
|
|
4647
4552
|
);
|
|
4648
|
-
} else if (
|
|
4553
|
+
} else if (this.ctx.config.api?.port) {
|
|
4649
4554
|
const resolvedUrls = this.ctx.server.resolvedUrls;
|
|
4650
4555
|
const fallbackUrl = `http://${this.ctx.config.api.host || "localhost"}:${this.ctx.config.api.port}`;
|
|
4651
|
-
const origin =
|
|
4556
|
+
const origin = resolvedUrls?.local[0] ?? resolvedUrls?.network[0] ?? fallbackUrl;
|
|
4652
4557
|
this.log(c.dim(c.green(` API started at ${new URL("/", origin)}`)));
|
|
4653
4558
|
}
|
|
4654
4559
|
if (this.ctx.coverageProvider) {
|
|
@@ -4714,10 +4619,9 @@ function capturePrintError(error, ctx, options) {
|
|
|
4714
4619
|
showCodeFrame: false,
|
|
4715
4620
|
...options
|
|
4716
4621
|
});
|
|
4717
|
-
return { nearest: result
|
|
4622
|
+
return { nearest: result?.nearest, output };
|
|
4718
4623
|
}
|
|
4719
4624
|
function printError(error, project, options) {
|
|
4720
|
-
var _a;
|
|
4721
4625
|
const { showCodeFrame = true, type, printProperties = true } = options;
|
|
4722
4626
|
const logger = options.logger;
|
|
4723
4627
|
let e = error;
|
|
@@ -4750,7 +4654,7 @@ function printError(error, project, options) {
|
|
|
4750
4654
|
printErrorType(type, project.ctx);
|
|
4751
4655
|
}
|
|
4752
4656
|
printErrorMessage(e, logger);
|
|
4753
|
-
if (
|
|
4657
|
+
if (options.screenshotPaths?.length) {
|
|
4754
4658
|
const length = options.screenshotPaths.length;
|
|
4755
4659
|
logger.error(`
|
|
4756
4660
|
Failure screenshot${length > 1 ? "s" : ""}:`);
|
|
@@ -4871,7 +4775,7 @@ function handleImportOutsideModuleError(stack, logger) {
|
|
|
4871
4775
|
}
|
|
4872
4776
|
const path = normalize(stack.split("\n")[0].trim());
|
|
4873
4777
|
let name = path.split("/node_modules/").pop() || "";
|
|
4874
|
-
if (name
|
|
4778
|
+
if (name?.startsWith("@")) {
|
|
4875
4779
|
name = name.split("/").slice(0, 2).join("/");
|
|
4876
4780
|
} else {
|
|
4877
4781
|
name = name.split("/")[0];
|
|
@@ -4944,7 +4848,7 @@ function printStack(logger, project, stack, highlight, errorProperties, onStack)
|
|
|
4944
4848
|
].filter(Boolean).join(" ")}`
|
|
4945
4849
|
)
|
|
4946
4850
|
);
|
|
4947
|
-
onStack
|
|
4851
|
+
onStack?.(frame);
|
|
4948
4852
|
}
|
|
4949
4853
|
if (stack.length) {
|
|
4950
4854
|
logger.error();
|
|
@@ -4962,14 +4866,13 @@ function hasProperties(obj) {
|
|
|
4962
4866
|
return false;
|
|
4963
4867
|
}
|
|
4964
4868
|
function generateCodeFrame(source, indent = 0, loc, range = 2) {
|
|
4965
|
-
var _a;
|
|
4966
4869
|
const start = typeof loc === "object" ? positionToOffset(source, loc.line, loc.column) : loc;
|
|
4967
4870
|
const end = start;
|
|
4968
4871
|
const lines = source.split(lineSplitRE);
|
|
4969
4872
|
const nl = /\r\n/.test(source) ? 2 : 1;
|
|
4970
4873
|
let count = 0;
|
|
4971
4874
|
let res = [];
|
|
4972
|
-
const columns =
|
|
4875
|
+
const columns = process.stdout?.columns || 80;
|
|
4973
4876
|
function lineNo(no = "") {
|
|
4974
4877
|
return c.gray(`${String(no).padStart(3, " ")}| `);
|
|
4975
4878
|
}
|
|
@@ -5051,8 +4954,7 @@ function executionTime(durationMS) {
|
|
|
5051
4954
|
});
|
|
5052
4955
|
}
|
|
5053
4956
|
function getDuration(task) {
|
|
5054
|
-
|
|
5055
|
-
const duration = ((_a = task.result) == null ? void 0 : _a.duration) ?? 0;
|
|
4957
|
+
const duration = task.result?.duration ?? 0;
|
|
5056
4958
|
return executionTime(duration);
|
|
5057
4959
|
}
|
|
5058
4960
|
class JUnitReporter {
|
|
@@ -5064,9 +4966,8 @@ class JUnitReporter {
|
|
|
5064
4966
|
fileFd;
|
|
5065
4967
|
options;
|
|
5066
4968
|
constructor(options) {
|
|
5067
|
-
var _a;
|
|
5068
4969
|
this.options = { ...options };
|
|
5069
|
-
|
|
4970
|
+
this.options.includeConsoleOutput ??= true;
|
|
5070
4971
|
}
|
|
5071
4972
|
async onInit(ctx) {
|
|
5072
4973
|
this.ctx = ctx;
|
|
@@ -5135,7 +5036,6 @@ class JUnitReporter {
|
|
|
5135
5036
|
time: getDuration(task)
|
|
5136
5037
|
},
|
|
5137
5038
|
async () => {
|
|
5138
|
-
var _a;
|
|
5139
5039
|
if (this.options.includeConsoleOutput) {
|
|
5140
5040
|
await this.writeLogs(task, "out");
|
|
5141
5041
|
await this.writeLogs(task, "err");
|
|
@@ -5143,14 +5043,14 @@ class JUnitReporter {
|
|
|
5143
5043
|
if (task.mode === "skip" || task.mode === "todo") {
|
|
5144
5044
|
await this.logger.log("<skipped/>");
|
|
5145
5045
|
}
|
|
5146
|
-
if (
|
|
5046
|
+
if (task.result?.state === "fail") {
|
|
5147
5047
|
const errors = task.result.errors || [];
|
|
5148
5048
|
for (const error of errors) {
|
|
5149
5049
|
await this.writeElement(
|
|
5150
5050
|
"failure",
|
|
5151
5051
|
{
|
|
5152
|
-
message: error
|
|
5153
|
-
type:
|
|
5052
|
+
message: error?.message,
|
|
5053
|
+
type: error?.name ?? error?.nameStr
|
|
5154
5054
|
},
|
|
5155
5055
|
async () => {
|
|
5156
5056
|
if (!error) {
|
|
@@ -5173,17 +5073,14 @@ class JUnitReporter {
|
|
|
5173
5073
|
}
|
|
5174
5074
|
}
|
|
5175
5075
|
async onFinished(files = this.ctx.state.getFiles()) {
|
|
5176
|
-
var _a;
|
|
5177
5076
|
await this.logger.log('<?xml version="1.0" encoding="UTF-8" ?>');
|
|
5178
5077
|
const transformed = files.map((file) => {
|
|
5179
|
-
var _a2, _b;
|
|
5180
5078
|
const tasks = file.tasks.flatMap((task) => flattenTasks$1(task));
|
|
5181
5079
|
const stats2 = tasks.reduce(
|
|
5182
5080
|
(stats3, task) => {
|
|
5183
|
-
var _a3, _b2;
|
|
5184
5081
|
return {
|
|
5185
|
-
passed: stats3.passed + Number(
|
|
5186
|
-
failures: stats3.failures + Number(
|
|
5082
|
+
passed: stats3.passed + Number(task.result?.state === "pass"),
|
|
5083
|
+
failures: stats3.failures + Number(task.result?.state === "fail"),
|
|
5187
5084
|
skipped: stats3.skipped + Number(task.mode === "skip" || task.mode === "todo")
|
|
5188
5085
|
};
|
|
5189
5086
|
},
|
|
@@ -5195,12 +5092,12 @@ class JUnitReporter {
|
|
|
5195
5092
|
);
|
|
5196
5093
|
const suites = getSuites(file);
|
|
5197
5094
|
for (const suite of suites) {
|
|
5198
|
-
if (
|
|
5095
|
+
if (suite.result?.errors) {
|
|
5199
5096
|
tasks.push(suite);
|
|
5200
5097
|
stats2.failures += 1;
|
|
5201
5098
|
}
|
|
5202
5099
|
}
|
|
5203
|
-
if (tasks.length === 0 &&
|
|
5100
|
+
if (tasks.length === 0 && file.result?.state === "fail") {
|
|
5204
5101
|
stats2.failures = 1;
|
|
5205
5102
|
tasks.push({
|
|
5206
5103
|
id: file.id,
|
|
@@ -5261,7 +5158,7 @@ class JUnitReporter {
|
|
|
5261
5158
|
if (this.reportFile) {
|
|
5262
5159
|
this.ctx.logger.log(`JUNIT report written to ${this.reportFile}`);
|
|
5263
5160
|
}
|
|
5264
|
-
await
|
|
5161
|
+
await this.fileFd?.close();
|
|
5265
5162
|
this.fileFd = void 0;
|
|
5266
5163
|
}
|
|
5267
5164
|
}
|
|
@@ -5299,8 +5196,7 @@ class HangingProcessReporter {
|
|
|
5299
5196
|
this.whyRunning = _require("why-is-node-running");
|
|
5300
5197
|
}
|
|
5301
5198
|
onProcessTimeout() {
|
|
5302
|
-
|
|
5303
|
-
(_a = this.whyRunning) == null ? void 0 : _a.call(this);
|
|
5199
|
+
this.whyRunning?.();
|
|
5304
5200
|
}
|
|
5305
5201
|
}
|
|
5306
5202
|
|
|
@@ -5310,7 +5206,6 @@ class GithubActionsReporter {
|
|
|
5310
5206
|
this.ctx = ctx;
|
|
5311
5207
|
}
|
|
5312
5208
|
onFinished(files = [], errors = []) {
|
|
5313
|
-
var _a, _b;
|
|
5314
5209
|
const projectErrors = new Array();
|
|
5315
5210
|
for (const error of errors) {
|
|
5316
5211
|
projectErrors.push({
|
|
@@ -5323,11 +5218,11 @@ class GithubActionsReporter {
|
|
|
5323
5218
|
const tasks = getTasks(file);
|
|
5324
5219
|
const project = this.ctx.getProjectByTaskId(file.id);
|
|
5325
5220
|
for (const task of tasks) {
|
|
5326
|
-
if (
|
|
5221
|
+
if (task.result?.state !== "fail") {
|
|
5327
5222
|
continue;
|
|
5328
5223
|
}
|
|
5329
5224
|
const title = getFullName(task, " > ");
|
|
5330
|
-
for (const error of
|
|
5225
|
+
for (const error of task.result?.errors ?? []) {
|
|
5331
5226
|
projectErrors.push({
|
|
5332
5227
|
project,
|
|
5333
5228
|
title,
|
|
@@ -5339,7 +5234,7 @@ class GithubActionsReporter {
|
|
|
5339
5234
|
}
|
|
5340
5235
|
for (const { project, title, error, file } of projectErrors) {
|
|
5341
5236
|
const result = capturePrintError(error, this.ctx, { project, task: file });
|
|
5342
|
-
const stack = result
|
|
5237
|
+
const stack = result?.nearest;
|
|
5343
5238
|
if (!stack) {
|
|
5344
5239
|
continue;
|
|
5345
5240
|
}
|
|
@@ -5469,9 +5364,8 @@ async function readBlobs(blobsDirectory, projectsArray) {
|
|
|
5469
5364
|
});
|
|
5470
5365
|
});
|
|
5471
5366
|
const files = blobs.flatMap((blob) => blob.files).sort((f1, f2) => {
|
|
5472
|
-
|
|
5473
|
-
const
|
|
5474
|
-
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;
|
|
5475
5369
|
return time1 - time2;
|
|
5476
5370
|
});
|
|
5477
5371
|
const errors = blobs.flatMap((blob) => blob.errors);
|
|
@@ -5483,6 +5377,382 @@ async function readBlobs(blobsDirectory, projectsArray) {
|
|
|
5483
5377
|
};
|
|
5484
5378
|
}
|
|
5485
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
|
+
|
|
5486
5756
|
const outputMap = /* @__PURE__ */ new WeakMap();
|
|
5487
5757
|
function formatFilepath(path) {
|
|
5488
5758
|
const lastSlash = Math.max(path.lastIndexOf("/") + 1, 0);
|
|
@@ -5567,15 +5837,14 @@ function renderBenchmark(result, widths) {
|
|
|
5567
5837
|
].join(" ");
|
|
5568
5838
|
}
|
|
5569
5839
|
function renderTree(tasks, options, level = 0, shallow = false) {
|
|
5570
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
5571
5840
|
const output = [];
|
|
5572
5841
|
const benchMap = {};
|
|
5573
5842
|
for (const t of tasks) {
|
|
5574
|
-
if (t.meta.benchmark &&
|
|
5843
|
+
if (t.meta.benchmark && t.result?.benchmark) {
|
|
5575
5844
|
benchMap[t.id] = {
|
|
5576
5845
|
current: t.result.benchmark
|
|
5577
5846
|
};
|
|
5578
|
-
const baseline =
|
|
5847
|
+
const baseline = options.compare?.[t.id];
|
|
5579
5848
|
if (baseline) {
|
|
5580
5849
|
benchMap[t.id].baseline = {
|
|
5581
5850
|
...baseline,
|
|
@@ -5592,7 +5861,7 @@ function renderTree(tasks, options, level = 0, shallow = false) {
|
|
|
5592
5861
|
for (const task of tasks) {
|
|
5593
5862
|
const padding = " ".repeat(level ? 1 : 0);
|
|
5594
5863
|
let prefix = "";
|
|
5595
|
-
if (idx === 0 &&
|
|
5864
|
+
if (idx === 0 && task.meta?.benchmark) {
|
|
5596
5865
|
prefix += `${renderTableHead(columnWidths)}
|
|
5597
5866
|
${padding}`;
|
|
5598
5867
|
}
|
|
@@ -5604,14 +5873,14 @@ ${padding}`;
|
|
|
5604
5873
|
if (task.mode === "skip" || task.mode === "todo") {
|
|
5605
5874
|
suffix += ` ${c.dim(c.gray("[skipped]"))}`;
|
|
5606
5875
|
}
|
|
5607
|
-
if (
|
|
5876
|
+
if (task.result?.duration != null) {
|
|
5608
5877
|
if (task.result.duration > options.slowTestThreshold) {
|
|
5609
5878
|
suffix += c.yellow(
|
|
5610
5879
|
` ${Math.round(task.result.duration)}${c.dim("ms")}`
|
|
5611
5880
|
);
|
|
5612
5881
|
}
|
|
5613
5882
|
}
|
|
5614
|
-
if (options.showHeap &&
|
|
5883
|
+
if (options.showHeap && task.result?.heap != null) {
|
|
5615
5884
|
suffix += c.magenta(
|
|
5616
5885
|
` ${Math.floor(task.result.heap / 1024 / 1024)} MB heap used`
|
|
5617
5886
|
);
|
|
@@ -5651,7 +5920,7 @@ ${padding}`;
|
|
|
5651
5920
|
} else {
|
|
5652
5921
|
output.push(padding + prefix + name + suffix);
|
|
5653
5922
|
}
|
|
5654
|
-
if (
|
|
5923
|
+
if (task.result?.state !== "pass" && outputMap.get(task) != null) {
|
|
5655
5924
|
let data = outputMap.get(task);
|
|
5656
5925
|
if (typeof data === "string") {
|
|
5657
5926
|
data = stripAnsi(data.trim().split("\n").filter(Boolean).pop());
|
|
@@ -5665,7 +5934,7 @@ ${padding}`;
|
|
|
5665
5934
|
}
|
|
5666
5935
|
}
|
|
5667
5936
|
if (!shallow && task.type === "suite" && task.tasks.length > 0) {
|
|
5668
|
-
if (
|
|
5937
|
+
if (task.result?.state) {
|
|
5669
5938
|
output.push(renderTree(task.tasks, options, level + 1));
|
|
5670
5939
|
}
|
|
5671
5940
|
}
|
|
@@ -5725,14 +5994,13 @@ class TableReporter extends BaseReporter {
|
|
|
5725
5994
|
super.onWatcherStart();
|
|
5726
5995
|
}
|
|
5727
5996
|
async onCollected() {
|
|
5728
|
-
var _a, _b;
|
|
5729
5997
|
this.rendererOptions.logger = this.ctx.logger;
|
|
5730
5998
|
this.rendererOptions.showHeap = this.ctx.config.logHeapUsage;
|
|
5731
5999
|
this.rendererOptions.slowTestThreshold = this.ctx.config.slowTestThreshold;
|
|
5732
|
-
if (
|
|
6000
|
+
if (this.ctx.config.benchmark?.compare) {
|
|
5733
6001
|
const compareFile = pathe.resolve(
|
|
5734
6002
|
this.ctx.config.root,
|
|
5735
|
-
|
|
6003
|
+
this.ctx.config.benchmark?.compare
|
|
5736
6004
|
);
|
|
5737
6005
|
try {
|
|
5738
6006
|
this.rendererOptions.compare = flattenFormattedBenchmarkReport(
|
|
@@ -5757,18 +6025,14 @@ class TableReporter extends BaseReporter {
|
|
|
5757
6025
|
}
|
|
5758
6026
|
}
|
|
5759
6027
|
onTaskUpdate(packs) {
|
|
5760
|
-
var _a, _b;
|
|
5761
6028
|
if (this.isTTY) {
|
|
5762
6029
|
return;
|
|
5763
6030
|
}
|
|
5764
6031
|
for (const pack of packs) {
|
|
5765
6032
|
const task = this.ctx.state.idMap.get(pack[0]);
|
|
5766
|
-
if (task && task.type === "suite" &&
|
|
6033
|
+
if (task && task.type === "suite" && task.result?.state && task.result?.state !== "run") {
|
|
5767
6034
|
const benches = task.tasks.filter((t) => t.meta.benchmark);
|
|
5768
|
-
if (benches.length > 0 && benches.every((t) => {
|
|
5769
|
-
var _a2;
|
|
5770
|
-
return ((_a2 = t.result) == null ? void 0 : _a2.state) !== "run";
|
|
5771
|
-
})) {
|
|
6035
|
+
if (benches.length > 0 && benches.every((t) => t.result?.state !== "run")) {
|
|
5772
6036
|
let title = ` ${getStateSymbol(task)} ${getFullName(
|
|
5773
6037
|
task,
|
|
5774
6038
|
c.dim(" > ")
|
|
@@ -5787,11 +6051,10 @@ class TableReporter extends BaseReporter {
|
|
|
5787
6051
|
}
|
|
5788
6052
|
}
|
|
5789
6053
|
async onFinished(files = this.ctx.state.getFiles(), errors = this.ctx.state.getUnhandledErrors()) {
|
|
5790
|
-
var _a;
|
|
5791
6054
|
this.stopListRender();
|
|
5792
6055
|
this.ctx.logger.log();
|
|
5793
6056
|
super.onFinished(files, errors);
|
|
5794
|
-
let outputFile =
|
|
6057
|
+
let outputFile = this.ctx.config.benchmark?.outputJson;
|
|
5795
6058
|
if (outputFile) {
|
|
5796
6059
|
outputFile = pathe.resolve(this.ctx.config.root, outputFile);
|
|
5797
6060
|
const outputDirectory = pathe.dirname(outputFile);
|
|
@@ -5808,8 +6071,7 @@ class TableReporter extends BaseReporter {
|
|
|
5808
6071
|
await super.onWatcherStart();
|
|
5809
6072
|
}
|
|
5810
6073
|
stopListRender() {
|
|
5811
|
-
|
|
5812
|
-
(_a = this.renderer) == null ? void 0 : _a.stop();
|
|
6074
|
+
this.renderer?.stop();
|
|
5813
6075
|
this.renderer = void 0;
|
|
5814
6076
|
}
|
|
5815
6077
|
async onWatcherRerun(files, trigger) {
|
|
@@ -5817,16 +6079,14 @@ class TableReporter extends BaseReporter {
|
|
|
5817
6079
|
await super.onWatcherRerun(files, trigger);
|
|
5818
6080
|
}
|
|
5819
6081
|
onUserConsoleLog(log) {
|
|
5820
|
-
var _a;
|
|
5821
6082
|
if (!this.shouldLog(log)) {
|
|
5822
6083
|
return;
|
|
5823
6084
|
}
|
|
5824
|
-
|
|
6085
|
+
this.renderer?.clear();
|
|
5825
6086
|
super.onUserConsoleLog(log);
|
|
5826
6087
|
}
|
|
5827
6088
|
}
|
|
5828
6089
|
function createFormattedBenchmarkReport(files) {
|
|
5829
|
-
var _a;
|
|
5830
6090
|
const report = { files: [] };
|
|
5831
6091
|
for (const file of files) {
|
|
5832
6092
|
const groups = [];
|
|
@@ -5834,7 +6094,7 @@ function createFormattedBenchmarkReport(files) {
|
|
|
5834
6094
|
if (task && task.type === "suite") {
|
|
5835
6095
|
const benchmarks = [];
|
|
5836
6096
|
for (const t of task.tasks) {
|
|
5837
|
-
const benchmark = t.meta.benchmark &&
|
|
6097
|
+
const benchmark = t.meta.benchmark && t.result?.benchmark;
|
|
5838
6098
|
if (benchmark) {
|
|
5839
6099
|
const { samples, ...rest } = benchmark;
|
|
5840
6100
|
benchmarks.push({
|
|
@@ -5891,4 +6151,4 @@ const ReportersMap = {
|
|
|
5891
6151
|
"github-actions": GithubActionsReporter
|
|
5892
6152
|
};
|
|
5893
6153
|
|
|
5894
|
-
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 };
|