vitest 1.6.0 → 2.0.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +173 -1
- package/dist/browser.d.ts +22 -2
- package/dist/browser.js +6 -4
- package/dist/chunks/{environments-node.vcoXCoKs.js → environments-node.39w4gmlF.js} +2 -2
- package/dist/chunks/{install-pkg.LE8oaA1t.js → install-pkg.DNUmWFkO.js} +2 -2
- package/dist/chunks/integrations-globals.C6Ah-pUW.js +31 -0
- package/dist/chunks/{runtime-console.EO5ha7qv.js → runtime-console.DiVMr5d4.js} +62 -32
- package/dist/chunks/{runtime-runBaseTests.oAvMKtQC.js → runtime-runBaseTests.Cukyr5-I.js} +18 -18
- package/dist/cli.js +3 -3
- package/dist/config.cjs +4 -5
- package/dist/config.d.ts +2 -2
- package/dist/config.js +4 -5
- package/dist/coverage.d.ts +1 -1
- package/dist/coverage.js +34 -8
- package/dist/environments.d.ts +1 -1
- package/dist/environments.js +1 -1
- package/dist/execute.d.ts +3 -2
- package/dist/execute.js +2 -2
- package/dist/index.d.ts +777 -65
- package/dist/index.js +12 -12
- package/dist/node.d.ts +7 -7
- package/dist/node.js +24 -23
- package/dist/{reporters-yx5ZTtEV.d.ts → reporters-CYVC6LOl.d.ts} +439 -219
- package/dist/reporters.d.ts +1 -1
- package/dist/reporters.js +11 -12
- package/dist/runners.d.ts +4 -2
- package/dist/runners.js +25 -18
- package/dist/snapshot.js +3 -3
- package/dist/{suite-IbNSsUWN.d.ts → suite-Dpu9EC_k.d.ts} +1 -1
- package/dist/suite.d.ts +2 -2
- package/dist/suite.js +4 -4
- package/dist/vendor/{base.Ybri3C14.js → base.Dln9yllP.js} +3 -3
- package/dist/vendor/{base.5NT-gWu5.js → base._gnK9Slw.js} +1 -2
- package/dist/vendor/{benchmark.yGkUTKnC.js → benchmark.BNLebNi5.js} +1 -1
- package/dist/vendor/{cac.EdDItJD-.js → cac.CtYFkoSJ.js} +66 -25
- package/dist/vendor/{cli-api.E07AF1Yq.js → cli-api.CUtJc4r3.js} +11851 -7276
- package/dist/vendor/{constants.5J7I254_.js → constants.TCjCaw2D.js} +4 -3
- package/dist/vendor/{execute.fL3szUAI.js → execute.BHj6OMh4.js} +4 -4
- package/dist/vendor/{index.DpVgvm2P.js → index.B5SKBLvV.js} +5 -5
- package/dist/vendor/{index.Q04MCqDO.js → index.BOMEjpjj.js} +680 -160
- package/dist/vendor/{index.8bPxjt7g.js → index.BpSiYbpB.js} +5 -1
- package/dist/vendor/{index.xL8XjTLv.js → index.CThipSqB.js} +2538 -2525
- package/dist/vendor/{index.dI9lHwVn.js → index.D3hs2WiI.js} +8 -6
- package/dist/vendor/{index.SMVOaj7F.js → index._7XLd8Kd.js} +2 -2
- package/dist/vendor/{index.GVFv9dZ0.js → index.kpsSqFiz.js} +2 -1
- package/dist/vendor/{rpc.joBhAkyK.js → rpc.DRDE9Pu1.js} +2 -2
- package/dist/vendor/{run-once.Olz_Zkd8.js → run-once.DLomgGUH.js} +1 -1
- package/dist/vendor/{setup-common.8nJLd4ay.js → setup-common.DAu7t7mY.js} +2 -2
- package/dist/vendor/spy.Cf_4R5Oe.js +22 -0
- package/dist/vendor/{tasks.IknbGB2n.js → tasks.WC7M-K-v.js} +4 -1
- package/dist/vendor/{utils.dEtNIEgr.js → utils.YuQ3LT2a.js} +2 -2
- package/dist/vendor/{vi.YFlodzP_.js → vi.hATFzZbX.js} +124 -56
- package/dist/vendor/{vm.QEE48c0T.js → vm.Ow-X2mkS.js} +47 -59
- package/dist/worker.js +6 -6
- package/dist/workers/forks.js +5 -5
- package/dist/workers/runVmTests.js +17 -17
- 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 +1 -1
- package/dist/workers.js +13 -13
- package/package.json +35 -35
- package/suppress-warnings.cjs +2 -1
- package/vitest.mjs +1 -1
- package/dist/chunks/integrations-globals.kw4co3rx.js +0 -31
- package/dist/cli-wrapper.js +0 -119
- /package/dist/chunks/{node-git.Hw101KjS.js → node-git.CCI8evVZ.js} +0 -0
- /package/dist/vendor/{_commonjsHelpers.jjO7Zipk.js → _commonjsHelpers.BFTU3MAI.js} +0 -0
- /package/dist/vendor/{coverage.E7sG1b3r.js → coverage.ChSqD-qS.js} +0 -0
- /package/dist/vendor/{date.Ns1pGd_X.js → date.BKM1wewY.js} +0 -0
- /package/dist/vendor/{env.AtSIuHFg.js → env.bmJgw1qP.js} +0 -0
- /package/dist/vendor/{global.CkGT_TMy.js → global.7bFbnyXl.js} +0 -0
- /package/dist/vendor/{inspector.IgLX3ur5.js → inspector.hPQncR7V.js} +0 -0
- /package/dist/vendor/{utils.0uYuCbzo.js → utils.CUjzkRH7.js} +0 -0
|
@@ -2,36 +2,142 @@ import fs, { existsSync, promises, readFileSync } from 'node:fs';
|
|
|
2
2
|
import c from 'picocolors';
|
|
3
3
|
import * as pathe from 'pathe';
|
|
4
4
|
import { basename, dirname, resolve, join, relative, extname, normalize } from 'pathe';
|
|
5
|
-
import {
|
|
5
|
+
import { a as getFullName, h as hasFailedSnapshot } from './tasks.WC7M-K-v.js';
|
|
6
6
|
import { getSafeTimers, notNullish, highlight, shuffle, inspect, positionToOffset, lineSplitRE } from '@vitest/utils';
|
|
7
|
-
import { i as isNode } from './env.
|
|
8
|
-
import { g as getStateSymbol, f as formatProjectName, p as pointer, F as F_RIGHT, r as renderSnapshotSummary,
|
|
7
|
+
import { i as isNode } from './env.bmJgw1qP.js';
|
|
8
|
+
import { g as getStateSymbol, f as formatProjectName, p as pointer, 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.YuQ3LT2a.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
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
11
|
+
import { TraceMap, generatedPositionFor, parseStacktrace, parseErrorStacktrace } from '@vitest/utils/source-map';
|
|
12
|
+
import { r as relativePath } from './index._7XLd8Kd.js';
|
|
13
|
+
import { UNKNOWN_TEST_ID } from '../chunks/runtime-console.DiVMr5d4.js';
|
|
14
|
+
import { t as toArray, b as isPrimitive } from './base._gnK9Slw.js';
|
|
14
15
|
import { isCI } from 'std-env';
|
|
15
|
-
import { TraceMap, generatedPositionFor, parseErrorStacktrace } from '@vitest/utils/source-map';
|
|
16
16
|
import nodeos__default, { hostname } from 'node:os';
|
|
17
17
|
import { Writable } from 'node:stream';
|
|
18
|
-
import { writeFile, rm } from 'node:fs/promises';
|
|
18
|
+
import { writeFile, rm, mkdir, readdir, readFile } from 'node:fs/promises';
|
|
19
19
|
import { execa } from 'execa';
|
|
20
20
|
import url from 'node:url';
|
|
21
21
|
import p$1 from 'path';
|
|
22
22
|
import require$$0 from 'fs';
|
|
23
23
|
import ge from 'module';
|
|
24
24
|
import { parseAstAsync } from 'vite';
|
|
25
|
-
import { ancestor } from 'acorn-walk';
|
|
26
25
|
import { Console } from 'node:console';
|
|
27
26
|
import process$2 from 'node:process';
|
|
28
|
-
import { g as getDefaultExportFromCjs, c as commonjsGlobal } from './_commonjsHelpers.
|
|
27
|
+
import { g as getDefaultExportFromCjs, c as commonjsGlobal } from './_commonjsHelpers.BFTU3MAI.js';
|
|
29
28
|
import require$$0$2 from 'assert';
|
|
30
29
|
import require$$0$1 from 'events';
|
|
31
30
|
import { createHash } from 'node:crypto';
|
|
32
|
-
import { slash } from 'vite-node/utils';
|
|
31
|
+
import { slash, cleanUrl } from 'vite-node/utils';
|
|
33
32
|
import { createRequire } from 'node:module';
|
|
34
33
|
|
|
34
|
+
/// <reference types="../types/index.d.ts" />
|
|
35
|
+
|
|
36
|
+
// (c) 2020-present Andrea Giammarchi
|
|
37
|
+
|
|
38
|
+
const {parse: $parse, stringify: $stringify} = JSON;
|
|
39
|
+
const {keys} = Object;
|
|
40
|
+
|
|
41
|
+
const Primitive = String; // it could be Number
|
|
42
|
+
const primitive = 'string'; // it could be 'number'
|
|
43
|
+
|
|
44
|
+
const ignore$1 = {};
|
|
45
|
+
const object = 'object';
|
|
46
|
+
|
|
47
|
+
const noop = (_, value) => value;
|
|
48
|
+
|
|
49
|
+
const primitives = value => (
|
|
50
|
+
value instanceof Primitive ? Primitive(value) : value
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
const Primitives = (_, value) => (
|
|
54
|
+
typeof value === primitive ? new Primitive(value) : value
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
const revive = (input, parsed, output, $) => {
|
|
58
|
+
const lazy = [];
|
|
59
|
+
for (let ke = keys(output), {length} = ke, y = 0; y < length; y++) {
|
|
60
|
+
const k = ke[y];
|
|
61
|
+
const value = output[k];
|
|
62
|
+
if (value instanceof Primitive) {
|
|
63
|
+
const tmp = input[value];
|
|
64
|
+
if (typeof tmp === object && !parsed.has(tmp)) {
|
|
65
|
+
parsed.add(tmp);
|
|
66
|
+
output[k] = ignore$1;
|
|
67
|
+
lazy.push({k, a: [input, parsed, tmp, $]});
|
|
68
|
+
}
|
|
69
|
+
else
|
|
70
|
+
output[k] = $.call(output, k, tmp);
|
|
71
|
+
}
|
|
72
|
+
else if (output[k] !== ignore$1)
|
|
73
|
+
output[k] = $.call(output, k, value);
|
|
74
|
+
}
|
|
75
|
+
for (let {length} = lazy, i = 0; i < length; i++) {
|
|
76
|
+
const {k, a} = lazy[i];
|
|
77
|
+
output[k] = $.call(output, k, revive.apply(null, a));
|
|
78
|
+
}
|
|
79
|
+
return output;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const set = (known, input, value) => {
|
|
83
|
+
const index = Primitive(input.push(value) - 1);
|
|
84
|
+
known.set(value, index);
|
|
85
|
+
return index;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Converts a specialized flatted string into a JS value.
|
|
90
|
+
* @param {string} text
|
|
91
|
+
* @param {(this: any, key: string, value: any) => any} [reviver]
|
|
92
|
+
* @returns {any}
|
|
93
|
+
*/
|
|
94
|
+
const parse = (text, reviver) => {
|
|
95
|
+
const input = $parse(text, Primitives).map(primitives);
|
|
96
|
+
const value = input[0];
|
|
97
|
+
const $ = reviver || noop;
|
|
98
|
+
const tmp = typeof value === object && value ?
|
|
99
|
+
revive(input, new Set, value, $) :
|
|
100
|
+
value;
|
|
101
|
+
return $.call({'': tmp}, '', tmp);
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Converts a JS value into a specialized flatted string.
|
|
106
|
+
* @param {any} value
|
|
107
|
+
* @param {((this: any, key: string, value: any) => any) | (string | number)[] | null | undefined} [replacer]
|
|
108
|
+
* @param {string | number | undefined} [space]
|
|
109
|
+
* @returns {string}
|
|
110
|
+
*/
|
|
111
|
+
const stringify = (value, replacer, space) => {
|
|
112
|
+
const $ = replacer && typeof replacer === object ?
|
|
113
|
+
(k, v) => (k === '' || -1 < replacer.indexOf(k) ? v : void 0) :
|
|
114
|
+
(replacer || noop);
|
|
115
|
+
const known = new Map;
|
|
116
|
+
const input = [];
|
|
117
|
+
const output = [];
|
|
118
|
+
let i = +set(known, input, $.call({'': value}, '', value));
|
|
119
|
+
let firstRun = !i;
|
|
120
|
+
while (i < input.length) {
|
|
121
|
+
firstRun = true;
|
|
122
|
+
output[i] = $stringify(input[i++], replace, space);
|
|
123
|
+
}
|
|
124
|
+
return '[' + output.join(',') + ']';
|
|
125
|
+
function replace(key, value) {
|
|
126
|
+
if (firstRun) {
|
|
127
|
+
firstRun = !firstRun;
|
|
128
|
+
return value;
|
|
129
|
+
}
|
|
130
|
+
const after = $.call(this, key, value);
|
|
131
|
+
switch (typeof after) {
|
|
132
|
+
case object:
|
|
133
|
+
if (after === null) return after;
|
|
134
|
+
case primitive:
|
|
135
|
+
return known.get(after) || set(known, input, after);
|
|
136
|
+
}
|
|
137
|
+
return after;
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
|
|
35
141
|
const REGEXP_WRAP_PREFIX = "$$vitest:";
|
|
36
142
|
function getOutputFile(config, reporter) {
|
|
37
143
|
if (!(config == null ? void 0 : config.outputFile))
|
|
@@ -54,11 +160,15 @@ function wrapSerializableConfig(config) {
|
|
|
54
160
|
};
|
|
55
161
|
}
|
|
56
162
|
|
|
57
|
-
const A=r=>r!==null&&typeof r=="object",a=(r,t)=>Object.assign(new Error(`[${r}]: ${t}`),{code:r}),_$1="ERR_INVALID_PACKAGE_CONFIG",E
|
|
163
|
+
const A=r=>r!==null&&typeof r=="object",a=(r,t)=>Object.assign(new Error(`[${r}]: ${t}`),{code:r}),_$1="ERR_INVALID_PACKAGE_CONFIG",E="ERR_INVALID_PACKAGE_TARGET",I$1="ERR_PACKAGE_PATH_NOT_EXPORTED",R$1=/^\d+$/,O=/^(\.{1,2}|node_modules)$/i,w=/\/|\\/;var h$1=(r=>(r.Export="exports",r.Import="imports",r))(h$1||{});const f=(r,t,e,o,c)=>{if(t==null)return [];if(typeof t=="string"){const[n,...i]=t.split(w);if(n===".."||i.some(l=>O.test(l)))throw a(E,`Invalid "${r}" target "${t}" defined in the package config`);return [c?t.replace(/\*/g,c):t]}if(Array.isArray(t))return t.flatMap(n=>f(r,n,e,o,c));if(A(t)){for(const n of Object.keys(t)){if(R$1.test(n))throw a(_$1,"Cannot contain numeric property keys");if(n==="default"||o.includes(n))return f(r,t[n],e,o,c)}return []}throw a(E,`Invalid "${r}" target "${t}"`)},s="*",m=(r,t)=>{const e=r.indexOf(s),o=t.indexOf(s);return e===o?t.length>r.length:o>e};function d(r,t){if(!t.includes(s)&&r.hasOwnProperty(t))return [t];let e,o;for(const c of Object.keys(r))if(c.includes(s)){const[n,i,l]=c.split(s);if(l===void 0&&t.startsWith(n)&&t.endsWith(i)){const g=t.slice(n.length,-i.length||void 0);g&&(!e||m(e,c))&&(e=c,o=g);}}return [e,o]}const p=r=>Object.keys(r).reduce((t,e)=>{const o=e===""||e[0]!==".";if(t===void 0||t===o)return o;throw a(_$1,'"exports" cannot contain some keys starting with "." and some not')},void 0),u=/^\w+:/,v=(r,t,e)=>{if(!r)throw new Error('"exports" is required');t=t===""?".":`./${t}`,(typeof r=="string"||Array.isArray(r)||A(r)&&p(r))&&(r={".":r});const[o,c]=d(r,t),n=f(h$1.Export,r[o],t,e,c);if(n.length===0)throw a(I$1,t==="."?'No "exports" main defined':`Package subpath '${t}' is not defined by "exports"`);for(const i of n)if(!i.startsWith("./")&&!u.test(i))throw a(E,`Invalid "exports" target "${i}" defined in the package config`);return n};
|
|
58
164
|
|
|
59
|
-
function B(e){return e.startsWith("\\\\?\\")?e:e.replace(/\\/g,"/")}const
|
|
60
|
-
`;break;case 114:
|
|
61
|
-
`),m++,b=n,s=14;switch(u){case 123:return n++,s=1;case 125:return n++,s=2;case 91:return n++,s=3;case 93:return n++,s=4;case 58:return n++,s=6;case 44:return n++,s=5;case 34:return n++,t=k(),s=10;case 47:const g=n-1;if(e.charCodeAt(n+1)===47){for(n+=2;n<i&&!_(e.charCodeAt(n));)n++;return t=e.substring(g,n),s=12}if(e.charCodeAt(n+1)===42){n+=2;const f=i-1;let $=!1;for(;n<f;){const O=e.charCodeAt(n);if(O===42&&e.charCodeAt(n+1)===47){n+=2,$=!0;break}n++,_(O)&&(O===13&&e.charCodeAt(n)===10&&n++,m++,b=n);}return $||(n++,c=1),t=e.substring(g,n),s=13}return t+=String.fromCharCode(u),n++,s=16;case 45:if(t+=String.fromCharCode(u),n++,n===i||!N(e.charCodeAt(n)))return s=16;case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return t+=w(),s=11;default:for(;n<i&&U(u);)n++,u=e.charCodeAt(n);if(l!==n){switch(t=e.substring(l,n),t){case"true":return s=8;case"false":return s=9;case"null":return s=7}return s=16}return t+=String.fromCharCode(u),n++,s=16}}function U(u){if(J(u)||_(u))return !1;switch(u){case 125:case 93:case 123:case 91:case 34:case 58:case 44:case 47:return !1}return !0}function F(){let u;do u=j();while(u>=12&&u<=15);return u}return {setPosition:T,getPosition:()=>n,scan:o?F:j,getToken:()=>s,getTokenValue:()=>t,getTokenOffset:()=>l,getTokenLength:()=>n-l,getTokenStartLine:()=>r,getTokenStartCharacter:()=>l-v,getTokenError:()=>c}}function J(e){return e===32||e===9}function _(e){return e===10||e===13}function N(e){return e>=48&&e<=57}var q;(function(e){e[e.lineFeed=10]="lineFeed",e[e.carriageReturn=13]="carriageReturn",e[e.space=32]="space",e[e._0=48]="_0",e[e._1=49]="_1",e[e._2=50]="_2",e[e._3=51]="_3",e[e._4=52]="_4",e[e._5=53]="_5",e[e._6=54]="_6",e[e._7=55]="_7",e[e._8=56]="_8",e[e._9=57]="_9",e[e.a=97]="a",e[e.b=98]="b",e[e.c=99]="c",e[e.d=100]="d",e[e.e=101]="e",e[e.f=102]="f",e[e.g=103]="g",e[e.h=104]="h",e[e.i=105]="i",e[e.j=106]="j",e[e.k=107]="k",e[e.l=108]="l",e[e.m=109]="m",e[e.n=110]="n",e[e.o=111]="o",e[e.p=112]="p",e[e.q=113]="q",e[e.r=114]="r",e[e.s=115]="s",e[e.t=116]="t",e[e.u=117]="u",e[e.v=118]="v",e[e.w=119]="w",e[e.x=120]="x",e[e.y=121]="y",e[e.z=122]="z",e[e.A=65]="A",e[e.B=66]="B",e[e.C=67]="C",e[e.D=68]="D",e[e.E=69]="E",e[e.F=70]="F",e[e.G=71]="G",e[e.H=72]="H",e[e.I=73]="I",e[e.J=74]="J",e[e.K=75]="K",e[e.L=76]="L",e[e.M=77]="M",e[e.N=78]="N",e[e.O=79]="O",e[e.P=80]="P",e[e.Q=81]="Q",e[e.R=82]="R",e[e.S=83]="S",e[e.T=84]="T",e[e.U=85]="U",e[e.V=86]="V",e[e.W=87]="W",e[e.X=88]="X",e[e.Y=89]="Y",e[e.Z=90]="Z",e[e.asterisk=42]="asterisk",e[e.backslash=92]="backslash",e[e.closeBrace=125]="closeBrace",e[e.closeBracket=93]="closeBracket",e[e.colon=58]="colon",e[e.comma=44]="comma",e[e.dot=46]="dot",e[e.doubleQuote=34]="doubleQuote",e[e.minus=45]="minus",e[e.openBrace=123]="openBrace",e[e.openBracket=91]="openBracket",e[e.plus=43]="plus",e[e.slash=47]="slash",e[e.formFeed=12]="formFeed",e[e.tab=9]="tab";})(q||(q={}));var I;(function(e){e.DEFAULT={allowTrailingComma:!1};})(I||(I={}));function Te(e,o=[],i=I.DEFAULT){let n=null,t=[];const l=[];function s(r){Array.isArray(t)?t.push(r):n!==null&&(t[n]=r);}return we(e,{onObjectBegin:()=>{const r={};s(r),l.push(t),t=r,n=null;},onObjectProperty:r=>{n=r;},onObjectEnd:()=>{t=l.pop();},onArrayBegin:()=>{const r=[];s(r),l.push(t),t=r,n=null;},onArrayEnd:()=>{t=l.pop();},onLiteralValue:s,onError:(r,b,v)=>{o.push({error:r,offset:b,length:v});}},i),t[0]}function we(e,o,i=I.DEFAULT){const n=be(e,!1),t=[];function l(a){return a?()=>a(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter()):()=>!0}function s(a){return a?()=>a(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter(),()=>t.slice()):()=>!0}function m(a){return a?A=>a(A,n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter()):()=>!0}function r(a){return a?A=>a(A,n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter(),()=>t.slice()):()=>!0}const b=s(o.onObjectBegin),v=r(o.onObjectProperty),c=l(o.onObjectEnd),L=s(o.onArrayBegin),T=l(o.onArrayEnd),w=r(o.onLiteralValue),k=m(o.onSeparator),j=l(o.onComment),U=m(o.onError),F=i&&i.disallowComments,u=i&&i.allowTrailingComma;function g(){for(;;){const a=n.scan();switch(n.getTokenError()){case 4:f(14);break;case 5:f(15);break;case 3:f(13);break;case 1:F||f(11);break;case 2:f(12);break;case 6:f(16);break}switch(a){case 12:case 13:F?f(10):j();break;case 16:f(1);break;case 15:case 14:break;default:return a}}}function f(a,A=[],Y=[]){if(U(a),A.length+Y.length>0){let y=n.getToken();for(;y!==17;){if(A.indexOf(y)!==-1){g();break}else if(Y.indexOf(y)!==-1)break;y=g();}}}function $(a){const A=n.getTokenValue();return a?w(A):(v(A),t.push(A)),g(),!0}function O(){switch(n.getToken()){case 11:const a=n.getTokenValue();let A=Number(a);isNaN(A)&&(f(2),A=0),w(A);break;case 7:w(null);break;case 8:w(!0);break;case 9:w(!1);break;default:return !1}return g(),!0}function ce(){return n.getToken()!==10?(f(3,[],[2,5]),!1):($(!1),n.getToken()===6?(k(":"),g(),V()||f(4,[],[2,5])):f(5,[],[2,5]),t.pop(),!0)}function fe(){b(),g();let a=!1;for(;n.getToken()!==2&&n.getToken()!==17;){if(n.getToken()===5){if(a||f(4,[],[]),k(","),g(),n.getToken()===2&&u)break}else a&&f(6,[],[]);ce()||f(4,[],[2,5]),a=!0;}return c(),n.getToken()!==2?f(7,[2],[]):g(),!0}function pe(){L(),g();let a=!0,A=!1;for(;n.getToken()!==4&&n.getToken()!==17;){if(n.getToken()===5){if(A||f(4,[],[]),k(","),g(),n.getToken()===4&&u)break}else A&&f(6,[],[]);a?(t.push(0),a=!1):t[t.length-1]++,V()||f(4,[],[4,5]),A=!0;}return T(),a||t.pop(),n.getToken()!==4?f(8,[4],[]):g(),!0}function V(){switch(n.getToken()){case 3:return pe();case 1:return fe();case 10:return $(!0);default:return O()}}return g(),n.getToken()===17?i.allowEmptyContent?!0:(f(4,[],[]),!1):V()?(n.getToken()!==17&&f(9,[],[]),!0):(f(4,[],[]),!1)}var K;(function(e){e[e.None=0]="None",e[e.UnexpectedEndOfComment=1]="UnexpectedEndOfComment",e[e.UnexpectedEndOfString=2]="UnexpectedEndOfString",e[e.UnexpectedEndOfNumber=3]="UnexpectedEndOfNumber",e[e.InvalidUnicode=4]="InvalidUnicode",e[e.InvalidEscapeCharacter=5]="InvalidEscapeCharacter",e[e.InvalidCharacter=6]="InvalidCharacter";})(K||(K={}));var C;(function(e){e[e.OpenBraceToken=1]="OpenBraceToken",e[e.CloseBraceToken=2]="CloseBraceToken",e[e.OpenBracketToken=3]="OpenBracketToken",e[e.CloseBracketToken=4]="CloseBracketToken",e[e.CommaToken=5]="CommaToken",e[e.ColonToken=6]="ColonToken",e[e.NullKeyword=7]="NullKeyword",e[e.TrueKeyword=8]="TrueKeyword",e[e.FalseKeyword=9]="FalseKeyword",e[e.StringLiteral=10]="StringLiteral",e[e.NumericLiteral=11]="NumericLiteral",e[e.LineCommentTrivia=12]="LineCommentTrivia",e[e.BlockCommentTrivia=13]="BlockCommentTrivia",e[e.LineBreakTrivia=14]="LineBreakTrivia",e[e.Trivia=15]="Trivia",e[e.Unknown=16]="Unknown",e[e.EOF=17]="EOF";})(C||(C={}));const ve=Te;var ee;(function(e){e[e.InvalidSymbol=1]="InvalidSymbol",e[e.InvalidNumberFormat=2]="InvalidNumberFormat",e[e.PropertyNameExpected=3]="PropertyNameExpected",e[e.ValueExpected=4]="ValueExpected",e[e.ColonExpected=5]="ColonExpected",e[e.CommaExpected=6]="CommaExpected",e[e.CloseBraceExpected=7]="CloseBraceExpected",e[e.CloseBracketExpected=8]="CloseBracketExpected",e[e.EndOfFileExpected=9]="EndOfFileExpected",e[e.InvalidCommentToken=10]="InvalidCommentToken",e[e.UnexpectedEndOfComment=11]="UnexpectedEndOfComment",e[e.UnexpectedEndOfString=12]="UnexpectedEndOfString",e[e.UnexpectedEndOfNumber=13]="UnexpectedEndOfNumber",e[e.InvalidUnicode=14]="InvalidUnicode",e[e.InvalidEscapeCharacter=15]="InvalidEscapeCharacter",e[e.InvalidCharacter=16]="InvalidCharacter";})(ee||(ee={}));const ne=(e,o)=>ve(ke(o,e,"utf8")),M=Symbol("implicitBaseUrl"),Oe=()=>{const{findPnpApi:e}=ge;return e&&e(process.cwd())},R=(e,o,i,n)=>{const t=`resolveFromPackageJsonPath:${e}:${o}:${i}`;if(n!=null&&n.has(t))return n.get(t);const l=ne(e,n);if(!l)return;let s=o||"tsconfig.json";if(!i&&l.exports)try{const[m]=v(l.exports,o,["require","types"]);s=m;}catch{return !1}else !o&&l.tsconfig&&(s=l.tsconfig);return s=p$1.join(e,"..",s),n==null||n.set(t,s),s},G="package.json",z="tsconfig.json",Ae=(e,o,i)=>{let n=e;if(e===".."&&(n=p$1.join(n,z)),e[0]==="."&&(n=p$1.resolve(o,n)),p$1.isAbsolute(n)){if(E(i,n)){if(P(i,n).isFile())return n}else if(!n.endsWith(".json")){const T=`${n}.json`;if(E(i,T))return T}return}const[t,...l]=e.split("/"),s=t[0]==="@"?`${t}/${l.shift()}`:t,m=l.join("/"),r=Oe();if(r){const{resolveRequest:T}=r;try{if(s===e){const w=T(p$1.join(s,G),o);if(w){const k=R(w,m,!1,i);if(k&&E(i,k))return k}}else {let w;try{w=T(e,o,{extensions:[".json"]});}catch{w=T(p$1.join(e,z),o);}if(w)return w}}catch{}}const b=Z(o,p$1.join("node_modules",s),i);if(!b||!P(i,b).isDirectory())return;const v=p$1.join(b,G);if(E(i,v)){const T=R(v,m,!1,i);if(T===!1)return;if(T&&E(i,T)&&P(i,T).isFile())return T}const c=p$1.join(b,m),L=c.endsWith(".json");if(!L){const T=`${c}.json`;if(E(i,T))return T}if(E(i,c)){if(P(i,c).isDirectory()){const T=p$1.join(c,G);if(E(i,T)){const k=R(T,"",!0,i);if(k&&E(i,k))return k}const w=p$1.join(c,z);if(E(i,w))return w}else if(L)return c}},je=(e,o,i,n)=>{const t=Ae(e,o,n);if(!t)throw new Error(`File '${e}' not found.`);if(i.has(t))throw new Error(`Circularity detected while resolving configuration: ${t}`);i.add(t);const l=p$1.dirname(t),s=te(t,n,i);delete s.references;const{compilerOptions:m}=s;if(m){const r=["baseUrl","outDir"];for(const b of r){const v=m[b];v&&(m[b]=B(p$1.relative(o,p$1.join(l,v)))||"./");}}return s.files&&(s.files=s.files.map(r=>B(p$1.relative(o,p$1.join(l,r))))),s.include&&(s.include=s.include.map(r=>B(p$1.relative(o,p$1.join(l,r))))),s.exclude&&(s.exclude=s.exclude.map(r=>B(p$1.relative(o,p$1.join(l,r))))),s},te=(e,o,i=new Set)=>{let n;try{n=ae(o,e);}catch{throw new Error(`Cannot resolve tsconfig at path: ${e}`)}let t=ne(n,o)||{};if(typeof t!="object")throw new SyntaxError(`Failed to parse tsconfig at: ${e}`);const l=p$1.dirname(n);if(t.compilerOptions){const{compilerOptions:s}=t;s.paths&&!s.baseUrl&&(s[M]=l);}if(t.extends){const s=Array.isArray(t.extends)?t.extends:[t.extends];delete t.extends;for(const m of s.reverse()){const r=je(m,l,new Set(i),o),b={...r,...t,compilerOptions:{...r.compilerOptions,...t.compilerOptions}};r.watchOptions&&(b.watchOptions={...r.watchOptions,...t.watchOptions}),t=b;}}if(t.compilerOptions){const{compilerOptions:s}=t,m=["baseUrl","rootDir"];for(const b of m){const v=s[b];if(v){const c=p$1.resolve(l,v),L=W(p$1.relative(l,c));s[b]=L;}}const{outDir:r}=s;r&&(Array.isArray(t.exclude)||(t.exclude=[]),t.exclude.includes(r)||t.exclude.push(r),s.outDir=W(r));}else t.compilerOptions={};if(t.files&&(t.files=t.files.map(W)),t.include&&(t.include=t.include.map(B)),t.watchOptions){const{watchOptions:s}=t;s.excludeDirectories&&(s.excludeDirectories=s.excludeDirectories.map(m=>B(p$1.resolve(l,m))));}return t},ie=(e,o=new Map)=>te(e,o),$e=(e=process.cwd(),o="tsconfig.json",i=new Map)=>{const n=Z(B(e),o,i);if(!n)return null;const t=ie(n,i);return {path:n,config:t}};p$1.posix;process.platform==="win32";
|
|
165
|
+
function B(e){return e.startsWith("\\\\?\\")?e:e.replace(/\\/g,"/")}const W=e=>{const t=require$$0[e];return (i,...n)=>{const l=`${e}:${n.join(":")}`;let s=i==null?void 0:i.get(l);return s===void 0&&(s=Reflect.apply(t,require$$0,n),i==null||i.set(l,s)),s}},_=W("existsSync"),ke=W("readFileSync"),I=W("statSync"),q=(e,t,i)=>{for(;;){const n=p$1.posix.join(e,t);if(_(i,n))return n;const l=p$1.dirname(e);if(l===e)return;e=l;}},h=/^\.{1,2}(\/.*)?$/,J=e=>{const t=B(e);return h.test(t)?t:`./${t}`};function be(e,t=!1){const i=e.length;let n=0,l="",s=0,o=16,m=0,u=0,w=0,v=0,f=0;function E(r,g){let c=0,$=0;for(;c<r||!g;){let A=e.charCodeAt(n);if(A>=48&&A<=57)$=$*16+A-48;else if(A>=65&&A<=70)$=$*16+A-65+10;else if(A>=97&&A<=102)$=$*16+A-97+10;else break;n++,c++;}return c<r&&($=-1),$}function b(r){n=r,l="",s=0,o=16,f=0;}function T(){let r=n;if(e.charCodeAt(n)===48)n++;else for(n++;n<e.length&&y(e.charCodeAt(n));)n++;if(n<e.length&&e.charCodeAt(n)===46)if(n++,n<e.length&&y(e.charCodeAt(n)))for(n++;n<e.length&&y(e.charCodeAt(n));)n++;else return f=3,e.substring(r,n);let g=n;if(n<e.length&&(e.charCodeAt(n)===69||e.charCodeAt(n)===101))if(n++,(n<e.length&&e.charCodeAt(n)===43||e.charCodeAt(n)===45)&&n++,n<e.length&&y(e.charCodeAt(n))){for(n++;n<e.length&&y(e.charCodeAt(n));)n++;g=n;}else f=3;return e.substring(r,g)}function k(){let r="",g=n;for(;;){if(n>=i){r+=e.substring(g,n),f=2;break}const c=e.charCodeAt(n);if(c===34){r+=e.substring(g,n),n++;break}if(c===92){if(r+=e.substring(g,n),n++,n>=i){f=2;break}switch(e.charCodeAt(n++)){case 34:r+='"';break;case 92:r+="\\";break;case 47:r+="/";break;case 98:r+="\b";break;case 102:r+="\f";break;case 110:r+=`
|
|
166
|
+
`;break;case 114:r+="\r";break;case 116:r+=" ";break;case 117:const A=E(4,!0);A>=0?r+=String.fromCharCode(A):f=4;break;default:f=5;}g=n;continue}if(c>=0&&c<=31)if(N(c)){r+=e.substring(g,n),f=2;break}else f=6;n++;}return r}function j(){if(l="",f=0,s=n,u=m,v=w,n>=i)return s=i,o=17;let r=e.charCodeAt(n);if(M(r)){do n++,l+=String.fromCharCode(r),r=e.charCodeAt(n);while(M(r));return o=15}if(N(r))return n++,l+=String.fromCharCode(r),r===13&&e.charCodeAt(n)===10&&(n++,l+=`
|
|
167
|
+
`),m++,w=n,o=14;switch(r){case 123:return n++,o=1;case 125:return n++,o=2;case 91:return n++,o=3;case 93:return n++,o=4;case 58:return n++,o=6;case 44:return n++,o=5;case 34:return n++,l=k(),o=10;case 47:const g=n-1;if(e.charCodeAt(n+1)===47){for(n+=2;n<i&&!N(e.charCodeAt(n));)n++;return l=e.substring(g,n),o=12}if(e.charCodeAt(n+1)===42){n+=2;const c=i-1;let $=!1;for(;n<c;){const A=e.charCodeAt(n);if(A===42&&e.charCodeAt(n+1)===47){n+=2,$=!0;break}n++,N(A)&&(A===13&&e.charCodeAt(n)===10&&n++,m++,w=n);}return $||(n++,f=1),l=e.substring(g,n),o=13}return l+=String.fromCharCode(r),n++,o=16;case 45:if(l+=String.fromCharCode(r),n++,n===i||!y(e.charCodeAt(n)))return o=16;case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return l+=T(),o=11;default:for(;n<i&&L(r);)n++,r=e.charCodeAt(n);if(s!==n){switch(l=e.substring(s,n),l){case"true":return o=8;case"false":return o=9;case"null":return o=7}return o=16}return l+=String.fromCharCode(r),n++,o=16}}function L(r){if(M(r)||N(r))return !1;switch(r){case 125:case 93:case 123:case 91:case 34:case 58:case 44:case 47:return !1}return !0}function U(){let r;do r=j();while(r>=12&&r<=15);return r}return {setPosition:b,getPosition:()=>n,scan:t?U:j,getToken:()=>o,getTokenValue:()=>l,getTokenOffset:()=>s,getTokenLength:()=>n-s,getTokenStartLine:()=>u,getTokenStartCharacter:()=>s-v,getTokenError:()=>f}}function M(e){return e===32||e===9}function N(e){return e===10||e===13}function y(e){return e>=48&&e<=57}var K;((function(e){e[e.lineFeed=10]="lineFeed",e[e.carriageReturn=13]="carriageReturn",e[e.space=32]="space",e[e._0=48]="_0",e[e._1=49]="_1",e[e._2=50]="_2",e[e._3=51]="_3",e[e._4=52]="_4",e[e._5=53]="_5",e[e._6=54]="_6",e[e._7=55]="_7",e[e._8=56]="_8",e[e._9=57]="_9",e[e.a=97]="a",e[e.b=98]="b",e[e.c=99]="c",e[e.d=100]="d",e[e.e=101]="e",e[e.f=102]="f",e[e.g=103]="g",e[e.h=104]="h",e[e.i=105]="i",e[e.j=106]="j",e[e.k=107]="k",e[e.l=108]="l",e[e.m=109]="m",e[e.n=110]="n",e[e.o=111]="o",e[e.p=112]="p",e[e.q=113]="q",e[e.r=114]="r",e[e.s=115]="s",e[e.t=116]="t",e[e.u=117]="u",e[e.v=118]="v",e[e.w=119]="w",e[e.x=120]="x",e[e.y=121]="y",e[e.z=122]="z",e[e.A=65]="A",e[e.B=66]="B",e[e.C=67]="C",e[e.D=68]="D",e[e.E=69]="E",e[e.F=70]="F",e[e.G=71]="G",e[e.H=72]="H",e[e.I=73]="I",e[e.J=74]="J",e[e.K=75]="K",e[e.L=76]="L",e[e.M=77]="M",e[e.N=78]="N",e[e.O=79]="O",e[e.P=80]="P",e[e.Q=81]="Q",e[e.R=82]="R",e[e.S=83]="S",e[e.T=84]="T",e[e.U=85]="U",e[e.V=86]="V",e[e.W=87]="W",e[e.X=88]="X",e[e.Y=89]="Y",e[e.Z=90]="Z",e[e.asterisk=42]="asterisk",e[e.backslash=92]="backslash",e[e.closeBrace=125]="closeBrace",e[e.closeBracket=93]="closeBracket",e[e.colon=58]="colon",e[e.comma=44]="comma",e[e.dot=46]="dot",e[e.doubleQuote=34]="doubleQuote",e[e.minus=45]="minus",e[e.openBrace=123]="openBrace",e[e.openBracket=91]="openBracket",e[e.plus=43]="plus",e[e.slash=47]="slash",e[e.formFeed=12]="formFeed",e[e.tab=9]="tab";}))(K||(K={})),new Array(20).fill(0).map((e,t)=>" ".repeat(t));const F=200;new Array(F).fill(0).map((e,t)=>`
|
|
168
|
+
`+" ".repeat(t)),new Array(F).fill(0).map((e,t)=>"\r"+" ".repeat(t)),new Array(F).fill(0).map((e,t)=>`\r
|
|
169
|
+
`+" ".repeat(t)),new Array(F).fill(0).map((e,t)=>`
|
|
170
|
+
`+" ".repeat(t)),new Array(F).fill(0).map((e,t)=>"\r"+" ".repeat(t)),new Array(F).fill(0).map((e,t)=>`\r
|
|
171
|
+
`+" ".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";
|
|
62
172
|
|
|
63
173
|
const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
|
|
64
174
|
const newLineRegExp = /\r?\n/;
|
|
@@ -66,8 +176,9 @@ const errCodeRegExp = /error TS(?<errCode>\d+)/;
|
|
|
66
176
|
async function makeTscErrorInfo(errInfo) {
|
|
67
177
|
var _a;
|
|
68
178
|
const [errFilePathPos = "", ...errMsgRawArr] = errInfo.split(":");
|
|
69
|
-
if (!errFilePathPos || errMsgRawArr.length === 0 || errMsgRawArr.join("").length === 0)
|
|
179
|
+
if (!errFilePathPos || errMsgRawArr.length === 0 || errMsgRawArr.join("").length === 0) {
|
|
70
180
|
return ["unknown filepath", null];
|
|
181
|
+
}
|
|
71
182
|
const errMsgRaw = errMsgRawArr.join("").trim();
|
|
72
183
|
const [errFilePath, errPos] = errFilePathPos.slice(0, -1).split("(");
|
|
73
184
|
if (!errFilePath || !errPos)
|
|
@@ -161,6 +272,317 @@ function createIndexMap(source) {
|
|
|
161
272
|
return map;
|
|
162
273
|
}
|
|
163
274
|
|
|
275
|
+
// AST walker module for ESTree compatible trees
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
// An ancestor walk keeps an array of ancestor nodes (including the
|
|
279
|
+
// current node) and passes them to the callback as third parameter
|
|
280
|
+
// (and also as state parameter when no other state is present).
|
|
281
|
+
function ancestor(node, visitors, baseVisitor, state, override) {
|
|
282
|
+
var ancestors = [];
|
|
283
|
+
if (!baseVisitor) { baseVisitor = base
|
|
284
|
+
; }(function c(node, st, override) {
|
|
285
|
+
var type = override || node.type;
|
|
286
|
+
var isNew = node !== ancestors[ancestors.length - 1];
|
|
287
|
+
if (isNew) { ancestors.push(node); }
|
|
288
|
+
baseVisitor[type](node, st, c);
|
|
289
|
+
if (visitors[type]) { visitors[type](node, st || ancestors, ancestors); }
|
|
290
|
+
if (isNew) { ancestors.pop(); }
|
|
291
|
+
})(node, state, override);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
function makeTest(test) {
|
|
295
|
+
if (typeof test === "string")
|
|
296
|
+
{ return function (type) { return type === test; } }
|
|
297
|
+
else if (!test)
|
|
298
|
+
{ return function () { return true; } }
|
|
299
|
+
else
|
|
300
|
+
{ return test }
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
var Found = function Found(node, state) { this.node = node; this.state = state; };
|
|
304
|
+
|
|
305
|
+
// Find the innermost node of a given type that contains the given
|
|
306
|
+
// position. Interface similar to findNodeAt.
|
|
307
|
+
function findNodeAround(node, pos, test, baseVisitor, state) {
|
|
308
|
+
test = makeTest(test);
|
|
309
|
+
if (!baseVisitor) { baseVisitor = base; }
|
|
310
|
+
try {
|
|
311
|
+
(function c(node, st, override) {
|
|
312
|
+
var type = override || node.type;
|
|
313
|
+
if (node.start > pos || node.end < pos) { return }
|
|
314
|
+
baseVisitor[type](node, st, c);
|
|
315
|
+
if (test(type, node)) { throw new Found(node, st) }
|
|
316
|
+
})(node, state);
|
|
317
|
+
} catch (e) {
|
|
318
|
+
if (e instanceof Found) { return e }
|
|
319
|
+
throw e
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
function skipThrough(node, st, c) { c(node, st); }
|
|
324
|
+
function ignore(_node, _st, _c) {}
|
|
325
|
+
|
|
326
|
+
// Node walkers.
|
|
327
|
+
|
|
328
|
+
var base = {};
|
|
329
|
+
|
|
330
|
+
base.Program = base.BlockStatement = base.StaticBlock = function (node, st, c) {
|
|
331
|
+
for (var i = 0, list = node.body; i < list.length; i += 1)
|
|
332
|
+
{
|
|
333
|
+
var stmt = list[i];
|
|
334
|
+
|
|
335
|
+
c(stmt, st, "Statement");
|
|
336
|
+
}
|
|
337
|
+
};
|
|
338
|
+
base.Statement = skipThrough;
|
|
339
|
+
base.EmptyStatement = ignore;
|
|
340
|
+
base.ExpressionStatement = base.ParenthesizedExpression = base.ChainExpression =
|
|
341
|
+
function (node, st, c) { return c(node.expression, st, "Expression"); };
|
|
342
|
+
base.IfStatement = function (node, st, c) {
|
|
343
|
+
c(node.test, st, "Expression");
|
|
344
|
+
c(node.consequent, st, "Statement");
|
|
345
|
+
if (node.alternate) { c(node.alternate, st, "Statement"); }
|
|
346
|
+
};
|
|
347
|
+
base.LabeledStatement = function (node, st, c) { return c(node.body, st, "Statement"); };
|
|
348
|
+
base.BreakStatement = base.ContinueStatement = ignore;
|
|
349
|
+
base.WithStatement = function (node, st, c) {
|
|
350
|
+
c(node.object, st, "Expression");
|
|
351
|
+
c(node.body, st, "Statement");
|
|
352
|
+
};
|
|
353
|
+
base.SwitchStatement = function (node, st, c) {
|
|
354
|
+
c(node.discriminant, st, "Expression");
|
|
355
|
+
for (var i$1 = 0, list$1 = node.cases; i$1 < list$1.length; i$1 += 1) {
|
|
356
|
+
var cs = list$1[i$1];
|
|
357
|
+
|
|
358
|
+
if (cs.test) { c(cs.test, st, "Expression"); }
|
|
359
|
+
for (var i = 0, list = cs.consequent; i < list.length; i += 1)
|
|
360
|
+
{
|
|
361
|
+
var cons = list[i];
|
|
362
|
+
|
|
363
|
+
c(cons, st, "Statement");
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
};
|
|
367
|
+
base.SwitchCase = function (node, st, c) {
|
|
368
|
+
if (node.test) { c(node.test, st, "Expression"); }
|
|
369
|
+
for (var i = 0, list = node.consequent; i < list.length; i += 1)
|
|
370
|
+
{
|
|
371
|
+
var cons = list[i];
|
|
372
|
+
|
|
373
|
+
c(cons, st, "Statement");
|
|
374
|
+
}
|
|
375
|
+
};
|
|
376
|
+
base.ReturnStatement = base.YieldExpression = base.AwaitExpression = function (node, st, c) {
|
|
377
|
+
if (node.argument) { c(node.argument, st, "Expression"); }
|
|
378
|
+
};
|
|
379
|
+
base.ThrowStatement = base.SpreadElement =
|
|
380
|
+
function (node, st, c) { return c(node.argument, st, "Expression"); };
|
|
381
|
+
base.TryStatement = function (node, st, c) {
|
|
382
|
+
c(node.block, st, "Statement");
|
|
383
|
+
if (node.handler) { c(node.handler, st); }
|
|
384
|
+
if (node.finalizer) { c(node.finalizer, st, "Statement"); }
|
|
385
|
+
};
|
|
386
|
+
base.CatchClause = function (node, st, c) {
|
|
387
|
+
if (node.param) { c(node.param, st, "Pattern"); }
|
|
388
|
+
c(node.body, st, "Statement");
|
|
389
|
+
};
|
|
390
|
+
base.WhileStatement = base.DoWhileStatement = function (node, st, c) {
|
|
391
|
+
c(node.test, st, "Expression");
|
|
392
|
+
c(node.body, st, "Statement");
|
|
393
|
+
};
|
|
394
|
+
base.ForStatement = function (node, st, c) {
|
|
395
|
+
if (node.init) { c(node.init, st, "ForInit"); }
|
|
396
|
+
if (node.test) { c(node.test, st, "Expression"); }
|
|
397
|
+
if (node.update) { c(node.update, st, "Expression"); }
|
|
398
|
+
c(node.body, st, "Statement");
|
|
399
|
+
};
|
|
400
|
+
base.ForInStatement = base.ForOfStatement = function (node, st, c) {
|
|
401
|
+
c(node.left, st, "ForInit");
|
|
402
|
+
c(node.right, st, "Expression");
|
|
403
|
+
c(node.body, st, "Statement");
|
|
404
|
+
};
|
|
405
|
+
base.ForInit = function (node, st, c) {
|
|
406
|
+
if (node.type === "VariableDeclaration") { c(node, st); }
|
|
407
|
+
else { c(node, st, "Expression"); }
|
|
408
|
+
};
|
|
409
|
+
base.DebuggerStatement = ignore;
|
|
410
|
+
|
|
411
|
+
base.FunctionDeclaration = function (node, st, c) { return c(node, st, "Function"); };
|
|
412
|
+
base.VariableDeclaration = function (node, st, c) {
|
|
413
|
+
for (var i = 0, list = node.declarations; i < list.length; i += 1)
|
|
414
|
+
{
|
|
415
|
+
var decl = list[i];
|
|
416
|
+
|
|
417
|
+
c(decl, st);
|
|
418
|
+
}
|
|
419
|
+
};
|
|
420
|
+
base.VariableDeclarator = function (node, st, c) {
|
|
421
|
+
c(node.id, st, "Pattern");
|
|
422
|
+
if (node.init) { c(node.init, st, "Expression"); }
|
|
423
|
+
};
|
|
424
|
+
|
|
425
|
+
base.Function = function (node, st, c) {
|
|
426
|
+
if (node.id) { c(node.id, st, "Pattern"); }
|
|
427
|
+
for (var i = 0, list = node.params; i < list.length; i += 1)
|
|
428
|
+
{
|
|
429
|
+
var param = list[i];
|
|
430
|
+
|
|
431
|
+
c(param, st, "Pattern");
|
|
432
|
+
}
|
|
433
|
+
c(node.body, st, node.expression ? "Expression" : "Statement");
|
|
434
|
+
};
|
|
435
|
+
|
|
436
|
+
base.Pattern = function (node, st, c) {
|
|
437
|
+
if (node.type === "Identifier")
|
|
438
|
+
{ c(node, st, "VariablePattern"); }
|
|
439
|
+
else if (node.type === "MemberExpression")
|
|
440
|
+
{ c(node, st, "MemberPattern"); }
|
|
441
|
+
else
|
|
442
|
+
{ c(node, st); }
|
|
443
|
+
};
|
|
444
|
+
base.VariablePattern = ignore;
|
|
445
|
+
base.MemberPattern = skipThrough;
|
|
446
|
+
base.RestElement = function (node, st, c) { return c(node.argument, st, "Pattern"); };
|
|
447
|
+
base.ArrayPattern = function (node, st, c) {
|
|
448
|
+
for (var i = 0, list = node.elements; i < list.length; i += 1) {
|
|
449
|
+
var elt = list[i];
|
|
450
|
+
|
|
451
|
+
if (elt) { c(elt, st, "Pattern"); }
|
|
452
|
+
}
|
|
453
|
+
};
|
|
454
|
+
base.ObjectPattern = function (node, st, c) {
|
|
455
|
+
for (var i = 0, list = node.properties; i < list.length; i += 1) {
|
|
456
|
+
var prop = list[i];
|
|
457
|
+
|
|
458
|
+
if (prop.type === "Property") {
|
|
459
|
+
if (prop.computed) { c(prop.key, st, "Expression"); }
|
|
460
|
+
c(prop.value, st, "Pattern");
|
|
461
|
+
} else if (prop.type === "RestElement") {
|
|
462
|
+
c(prop.argument, st, "Pattern");
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
};
|
|
466
|
+
|
|
467
|
+
base.Expression = skipThrough;
|
|
468
|
+
base.ThisExpression = base.Super = base.MetaProperty = ignore;
|
|
469
|
+
base.ArrayExpression = function (node, st, c) {
|
|
470
|
+
for (var i = 0, list = node.elements; i < list.length; i += 1) {
|
|
471
|
+
var elt = list[i];
|
|
472
|
+
|
|
473
|
+
if (elt) { c(elt, st, "Expression"); }
|
|
474
|
+
}
|
|
475
|
+
};
|
|
476
|
+
base.ObjectExpression = function (node, st, c) {
|
|
477
|
+
for (var i = 0, list = node.properties; i < list.length; i += 1)
|
|
478
|
+
{
|
|
479
|
+
var prop = list[i];
|
|
480
|
+
|
|
481
|
+
c(prop, st);
|
|
482
|
+
}
|
|
483
|
+
};
|
|
484
|
+
base.FunctionExpression = base.ArrowFunctionExpression = base.FunctionDeclaration;
|
|
485
|
+
base.SequenceExpression = function (node, st, c) {
|
|
486
|
+
for (var i = 0, list = node.expressions; i < list.length; i += 1)
|
|
487
|
+
{
|
|
488
|
+
var expr = list[i];
|
|
489
|
+
|
|
490
|
+
c(expr, st, "Expression");
|
|
491
|
+
}
|
|
492
|
+
};
|
|
493
|
+
base.TemplateLiteral = function (node, st, c) {
|
|
494
|
+
for (var i = 0, list = node.quasis; i < list.length; i += 1)
|
|
495
|
+
{
|
|
496
|
+
var quasi = list[i];
|
|
497
|
+
|
|
498
|
+
c(quasi, st);
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
for (var i$1 = 0, list$1 = node.expressions; i$1 < list$1.length; i$1 += 1)
|
|
502
|
+
{
|
|
503
|
+
var expr = list$1[i$1];
|
|
504
|
+
|
|
505
|
+
c(expr, st, "Expression");
|
|
506
|
+
}
|
|
507
|
+
};
|
|
508
|
+
base.TemplateElement = ignore;
|
|
509
|
+
base.UnaryExpression = base.UpdateExpression = function (node, st, c) {
|
|
510
|
+
c(node.argument, st, "Expression");
|
|
511
|
+
};
|
|
512
|
+
base.BinaryExpression = base.LogicalExpression = function (node, st, c) {
|
|
513
|
+
c(node.left, st, "Expression");
|
|
514
|
+
c(node.right, st, "Expression");
|
|
515
|
+
};
|
|
516
|
+
base.AssignmentExpression = base.AssignmentPattern = function (node, st, c) {
|
|
517
|
+
c(node.left, st, "Pattern");
|
|
518
|
+
c(node.right, st, "Expression");
|
|
519
|
+
};
|
|
520
|
+
base.ConditionalExpression = function (node, st, c) {
|
|
521
|
+
c(node.test, st, "Expression");
|
|
522
|
+
c(node.consequent, st, "Expression");
|
|
523
|
+
c(node.alternate, st, "Expression");
|
|
524
|
+
};
|
|
525
|
+
base.NewExpression = base.CallExpression = function (node, st, c) {
|
|
526
|
+
c(node.callee, st, "Expression");
|
|
527
|
+
if (node.arguments)
|
|
528
|
+
{ for (var i = 0, list = node.arguments; i < list.length; i += 1)
|
|
529
|
+
{
|
|
530
|
+
var arg = list[i];
|
|
531
|
+
|
|
532
|
+
c(arg, st, "Expression");
|
|
533
|
+
} }
|
|
534
|
+
};
|
|
535
|
+
base.MemberExpression = function (node, st, c) {
|
|
536
|
+
c(node.object, st, "Expression");
|
|
537
|
+
if (node.computed) { c(node.property, st, "Expression"); }
|
|
538
|
+
};
|
|
539
|
+
base.ExportNamedDeclaration = base.ExportDefaultDeclaration = function (node, st, c) {
|
|
540
|
+
if (node.declaration)
|
|
541
|
+
{ c(node.declaration, st, node.type === "ExportNamedDeclaration" || node.declaration.id ? "Statement" : "Expression"); }
|
|
542
|
+
if (node.source) { c(node.source, st, "Expression"); }
|
|
543
|
+
};
|
|
544
|
+
base.ExportAllDeclaration = function (node, st, c) {
|
|
545
|
+
if (node.exported)
|
|
546
|
+
{ c(node.exported, st); }
|
|
547
|
+
c(node.source, st, "Expression");
|
|
548
|
+
};
|
|
549
|
+
base.ImportDeclaration = function (node, st, c) {
|
|
550
|
+
for (var i = 0, list = node.specifiers; i < list.length; i += 1)
|
|
551
|
+
{
|
|
552
|
+
var spec = list[i];
|
|
553
|
+
|
|
554
|
+
c(spec, st);
|
|
555
|
+
}
|
|
556
|
+
c(node.source, st, "Expression");
|
|
557
|
+
};
|
|
558
|
+
base.ImportExpression = function (node, st, c) {
|
|
559
|
+
c(node.source, st, "Expression");
|
|
560
|
+
};
|
|
561
|
+
base.ImportSpecifier = base.ImportDefaultSpecifier = base.ImportNamespaceSpecifier = base.Identifier = base.PrivateIdentifier = base.Literal = ignore;
|
|
562
|
+
|
|
563
|
+
base.TaggedTemplateExpression = function (node, st, c) {
|
|
564
|
+
c(node.tag, st, "Expression");
|
|
565
|
+
c(node.quasi, st, "Expression");
|
|
566
|
+
};
|
|
567
|
+
base.ClassDeclaration = base.ClassExpression = function (node, st, c) { return c(node, st, "Class"); };
|
|
568
|
+
base.Class = function (node, st, c) {
|
|
569
|
+
if (node.id) { c(node.id, st, "Pattern"); }
|
|
570
|
+
if (node.superClass) { c(node.superClass, st, "Expression"); }
|
|
571
|
+
c(node.body, st);
|
|
572
|
+
};
|
|
573
|
+
base.ClassBody = function (node, st, c) {
|
|
574
|
+
for (var i = 0, list = node.body; i < list.length; i += 1)
|
|
575
|
+
{
|
|
576
|
+
var elt = list[i];
|
|
577
|
+
|
|
578
|
+
c(elt, st);
|
|
579
|
+
}
|
|
580
|
+
};
|
|
581
|
+
base.MethodDefinition = base.PropertyDefinition = base.Property = function (node, st, c) {
|
|
582
|
+
if (node.computed) { c(node.key, st, "Expression"); }
|
|
583
|
+
if (node.value) { c(node.value, st, "Expression"); }
|
|
584
|
+
};
|
|
585
|
+
|
|
164
586
|
async function collectTests(ctx, filepath) {
|
|
165
587
|
const request = await ctx.vitenode.transformRequest(filepath, filepath);
|
|
166
588
|
if (!request)
|
|
@@ -177,8 +599,10 @@ async function collectTests(ctx, filepath) {
|
|
|
177
599
|
start: ast.start,
|
|
178
600
|
end: ast.end,
|
|
179
601
|
projectName: ctx.getName(),
|
|
180
|
-
meta: { typecheck: true }
|
|
602
|
+
meta: { typecheck: true },
|
|
603
|
+
file: null
|
|
181
604
|
};
|
|
605
|
+
file.file = file;
|
|
182
606
|
const definitions = [];
|
|
183
607
|
const getName = (callee) => {
|
|
184
608
|
var _a, _b, _c;
|
|
@@ -240,7 +664,6 @@ async function collectTests(ctx, filepath) {
|
|
|
240
664
|
name: definition.name,
|
|
241
665
|
end: definition.end,
|
|
242
666
|
start: definition.start,
|
|
243
|
-
projectName: ctx.getName(),
|
|
244
667
|
meta: {
|
|
245
668
|
typecheck: true
|
|
246
669
|
}
|
|
@@ -385,6 +808,8 @@ class Typechecker {
|
|
|
385
808
|
};
|
|
386
809
|
if (task.suite)
|
|
387
810
|
markState(task.suite, state);
|
|
811
|
+
else if (task.file && task !== task.file)
|
|
812
|
+
markState(task.file, state);
|
|
388
813
|
};
|
|
389
814
|
errors.forEach(({ error, originalError }) => {
|
|
390
815
|
var _a;
|
|
@@ -405,8 +830,12 @@ class Typechecker {
|
|
|
405
830
|
errors: errors2
|
|
406
831
|
};
|
|
407
832
|
errors2.push(error);
|
|
408
|
-
if (state === "fail"
|
|
409
|
-
|
|
833
|
+
if (state === "fail") {
|
|
834
|
+
if (suite.suite)
|
|
835
|
+
markState(suite.suite, "fail");
|
|
836
|
+
else if (suite.file && suite !== suite.file)
|
|
837
|
+
markState(suite.file, "fail");
|
|
838
|
+
}
|
|
410
839
|
});
|
|
411
840
|
this.markPassed(file);
|
|
412
841
|
});
|
|
@@ -542,7 +971,6 @@ class Typechecker {
|
|
|
542
971
|
}
|
|
543
972
|
}
|
|
544
973
|
|
|
545
|
-
var _a;
|
|
546
974
|
const BADGE_PADDING = " ";
|
|
547
975
|
const HELP_HINT = `${c.dim("press ")}${c.bold("h")}${c.dim(" to show help")}`;
|
|
548
976
|
const HELP_UPDATE_SNAP = c.dim("press ") + c.bold(c.yellow("u")) + c.dim(" to update snapshot");
|
|
@@ -558,7 +986,7 @@ class BaseReporter {
|
|
|
558
986
|
start = 0;
|
|
559
987
|
end = 0;
|
|
560
988
|
watchFilters;
|
|
561
|
-
isTTY
|
|
989
|
+
isTTY;
|
|
562
990
|
ctx = void 0;
|
|
563
991
|
_filesInWatchMode = /* @__PURE__ */ new Map();
|
|
564
992
|
_lastRunTimeout = 0;
|
|
@@ -566,7 +994,9 @@ class BaseReporter {
|
|
|
566
994
|
_lastRunCount = 0;
|
|
567
995
|
_timeStart = /* @__PURE__ */ new Date();
|
|
568
996
|
_offUnhandledRejection;
|
|
569
|
-
constructor() {
|
|
997
|
+
constructor(options = {}) {
|
|
998
|
+
var _a;
|
|
999
|
+
this.isTTY = options.isTTY ?? (isNode && ((_a = process.stdout) == null ? void 0 : _a.isTTY) && !isCI);
|
|
570
1000
|
this.registerUnhandledRejection();
|
|
571
1001
|
}
|
|
572
1002
|
get mode() {
|
|
@@ -575,8 +1005,8 @@ class BaseReporter {
|
|
|
575
1005
|
onInit(ctx) {
|
|
576
1006
|
this.ctx = ctx;
|
|
577
1007
|
ctx.onClose(() => {
|
|
578
|
-
var
|
|
579
|
-
(
|
|
1008
|
+
var _a;
|
|
1009
|
+
(_a = this._offUnhandledRejection) == null ? void 0 : _a.call(this);
|
|
580
1010
|
});
|
|
581
1011
|
ctx.logger.printBanner();
|
|
582
1012
|
this.start = performance.now();
|
|
@@ -584,26 +1014,26 @@ class BaseReporter {
|
|
|
584
1014
|
relative(path) {
|
|
585
1015
|
return relativePath(this.ctx.config.root, path);
|
|
586
1016
|
}
|
|
587
|
-
|
|
1017
|
+
onFinished(files = this.ctx.state.getFiles(), errors = this.ctx.state.getUnhandledErrors()) {
|
|
588
1018
|
this.end = performance.now();
|
|
589
|
-
|
|
1019
|
+
this.reportSummary(files, errors);
|
|
590
1020
|
if (errors.length) {
|
|
591
1021
|
if (!this.ctx.config.dangerouslyIgnoreUnhandledErrors)
|
|
592
1022
|
process.exitCode = 1;
|
|
593
1023
|
}
|
|
594
1024
|
}
|
|
595
1025
|
onTaskUpdate(packs) {
|
|
596
|
-
var
|
|
1026
|
+
var _a, _b, _c, _d;
|
|
597
1027
|
if (this.isTTY)
|
|
598
1028
|
return;
|
|
599
1029
|
const logger = this.ctx.logger;
|
|
600
1030
|
for (const pack of packs) {
|
|
601
1031
|
const task = this.ctx.state.idMap.get(pack[0]);
|
|
602
|
-
if (task && "filepath" in task && ((
|
|
1032
|
+
if (task && "filepath" in task && ((_a = task.result) == null ? void 0 : _a.state) && ((_b = task.result) == null ? void 0 : _b.state) !== "run") {
|
|
603
1033
|
const tests = getTests(task);
|
|
604
1034
|
const failed = tests.filter((t) => {
|
|
605
|
-
var
|
|
606
|
-
return ((
|
|
1035
|
+
var _a2;
|
|
1036
|
+
return ((_a2 = t.result) == null ? void 0 : _a2.state) === "fail";
|
|
607
1037
|
});
|
|
608
1038
|
const skipped = tests.filter((t) => t.mode === "skip" || t.mode === "todo");
|
|
609
1039
|
let state = c.dim(`${tests.length} test${tests.length > 1 ? "s" : ""}`);
|
|
@@ -632,7 +1062,7 @@ class BaseReporter {
|
|
|
632
1062
|
}
|
|
633
1063
|
}
|
|
634
1064
|
}
|
|
635
|
-
|
|
1065
|
+
onWatcherStart(files = this.ctx.state.getFiles(), errors = this.ctx.state.getUnhandledErrors()) {
|
|
636
1066
|
this.resetLastRunLog();
|
|
637
1067
|
const failed = errors.length > 0 || hasFailed(files);
|
|
638
1068
|
const failedSnap = hasFailedSnapshot(files);
|
|
@@ -678,7 +1108,7 @@ class BaseReporter {
|
|
|
678
1108
|
this._lastRunTimer = void 0;
|
|
679
1109
|
this.ctx.logger.logUpdate.clear();
|
|
680
1110
|
}
|
|
681
|
-
|
|
1111
|
+
onWatcherRerun(files, trigger) {
|
|
682
1112
|
this.resetLastRunLog();
|
|
683
1113
|
this.watchFilters = files;
|
|
684
1114
|
files.forEach((filepath) => {
|
|
@@ -714,15 +1144,32 @@ ${PROJECT_FILTER}${FILENAME_PATTERN}${TESTNAME_PATTERN}`);
|
|
|
714
1144
|
const task = log.taskId ? this.ctx.state.idMap.get(log.taskId) : void 0;
|
|
715
1145
|
const header = c.gray(log.type + c.dim(` | ${task ? getFullName(task, c.dim(" > ")) : log.taskId !== UNKNOWN_TEST_ID ? log.taskId : "unknown test"}`));
|
|
716
1146
|
const output = log.type === "stdout" ? this.ctx.logger.outputStream : this.ctx.logger.errorStream;
|
|
717
|
-
output.write(
|
|
718
|
-
|
|
719
|
-
`);
|
|
1147
|
+
const write = (msg) => output.write(msg);
|
|
1148
|
+
write(`${header}
|
|
1149
|
+
${log.content}`);
|
|
1150
|
+
if (log.origin) {
|
|
1151
|
+
if (log.browser)
|
|
1152
|
+
write("\n");
|
|
1153
|
+
const project = log.taskId ? this.ctx.getProjectByTaskId(log.taskId) : this.ctx.getCoreWorkspaceProject();
|
|
1154
|
+
const stack = parseStacktrace(log.origin, {
|
|
1155
|
+
getSourceMap: (file) => project.getBrowserSourceMapModuleById(file),
|
|
1156
|
+
frameFilter: project.config.onStackTrace
|
|
1157
|
+
});
|
|
1158
|
+
const highlight = task ? stack.find((i) => i.file === task.file.filepath) : null;
|
|
1159
|
+
for (const frame of stack) {
|
|
1160
|
+
const color = frame === highlight ? c.cyan : c.gray;
|
|
1161
|
+
const path = relative(project.config.root, frame.file);
|
|
1162
|
+
write(color(` ${c.dim(F_POINTER)} ${[frame.method, `${path}:${c.dim(`${frame.line}:${frame.column}`)}`].filter(Boolean).join(" ")}
|
|
1163
|
+
`));
|
|
1164
|
+
}
|
|
1165
|
+
}
|
|
1166
|
+
write("\n");
|
|
720
1167
|
}
|
|
721
1168
|
shouldLog(log) {
|
|
722
|
-
var
|
|
1169
|
+
var _a, _b;
|
|
723
1170
|
if (this.ctx.config.silent)
|
|
724
1171
|
return false;
|
|
725
|
-
const shouldLog = (_b = (
|
|
1172
|
+
const shouldLog = (_b = (_a = this.ctx.config).onConsoleLog) == null ? void 0 : _b.call(_a, log.content, log.type);
|
|
726
1173
|
if (shouldLog === false)
|
|
727
1174
|
return shouldLog;
|
|
728
1175
|
return true;
|
|
@@ -732,22 +1179,22 @@ ${log.content}
|
|
|
732
1179
|
reason === "config" ? "\nRestarting due to config changes..." : "\nRestarting Vitest..."
|
|
733
1180
|
)));
|
|
734
1181
|
}
|
|
735
|
-
|
|
736
|
-
|
|
1182
|
+
reportSummary(files, errors) {
|
|
1183
|
+
this.printErrorsSummary(files, errors);
|
|
737
1184
|
if (this.mode === "benchmark")
|
|
738
|
-
|
|
1185
|
+
this.reportBenchmarkSummary(files);
|
|
739
1186
|
else
|
|
740
|
-
|
|
1187
|
+
this.reportTestSummary(files, errors);
|
|
741
1188
|
}
|
|
742
|
-
|
|
1189
|
+
reportTestSummary(files, errors) {
|
|
743
1190
|
const tests = getTests(files);
|
|
744
1191
|
const logger = this.ctx.logger;
|
|
745
1192
|
const executionTime = this.end - this.start;
|
|
746
1193
|
const collectTime = files.reduce((acc, test) => acc + Math.max(0, test.collectDuration || 0), 0);
|
|
747
1194
|
const setupTime = files.reduce((acc, test) => acc + Math.max(0, test.setupDuration || 0), 0);
|
|
748
1195
|
const testsTime = files.reduce((acc, test) => {
|
|
749
|
-
var
|
|
750
|
-
return acc + Math.max(0, ((
|
|
1196
|
+
var _a;
|
|
1197
|
+
return acc + Math.max(0, ((_a = test.result) == null ? void 0 : _a.duration) || 0);
|
|
751
1198
|
}, 0);
|
|
752
1199
|
const transformTime = this.ctx.projects.flatMap((w) => w.vitenode.getTotalDuration()).reduce((a, b) => a + b, 0);
|
|
753
1200
|
const environmentTime = files.reduce((acc, file) => acc + Math.max(0, file.environmentLoad || 0), 0);
|
|
@@ -771,8 +1218,8 @@ ${log.content}
|
|
|
771
1218
|
logger.log(padTitle("Tests"), getStateString(tests));
|
|
772
1219
|
if (this.ctx.projects.some((c2) => c2.config.typecheck.enabled)) {
|
|
773
1220
|
const failed = tests.filter((t) => {
|
|
774
|
-
var
|
|
775
|
-
return ((
|
|
1221
|
+
var _a, _b, _c;
|
|
1222
|
+
return ((_a = t.meta) == null ? void 0 : _a.typecheck) && ((_c = (_b = t.result) == null ? void 0 : _b.errors) == null ? void 0 : _c.length);
|
|
776
1223
|
});
|
|
777
1224
|
logger.log(padTitle("Type Errors"), failed.length ? c.bold(c.red(`${failed.length} failed`)) : c.dim("no errors"));
|
|
778
1225
|
}
|
|
@@ -784,8 +1231,8 @@ ${log.content}
|
|
|
784
1231
|
} else {
|
|
785
1232
|
let timers = `transform ${time(transformTime)}, setup ${time(setupTime)}, collect ${time(collectTime)}, tests ${time(testsTime)}, environment ${time(environmentTime)}, prepare ${time(prepareTime)}`;
|
|
786
1233
|
const typecheck = this.ctx.projects.reduce((acc, c2) => {
|
|
787
|
-
var
|
|
788
|
-
return acc + (((
|
|
1234
|
+
var _a;
|
|
1235
|
+
return acc + (((_a = c2.typechecker) == null ? void 0 : _a.getResult().time) || 0);
|
|
789
1236
|
}, 0);
|
|
790
1237
|
if (typecheck)
|
|
791
1238
|
timers += `, typecheck ${time(typecheck)}`;
|
|
@@ -793,17 +1240,17 @@ ${log.content}
|
|
|
793
1240
|
}
|
|
794
1241
|
logger.log();
|
|
795
1242
|
}
|
|
796
|
-
|
|
1243
|
+
printErrorsSummary(files, errors) {
|
|
797
1244
|
const logger = this.ctx.logger;
|
|
798
1245
|
const suites = getSuites(files);
|
|
799
1246
|
const tests = getTests(files);
|
|
800
1247
|
const failedSuites = suites.filter((i) => {
|
|
801
|
-
var
|
|
802
|
-
return (
|
|
1248
|
+
var _a;
|
|
1249
|
+
return (_a = i.result) == null ? void 0 : _a.errors;
|
|
803
1250
|
});
|
|
804
1251
|
const failedTests = tests.filter((i) => {
|
|
805
|
-
var
|
|
806
|
-
return ((
|
|
1252
|
+
var _a;
|
|
1253
|
+
return ((_a = i.result) == null ? void 0 : _a.state) === "fail";
|
|
807
1254
|
});
|
|
808
1255
|
const failedTotal = countTestErrors(failedSuites) + countTestErrors(failedTests);
|
|
809
1256
|
let current = 1;
|
|
@@ -812,38 +1259,38 @@ ${log.content}
|
|
|
812
1259
|
if (failedSuites.length) {
|
|
813
1260
|
logger.error(c.red(divider(c.bold(c.inverse(` Failed Suites ${failedSuites.length} `)))));
|
|
814
1261
|
logger.error();
|
|
815
|
-
|
|
1262
|
+
this.printTaskErrors(failedSuites, errorDivider);
|
|
816
1263
|
}
|
|
817
1264
|
if (failedTests.length) {
|
|
818
1265
|
logger.error(c.red(divider(c.bold(c.inverse(` Failed Tests ${failedTests.length} `)))));
|
|
819
1266
|
logger.error();
|
|
820
|
-
|
|
1267
|
+
this.printTaskErrors(failedTests, errorDivider);
|
|
821
1268
|
}
|
|
822
1269
|
if (errors.length) {
|
|
823
|
-
|
|
1270
|
+
logger.printUnhandledErrors(errors);
|
|
824
1271
|
logger.error();
|
|
825
1272
|
}
|
|
826
1273
|
return tests;
|
|
827
1274
|
}
|
|
828
|
-
|
|
1275
|
+
reportBenchmarkSummary(files) {
|
|
829
1276
|
const logger = this.ctx.logger;
|
|
830
1277
|
const benches = getTests(files);
|
|
831
1278
|
const topBenches = benches.filter((i) => {
|
|
832
|
-
var
|
|
833
|
-
return ((_b = (
|
|
1279
|
+
var _a, _b;
|
|
1280
|
+
return ((_b = (_a = i.result) == null ? void 0 : _a.benchmark) == null ? void 0 : _b.rank) === 1;
|
|
834
1281
|
});
|
|
835
1282
|
logger.log(`
|
|
836
1283
|
${c.cyan(c.inverse(c.bold(" BENCH ")))} ${c.cyan("Summary")}
|
|
837
1284
|
`);
|
|
838
1285
|
for (const bench of topBenches) {
|
|
839
|
-
const group = bench.suite;
|
|
1286
|
+
const group = bench.suite || bench.file;
|
|
840
1287
|
if (!group)
|
|
841
1288
|
continue;
|
|
842
1289
|
const groupName = getFullName(group, c.dim(" > "));
|
|
843
1290
|
logger.log(` ${bench.name}${c.dim(` - ${groupName}`)}`);
|
|
844
1291
|
const siblings = group.tasks.filter((i) => {
|
|
845
|
-
var
|
|
846
|
-
return i.meta.benchmark && ((
|
|
1292
|
+
var _a;
|
|
1293
|
+
return i.meta.benchmark && ((_a = i.result) == null ? void 0 : _a.benchmark) && i !== bench;
|
|
847
1294
|
}).sort((a, b) => a.result.benchmark.rank - b.result.benchmark.rank);
|
|
848
1295
|
if (siblings.length === 0) {
|
|
849
1296
|
logger.log("");
|
|
@@ -856,18 +1303,18 @@ ${c.cyan(c.inverse(c.bold(" BENCH ")))} ${c.cyan("Summary")}
|
|
|
856
1303
|
logger.log("");
|
|
857
1304
|
}
|
|
858
1305
|
}
|
|
859
|
-
|
|
860
|
-
var
|
|
1306
|
+
printTaskErrors(tasks, errorDivider) {
|
|
1307
|
+
var _a, _b, _c;
|
|
861
1308
|
const errorsQueue = [];
|
|
862
1309
|
for (const task of tasks) {
|
|
863
|
-
(_b = (
|
|
1310
|
+
(_b = (_a = task.result) == null ? void 0 : _a.errors) == null ? void 0 : _b.forEach((error) => {
|
|
864
1311
|
const errorItem = (error == null ? void 0 : error.stackStr) && errorsQueue.find((i) => {
|
|
865
|
-
var
|
|
866
|
-
const hasStr = ((
|
|
1312
|
+
var _a2, _b2, _c2, _d;
|
|
1313
|
+
const hasStr = ((_a2 = i[0]) == null ? void 0 : _a2.stackStr) === error.stackStr;
|
|
867
1314
|
if (!hasStr)
|
|
868
1315
|
return false;
|
|
869
|
-
const currentProjectName = (task == null ? void 0 : task.projectName) || ((_b2 = task.file) == null ? void 0 : _b2.projectName);
|
|
870
|
-
const projectName = ((_c2 = i[1][0]) == null ? void 0 : _c2.projectName) || ((_d = i[1][0].file) == null ? void 0 : _d.projectName);
|
|
1316
|
+
const currentProjectName = (task == null ? void 0 : task.projectName) || ((_b2 = task.file) == null ? void 0 : _b2.projectName) || "";
|
|
1317
|
+
const projectName = ((_c2 = i[1][0]) == null ? void 0 : _c2.projectName) || ((_d = i[1][0].file) == null ? void 0 : _d.projectName) || "";
|
|
871
1318
|
return projectName === currentProjectName;
|
|
872
1319
|
});
|
|
873
1320
|
if (errorItem)
|
|
@@ -879,22 +1326,21 @@ ${c.cyan(c.inverse(c.bold(" BENCH ")))} ${c.cyan("Summary")}
|
|
|
879
1326
|
for (const [error, tasks2] of errorsQueue) {
|
|
880
1327
|
for (const task of tasks2) {
|
|
881
1328
|
const filepath = (task == null ? void 0 : task.filepath) || "";
|
|
882
|
-
const projectName = (task == null ? void 0 : task.projectName) || ((_c = task.file) == null ? void 0 : _c.projectName);
|
|
1329
|
+
const projectName = (task == null ? void 0 : task.projectName) || ((_c = task.file) == null ? void 0 : _c.projectName) || "";
|
|
883
1330
|
let name = getFullName(task, c.dim(" > "));
|
|
884
1331
|
if (filepath)
|
|
885
1332
|
name = `${name} ${c.dim(`[ ${this.relative(filepath)} ]`)}`;
|
|
886
1333
|
this.ctx.logger.error(`${c.red(c.bold(c.inverse(" FAIL ")))} ${formatProjectName(projectName)}${name}`);
|
|
887
1334
|
}
|
|
888
1335
|
const project = this.ctx.getProjectByTaskId(tasks2[0].id);
|
|
889
|
-
|
|
1336
|
+
this.ctx.logger.printError(error, { project });
|
|
890
1337
|
errorDivider();
|
|
891
|
-
await Promise.resolve();
|
|
892
1338
|
}
|
|
893
1339
|
}
|
|
894
1340
|
registerUnhandledRejection() {
|
|
895
1341
|
const onUnhandledRejection = async (err) => {
|
|
896
1342
|
process.exitCode = 1;
|
|
897
|
-
|
|
1343
|
+
this.ctx.logger.printError(err, { fullStack: true, type: "Unhandled Rejection" });
|
|
898
1344
|
this.ctx.logger.error("\n\n");
|
|
899
1345
|
process.exit(1);
|
|
900
1346
|
};
|
|
@@ -1820,7 +2266,7 @@ function formatFilepath$1(path) {
|
|
|
1820
2266
|
}
|
|
1821
2267
|
function formatNumber$1(number) {
|
|
1822
2268
|
const res = String(number.toFixed(number < 100 ? 4 : 2)).split(".");
|
|
1823
|
-
return res[0].replace(/(?=(?:\d{3})+$)
|
|
2269
|
+
return res[0].replace(/(?=(?:\d{3})+$)\B/g, ",") + (res[1] ? `.${res[1]}` : "");
|
|
1824
2270
|
}
|
|
1825
2271
|
function renderHookState(task, hookName, level = 0) {
|
|
1826
2272
|
var _a, _b;
|
|
@@ -1872,7 +2318,7 @@ function renderTree$1(tasks, options, level = 0, maxRows) {
|
|
|
1872
2318
|
const taskOutput = [];
|
|
1873
2319
|
let suffix = "";
|
|
1874
2320
|
let prefix = ` ${getStateSymbol(task)} `;
|
|
1875
|
-
if (level === 0 && task.type === "suite" && task
|
|
2321
|
+
if (level === 0 && task.type === "suite" && "projectName" in task)
|
|
1876
2322
|
prefix += formatProjectName(task.projectName);
|
|
1877
2323
|
if (task.type === "test" && ((_a = task.result) == null ? void 0 : _a.retryCount) && task.result.retryCount > 0)
|
|
1878
2324
|
suffix += c.yellow(` (retry x${task.result.retryCount})`);
|
|
@@ -1967,7 +2413,7 @@ function createListRenderer(_tasks, options) {
|
|
|
1967
2413
|
tasks = _tasks2;
|
|
1968
2414
|
return this;
|
|
1969
2415
|
},
|
|
1970
|
-
|
|
2416
|
+
stop() {
|
|
1971
2417
|
if (timer) {
|
|
1972
2418
|
clearInterval(timer);
|
|
1973
2419
|
timer = void 0;
|
|
@@ -2000,13 +2446,13 @@ class DefaultReporter extends BaseReporter {
|
|
|
2000
2446
|
}
|
|
2001
2447
|
}
|
|
2002
2448
|
async onTestRemoved(trigger) {
|
|
2003
|
-
|
|
2449
|
+
this.stopListRender();
|
|
2004
2450
|
this.ctx.logger.clearScreen(c.yellow("Test removed...") + (trigger ? c.dim(` [ ${this.relative(trigger)} ]
|
|
2005
2451
|
`) : ""), true);
|
|
2006
2452
|
const files = this.ctx.state.getFiles(this.watchFilters);
|
|
2007
2453
|
createListRenderer(files, this.rendererOptions).stop();
|
|
2008
2454
|
this.ctx.logger.log();
|
|
2009
|
-
|
|
2455
|
+
super.reportSummary(files, this.ctx.state.getUnhandledErrors());
|
|
2010
2456
|
super.onWatcherStart();
|
|
2011
2457
|
}
|
|
2012
2458
|
onCollected() {
|
|
@@ -2022,22 +2468,22 @@ class DefaultReporter extends BaseReporter {
|
|
|
2022
2468
|
this.renderer.update(files);
|
|
2023
2469
|
}
|
|
2024
2470
|
}
|
|
2025
|
-
|
|
2026
|
-
|
|
2471
|
+
onFinished(files = this.ctx.state.getFiles(), errors = this.ctx.state.getUnhandledErrors()) {
|
|
2472
|
+
this.stopListRender();
|
|
2027
2473
|
this.ctx.logger.log();
|
|
2028
|
-
|
|
2474
|
+
super.onFinished(files, errors);
|
|
2029
2475
|
}
|
|
2030
2476
|
async onWatcherStart(files = this.ctx.state.getFiles(), errors = this.ctx.state.getUnhandledErrors()) {
|
|
2031
|
-
|
|
2477
|
+
this.stopListRender();
|
|
2032
2478
|
await super.onWatcherStart(files, errors);
|
|
2033
2479
|
}
|
|
2034
|
-
|
|
2480
|
+
stopListRender() {
|
|
2035
2481
|
var _a;
|
|
2036
|
-
|
|
2482
|
+
(_a = this.renderer) == null ? void 0 : _a.stop();
|
|
2037
2483
|
this.renderer = void 0;
|
|
2038
2484
|
}
|
|
2039
2485
|
async onWatcherRerun(files, trigger) {
|
|
2040
|
-
|
|
2486
|
+
this.stopListRender();
|
|
2041
2487
|
await super.onWatcherRerun(files, trigger);
|
|
2042
2488
|
}
|
|
2043
2489
|
onUserConsoleLog(log) {
|
|
@@ -2156,7 +2602,7 @@ class DotReporter extends BaseReporter {
|
|
|
2156
2602
|
async onFinished(files = this.ctx.state.getFiles(), errors = this.ctx.state.getUnhandledErrors()) {
|
|
2157
2603
|
await this.stopListRender();
|
|
2158
2604
|
this.ctx.logger.log();
|
|
2159
|
-
|
|
2605
|
+
super.onFinished(files, errors);
|
|
2160
2606
|
}
|
|
2161
2607
|
async onWatcherStart() {
|
|
2162
2608
|
await this.stopListRender();
|
|
@@ -2170,7 +2616,7 @@ class DotReporter extends BaseReporter {
|
|
|
2170
2616
|
}
|
|
2171
2617
|
async onWatcherRerun(files, trigger) {
|
|
2172
2618
|
await this.stopListRender();
|
|
2173
|
-
|
|
2619
|
+
super.onWatcherRerun(files, trigger);
|
|
2174
2620
|
}
|
|
2175
2621
|
onUserConsoleLog(log) {
|
|
2176
2622
|
var _a;
|
|
@@ -2237,7 +2683,7 @@ class JsonReporter {
|
|
|
2237
2683
|
var _a2, _b2;
|
|
2238
2684
|
return Math.max(prev, (((_a2 = next.result) == null ? void 0 : _a2.startTime) ?? 0) + (((_b2 = next.result) == null ? void 0 : _b2.duration) ?? 0));
|
|
2239
2685
|
}, startTime);
|
|
2240
|
-
const assertionResults =
|
|
2686
|
+
const assertionResults = tests2.map((t) => {
|
|
2241
2687
|
var _a2, _b2, _c2, _d2;
|
|
2242
2688
|
const ancestorTitles = [];
|
|
2243
2689
|
let iter = t.suite;
|
|
@@ -2248,14 +2694,15 @@ class JsonReporter {
|
|
|
2248
2694
|
ancestorTitles.reverse();
|
|
2249
2695
|
return {
|
|
2250
2696
|
ancestorTitles,
|
|
2251
|
-
fullName:
|
|
2697
|
+
fullName: t.name ? [...ancestorTitles, t.name].join(" ") : ancestorTitles.join(" "),
|
|
2252
2698
|
status: StatusMap[((_a2 = t.result) == null ? void 0 : _a2.state) || t.mode] || "skipped",
|
|
2253
2699
|
title: t.name,
|
|
2254
2700
|
duration: (_b2 = t.result) == null ? void 0 : _b2.duration,
|
|
2255
|
-
failureMessages: ((_d2 = (_c2 = t.result) == null ? void 0 : _c2.errors) == null ? void 0 : _d2.map((e) => e.message)) || [],
|
|
2256
|
-
location:
|
|
2701
|
+
failureMessages: ((_d2 = (_c2 = t.result) == null ? void 0 : _c2.errors) == null ? void 0 : _d2.map((e) => e.stack || e.message)) || [],
|
|
2702
|
+
location: t.location,
|
|
2703
|
+
meta: t.meta
|
|
2257
2704
|
};
|
|
2258
|
-
})
|
|
2705
|
+
});
|
|
2259
2706
|
if (tests2.some((t) => {
|
|
2260
2707
|
var _a2;
|
|
2261
2708
|
return ((_a2 = t.result) == null ? void 0 : _a2.state) === "run";
|
|
@@ -2285,6 +2732,7 @@ class JsonReporter {
|
|
|
2285
2732
|
numFailedTests,
|
|
2286
2733
|
numPendingTests,
|
|
2287
2734
|
numTodoTests,
|
|
2735
|
+
snapshot: this.ctx.snapshot.summary,
|
|
2288
2736
|
startTime: this.start,
|
|
2289
2737
|
success,
|
|
2290
2738
|
testResults
|
|
@@ -2312,21 +2760,6 @@ class JsonReporter {
|
|
|
2312
2760
|
this.ctx.logger.log(report);
|
|
2313
2761
|
}
|
|
2314
2762
|
}
|
|
2315
|
-
async getFailureLocation(test) {
|
|
2316
|
-
var _a, _b;
|
|
2317
|
-
const error = (_b = (_a = test.result) == null ? void 0 : _a.errors) == null ? void 0 : _b[0];
|
|
2318
|
-
if (!error)
|
|
2319
|
-
return;
|
|
2320
|
-
const project = this.ctx.getProjectByTaskId(test.id);
|
|
2321
|
-
const stack = parseErrorStacktrace(error, {
|
|
2322
|
-
getSourceMap: (file) => project.getBrowserSourceMapModuleById(file),
|
|
2323
|
-
frameFilter: this.ctx.config.onStackTrace
|
|
2324
|
-
});
|
|
2325
|
-
const frame = stack[0];
|
|
2326
|
-
if (!frame)
|
|
2327
|
-
return;
|
|
2328
|
-
return { line: frame.line, column: frame.column };
|
|
2329
|
-
}
|
|
2330
2763
|
}
|
|
2331
2764
|
|
|
2332
2765
|
class VerboseReporter extends DefaultReporter {
|
|
@@ -2335,15 +2768,15 @@ class VerboseReporter extends DefaultReporter {
|
|
|
2335
2768
|
this.rendererOptions.renderSucceed = true;
|
|
2336
2769
|
}
|
|
2337
2770
|
onTaskUpdate(packs) {
|
|
2338
|
-
var _a, _b, _c
|
|
2771
|
+
var _a, _b, _c;
|
|
2339
2772
|
if (this.isTTY)
|
|
2340
2773
|
return;
|
|
2341
2774
|
for (const pack of packs) {
|
|
2342
2775
|
const task = this.ctx.state.idMap.get(pack[0]);
|
|
2343
2776
|
if (task && task.type === "test" && ((_a = task.result) == null ? void 0 : _a.state) && ((_b = task.result) == null ? void 0 : _b.state) !== "run") {
|
|
2344
2777
|
let title = ` ${getStateSymbol(task)} `;
|
|
2345
|
-
if (
|
|
2346
|
-
title += formatProjectName(task.
|
|
2778
|
+
if (task.file.projectName)
|
|
2779
|
+
title += formatProjectName(task.file.projectName);
|
|
2347
2780
|
title += getFullName(task, c.dim(" > "));
|
|
2348
2781
|
if (task.result.duration != null && task.result.duration > this.ctx.config.slowTestThreshold)
|
|
2349
2782
|
title += c.yellow(` ${Math.round(task.result.duration)}${c.dim("ms")}`);
|
|
@@ -2351,7 +2784,7 @@ class VerboseReporter extends DefaultReporter {
|
|
|
2351
2784
|
title += c.magenta(` ${Math.floor(task.result.heap / 1024 / 1024)} MB heap used`);
|
|
2352
2785
|
this.ctx.logger.log(title);
|
|
2353
2786
|
if (task.result.state === "fail") {
|
|
2354
|
-
(
|
|
2787
|
+
(_c = task.result.errors) == null ? void 0 : _c.forEach((error) => {
|
|
2355
2788
|
this.ctx.logger.log(c.red(` ${F_RIGHT} ${error == null ? void 0 : error.message}`));
|
|
2356
2789
|
});
|
|
2357
2790
|
}
|
|
@@ -2450,7 +2883,7 @@ class TapReporter {
|
|
|
2450
2883
|
}
|
|
2451
2884
|
}
|
|
2452
2885
|
}
|
|
2453
|
-
|
|
2886
|
+
onFinished(files = this.ctx.state.getFiles()) {
|
|
2454
2887
|
this.logger.log("TAP version 13");
|
|
2455
2888
|
this.logTasks(files);
|
|
2456
2889
|
}
|
|
@@ -3655,8 +4088,6 @@ createLogUpdate(process$2.stdout);
|
|
|
3655
4088
|
|
|
3656
4089
|
createLogUpdate(process$2.stderr);
|
|
3657
4090
|
|
|
3658
|
-
var version = "1.6.0";
|
|
3659
|
-
|
|
3660
4091
|
const HIGHLIGHT_SUPPORTED_EXTS = new Set(["js", "ts"].flatMap((lang) => [
|
|
3661
4092
|
`.${lang}`,
|
|
3662
4093
|
`.m${lang}`,
|
|
@@ -3670,7 +4101,7 @@ function highlightCode(id, source, colors) {
|
|
|
3670
4101
|
if (!HIGHLIGHT_SUPPORTED_EXTS.has(ext))
|
|
3671
4102
|
return source;
|
|
3672
4103
|
const isJsx = ext.endsWith("x");
|
|
3673
|
-
return highlight(source, { jsx: isJsx, colors:
|
|
4104
|
+
return highlight(source, { jsx: isJsx, colors: c });
|
|
3674
4105
|
}
|
|
3675
4106
|
|
|
3676
4107
|
class BaseSequencer {
|
|
@@ -3778,10 +4209,10 @@ class Logger {
|
|
|
3778
4209
|
this._clearScreenPending = void 0;
|
|
3779
4210
|
this.console.log(`${CURSOR_TO_START}${ERASE_DOWN}${log}`);
|
|
3780
4211
|
}
|
|
3781
|
-
|
|
4212
|
+
printError(err, options = {}) {
|
|
3782
4213
|
const { fullStack = false, type } = options;
|
|
3783
4214
|
const project = options.project ?? this.ctx.getCoreWorkspaceProject() ?? this.ctx.projects[0];
|
|
3784
|
-
|
|
4215
|
+
printError(err, project, {
|
|
3785
4216
|
fullStack,
|
|
3786
4217
|
type,
|
|
3787
4218
|
showCodeFrame: true,
|
|
@@ -3825,8 +4256,6 @@ class Logger {
|
|
|
3825
4256
|
this.console.error(c.dim("typecheck exclude: ") + c.yellow(config2.typecheck.exclude.join(comma)));
|
|
3826
4257
|
}
|
|
3827
4258
|
});
|
|
3828
|
-
if (config.watchExclude)
|
|
3829
|
-
this.console.error(c.dim("watch exclude: ") + c.yellow(config.watchExclude.join(comma)));
|
|
3830
4259
|
if (config.watch && (config.changed || ((_a = config.related) == null ? void 0 : _a.length))) {
|
|
3831
4260
|
this.log(`No affected ${config.mode} files found
|
|
3832
4261
|
`);
|
|
@@ -3842,7 +4271,7 @@ No ${config.mode} files found, exiting with code 1`));
|
|
|
3842
4271
|
printBanner() {
|
|
3843
4272
|
var _a, _b;
|
|
3844
4273
|
this.log();
|
|
3845
|
-
const versionTest = this.ctx.config.watch ? c.blue(`v${version}`) : c.cyan(`v${version}`);
|
|
4274
|
+
const versionTest = this.ctx.config.watch ? c.blue(`v${this.ctx.version}`) : c.cyan(`v${this.ctx.version}`);
|
|
3846
4275
|
const mode = this.ctx.config.watch ? c.blue(" DEV ") : c.cyan(" RUN ");
|
|
3847
4276
|
this.log(`${c.inverse(c.bold(mode))} ${versionTest} ${c.gray(this.ctx.config.root)}`);
|
|
3848
4277
|
if (this.ctx.config.sequence.sequencer === RandomSequencer)
|
|
@@ -3872,7 +4301,7 @@ Vitest is running in standalone mode. Edit a test file to rerun tests.`));
|
|
|
3872
4301
|
else
|
|
3873
4302
|
this.log();
|
|
3874
4303
|
}
|
|
3875
|
-
|
|
4304
|
+
printUnhandledErrors(errors) {
|
|
3876
4305
|
const errorMessage = c.red(c.bold(
|
|
3877
4306
|
`
|
|
3878
4307
|
Vitest caught ${errors.length} unhandled error${errors.length > 1 ? "s" : ""} during the test run.
|
|
@@ -3880,26 +4309,26 @@ This might cause false positive tests. Resolve unhandled errors to make sure you
|
|
|
3880
4309
|
));
|
|
3881
4310
|
this.log(c.red(divider(c.bold(c.inverse(" Unhandled Errors ")))));
|
|
3882
4311
|
this.log(errorMessage);
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
})
|
|
4312
|
+
errors.forEach((err) => {
|
|
4313
|
+
this.printError(err, { fullStack: true, type: err.type || "Unhandled Error" });
|
|
4314
|
+
});
|
|
3886
4315
|
this.log(c.red(divider()));
|
|
3887
4316
|
}
|
|
3888
|
-
|
|
4317
|
+
printSourceTypeErrors(errors) {
|
|
3889
4318
|
const errorMessage = c.red(c.bold(
|
|
3890
4319
|
`
|
|
3891
4320
|
Vitest found ${errors.length} error${errors.length > 1 ? "s" : ""} not related to your test files.`
|
|
3892
4321
|
));
|
|
3893
4322
|
this.log(c.red(divider(c.bold(c.inverse(" Source Errors ")))));
|
|
3894
4323
|
this.log(errorMessage);
|
|
3895
|
-
|
|
3896
|
-
|
|
3897
|
-
})
|
|
4324
|
+
errors.forEach((err) => {
|
|
4325
|
+
this.printError(err, { fullStack: true });
|
|
4326
|
+
});
|
|
3898
4327
|
this.log(c.red(divider()));
|
|
3899
4328
|
}
|
|
3900
4329
|
}
|
|
3901
4330
|
|
|
3902
|
-
|
|
4331
|
+
function capturePrintError(error, ctx, project) {
|
|
3903
4332
|
let output = "";
|
|
3904
4333
|
const writable = new Writable({
|
|
3905
4334
|
write(chunk, _encoding, callback) {
|
|
@@ -3907,13 +4336,13 @@ async function captuerPrintError(error, ctx, project) {
|
|
|
3907
4336
|
callback();
|
|
3908
4337
|
}
|
|
3909
4338
|
});
|
|
3910
|
-
const result =
|
|
4339
|
+
const result = printError(error, project, {
|
|
3911
4340
|
showCodeFrame: false,
|
|
3912
4341
|
logger: new Logger(ctx, writable, writable)
|
|
3913
4342
|
});
|
|
3914
4343
|
return { nearest: result == null ? void 0 : result.nearest, output };
|
|
3915
4344
|
}
|
|
3916
|
-
|
|
4345
|
+
function printError(error, project, options) {
|
|
3917
4346
|
const { showCodeFrame = true, fullStack = false, type } = options;
|
|
3918
4347
|
const logger = options.logger;
|
|
3919
4348
|
let e = error;
|
|
@@ -3985,7 +4414,7 @@ async function printError(error, project, options) {
|
|
|
3985
4414
|
}
|
|
3986
4415
|
if (typeof e.cause === "object" && e.cause && "name" in e.cause) {
|
|
3987
4416
|
e.cause.name = `Caused by: ${e.cause.name}`;
|
|
3988
|
-
|
|
4417
|
+
printError(e.cause, project, { fullStack, showCodeFrame: false, logger: options.logger });
|
|
3989
4418
|
}
|
|
3990
4419
|
handleImportOutsideModuleError(e.stack || e.stackStr || "", logger);
|
|
3991
4420
|
return { nearest };
|
|
@@ -4002,6 +4431,8 @@ const skipErrorProperties = /* @__PURE__ */ new Set([
|
|
|
4002
4431
|
"stackStr",
|
|
4003
4432
|
"type",
|
|
4004
4433
|
"showDiff",
|
|
4434
|
+
"ok",
|
|
4435
|
+
"operator",
|
|
4005
4436
|
"diff",
|
|
4006
4437
|
"codeFrame",
|
|
4007
4438
|
"actual",
|
|
@@ -4154,12 +4585,14 @@ function flattenTasks$1(task, baseName = "") {
|
|
|
4154
4585
|
}
|
|
4155
4586
|
}
|
|
4156
4587
|
function removeInvalidXMLCharacters(value, removeDiscouragedChars) {
|
|
4157
|
-
let regex = /(
|
|
4588
|
+
let regex = /([\0-\x08\v\f\x0E-\x1F\uFFFD\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/g;
|
|
4158
4589
|
value = String(value || "").replace(regex, "");
|
|
4159
|
-
|
|
4590
|
+
{
|
|
4160
4591
|
regex = new RegExp(
|
|
4161
|
-
|
|
4592
|
+
/* eslint-disable regexp/prefer-character-class, regexp/no-obscure-range, regexp/no-useless-non-capturing-group */
|
|
4593
|
+
"([\\x7F-\\x84]|[\\x86-\\x9F]|[\\uFDD0-\\uFDEF]|\\uD83F[\\uDFFE\\uDFFF]|(?:\\uD87F[\\uDFFE\\uDFFF])|\\uD8BF[\\uDFFE\\uDFFF]|\\uD8FF[\\uDFFE\\uDFFF]|(?:\\uD93F[\\uDFFE\\uDFFF])|\\uD97F[\\uDFFE\\uDFFF]|\\uD9BF[\\uDFFE\\uDFFF]|\\uD9FF[\\uDFFE\\uDFFF]|\\uDA3F[\\uDFFE\\uDFFF]|\\uDA7F[\\uDFFE\\uDFFF]|\\uDABF[\\uDFFE\\uDFFF]|(?:\\uDAFF[\\uDFFE\\uDFFF])|\\uDB3F[\\uDFFE\\uDFFF]|\\uDB7F[\\uDFFE\\uDFFF]|(?:\\uDBBF[\\uDFFE\\uDFFF])|\\uDBFF[\\uDFFE\\uDFFF](?:[\\0-\\t\\v\\f\\x0E-\\u2027\\u202A-\\uD7FF\\uE000-\\uFFFF]|[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]|[\\uD800-\\uDBFF](?![\\uDC00-\\uDFFF])|(?:[^\\uD800-\\uDBFF]|^)[\\uDC00-\\uDFFF]))",
|
|
4162
4594
|
"g"
|
|
4595
|
+
/* eslint-enable */
|
|
4163
4596
|
);
|
|
4164
4597
|
value = value.replace(regex, "");
|
|
4165
4598
|
}
|
|
@@ -4167,9 +4600,7 @@ function removeInvalidXMLCharacters(value, removeDiscouragedChars) {
|
|
|
4167
4600
|
}
|
|
4168
4601
|
function escapeXML(value) {
|
|
4169
4602
|
return removeInvalidXMLCharacters(
|
|
4170
|
-
String(value).replace(/&/g, "&").replace(/"/g, """).replace(/'/g, "'").replace(/</g, "<").replace(/>/g, ">")
|
|
4171
|
-
true
|
|
4172
|
-
);
|
|
4603
|
+
String(value).replace(/&/g, "&").replace(/"/g, """).replace(/'/g, "'").replace(/</g, "<").replace(/>/g, ">"));
|
|
4173
4604
|
}
|
|
4174
4605
|
function executionTime(durationMS) {
|
|
4175
4606
|
return (durationMS / 1e3).toLocaleString("en-US", { useGrouping: false, maximumFractionDigits: 10 });
|
|
@@ -4243,8 +4674,7 @@ class JUnitReporter {
|
|
|
4243
4674
|
async writeTasks(tasks, filename) {
|
|
4244
4675
|
for (const task of tasks) {
|
|
4245
4676
|
await this.writeElement("testcase", {
|
|
4246
|
-
|
|
4247
|
-
classname: this.options.classname ?? process.env.VITEST_JUNIT_CLASSNAME ?? filename,
|
|
4677
|
+
classname: this.options.classname ?? filename,
|
|
4248
4678
|
file: this.options.addFileAttribute ? filename : void 0,
|
|
4249
4679
|
name: task.name,
|
|
4250
4680
|
time: getDuration(task)
|
|
@@ -4265,7 +4695,7 @@ class JUnitReporter {
|
|
|
4265
4695
|
}, async () => {
|
|
4266
4696
|
if (!error)
|
|
4267
4697
|
return;
|
|
4268
|
-
const result =
|
|
4698
|
+
const result = capturePrintError(
|
|
4269
4699
|
error,
|
|
4270
4700
|
this.ctx,
|
|
4271
4701
|
this.ctx.getProjectByTaskId(task.id)
|
|
@@ -4313,7 +4743,8 @@ class JUnitReporter {
|
|
|
4313
4743
|
meta: {},
|
|
4314
4744
|
// NOTE: not used in JUnitReporter
|
|
4315
4745
|
context: null,
|
|
4316
|
-
suite: null
|
|
4746
|
+
suite: null,
|
|
4747
|
+
file: null
|
|
4317
4748
|
});
|
|
4318
4749
|
}
|
|
4319
4750
|
return {
|
|
@@ -4327,8 +4758,7 @@ class JUnitReporter {
|
|
|
4327
4758
|
stats2.failures += file.stats.failures;
|
|
4328
4759
|
return stats2;
|
|
4329
4760
|
}, {
|
|
4330
|
-
|
|
4331
|
-
name: this.options.suiteName || process.env.VITEST_JUNIT_SUITE_NAME || "vitest tests",
|
|
4761
|
+
name: this.options.suiteName || "vitest tests",
|
|
4332
4762
|
tests: 0,
|
|
4333
4763
|
failures: 0,
|
|
4334
4764
|
errors: 0,
|
|
@@ -4375,7 +4805,7 @@ class TapFlatReporter extends TapReporter {
|
|
|
4375
4805
|
onInit(ctx) {
|
|
4376
4806
|
super.onInit(ctx);
|
|
4377
4807
|
}
|
|
4378
|
-
|
|
4808
|
+
onFinished(files = this.ctx.state.getFiles()) {
|
|
4379
4809
|
this.ctx.logger.log("TAP version 13");
|
|
4380
4810
|
const flatTasks = files.flatMap((task) => flattenTasks(task));
|
|
4381
4811
|
this.logTasks(flatTasks);
|
|
@@ -4399,7 +4829,7 @@ class GithubActionsReporter {
|
|
|
4399
4829
|
onInit(ctx) {
|
|
4400
4830
|
this.ctx = ctx;
|
|
4401
4831
|
}
|
|
4402
|
-
|
|
4832
|
+
onFinished(files = [], errors = []) {
|
|
4403
4833
|
var _a, _b;
|
|
4404
4834
|
const projectErrors = new Array();
|
|
4405
4835
|
for (const error of errors) {
|
|
@@ -4426,7 +4856,7 @@ class GithubActionsReporter {
|
|
|
4426
4856
|
}
|
|
4427
4857
|
}
|
|
4428
4858
|
for (const { project, title, error } of projectErrors) {
|
|
4429
|
-
const result =
|
|
4859
|
+
const result = capturePrintError(error, this.ctx, project);
|
|
4430
4860
|
const stack = result == null ? void 0 : result.nearest;
|
|
4431
4861
|
if (!stack)
|
|
4432
4862
|
continue;
|
|
@@ -4465,6 +4895,94 @@ function escapeProperty(s) {
|
|
|
4465
4895
|
return s.replace(/%/g, "%25").replace(/\r/g, "%0D").replace(/\n/g, "%0A").replace(/:/g, "%3A").replace(/,/g, "%2C");
|
|
4466
4896
|
}
|
|
4467
4897
|
|
|
4898
|
+
class BlobReporter {
|
|
4899
|
+
ctx;
|
|
4900
|
+
options;
|
|
4901
|
+
constructor(options) {
|
|
4902
|
+
this.options = options;
|
|
4903
|
+
}
|
|
4904
|
+
onInit(ctx) {
|
|
4905
|
+
if (ctx.config.watch)
|
|
4906
|
+
throw new Error("Blob reporter is not supported in watch mode");
|
|
4907
|
+
this.ctx = ctx;
|
|
4908
|
+
}
|
|
4909
|
+
async onFinished(files = [], errors = [], coverage) {
|
|
4910
|
+
let outputFile = this.options.outputFile ?? getOutputFile(this.ctx.config, "blob");
|
|
4911
|
+
if (!outputFile) {
|
|
4912
|
+
const shard = this.ctx.config.shard;
|
|
4913
|
+
outputFile = shard ? `.vitest-reports/blob-${shard.index}-${shard.count}.json` : ".vitest-reports/blob.json";
|
|
4914
|
+
}
|
|
4915
|
+
const moduleKeys = this.ctx.projects.map((project) => {
|
|
4916
|
+
return [project.getName(), [...project.server.moduleGraph.idToModuleMap.keys()]];
|
|
4917
|
+
});
|
|
4918
|
+
const report = stringify([this.ctx.version, files, errors, moduleKeys, coverage]);
|
|
4919
|
+
const reportFile = resolve(this.ctx.config.root, outputFile);
|
|
4920
|
+
const dir = dirname(reportFile);
|
|
4921
|
+
if (!existsSync(dir))
|
|
4922
|
+
await mkdir(dir, { recursive: true });
|
|
4923
|
+
await writeFile(
|
|
4924
|
+
reportFile,
|
|
4925
|
+
report,
|
|
4926
|
+
"utf-8"
|
|
4927
|
+
);
|
|
4928
|
+
this.ctx.logger.log("blob report written to", reportFile);
|
|
4929
|
+
}
|
|
4930
|
+
}
|
|
4931
|
+
async function readBlobs(blobsDirectory, projectsArray) {
|
|
4932
|
+
const resolvedDir = resolve(process.cwd(), blobsDirectory);
|
|
4933
|
+
const blobsFiles = await readdir(resolvedDir);
|
|
4934
|
+
const promises = blobsFiles.map(async (file) => {
|
|
4935
|
+
const content = await readFile(resolve(resolvedDir, file), "utf-8");
|
|
4936
|
+
const [version, files2, errors2, moduleKeys, coverage] = parse(content);
|
|
4937
|
+
return { version, files: files2, errors: errors2, moduleKeys, coverage };
|
|
4938
|
+
});
|
|
4939
|
+
const blobs = await Promise.all(promises);
|
|
4940
|
+
if (!blobs.length)
|
|
4941
|
+
throw new Error(`vitest.mergeReports() requires at least one blob file paths in the config`);
|
|
4942
|
+
const projects = Object.fromEntries(projectsArray.map((p) => [p.getName(), p]));
|
|
4943
|
+
blobs.forEach((blob) => {
|
|
4944
|
+
blob.moduleKeys.forEach(([projectName, moduleIds]) => {
|
|
4945
|
+
const project = projects[projectName];
|
|
4946
|
+
if (!project)
|
|
4947
|
+
return;
|
|
4948
|
+
moduleIds.forEach((moduleId) => {
|
|
4949
|
+
project.server.moduleGraph.idToModuleMap.set(moduleId, {
|
|
4950
|
+
id: moduleId,
|
|
4951
|
+
url: moduleId,
|
|
4952
|
+
file: cleanUrl(moduleId),
|
|
4953
|
+
ssrTransformResult: null,
|
|
4954
|
+
transformResult: null,
|
|
4955
|
+
importedBindings: null,
|
|
4956
|
+
importedModules: /* @__PURE__ */ new Set(),
|
|
4957
|
+
importers: /* @__PURE__ */ new Set(),
|
|
4958
|
+
type: "js",
|
|
4959
|
+
clientImportedModules: /* @__PURE__ */ new Set(),
|
|
4960
|
+
ssrError: null,
|
|
4961
|
+
ssrImportedModules: /* @__PURE__ */ new Set(),
|
|
4962
|
+
ssrModule: null,
|
|
4963
|
+
acceptedHmrDeps: /* @__PURE__ */ new Set(),
|
|
4964
|
+
acceptedHmrExports: null,
|
|
4965
|
+
lastHMRTimestamp: 0,
|
|
4966
|
+
lastInvalidationTimestamp: 0
|
|
4967
|
+
});
|
|
4968
|
+
});
|
|
4969
|
+
});
|
|
4970
|
+
});
|
|
4971
|
+
const files = blobs.flatMap((blob) => blob.files).sort((f1, f2) => {
|
|
4972
|
+
var _a, _b;
|
|
4973
|
+
const time1 = ((_a = f1.result) == null ? void 0 : _a.startTime) || 0;
|
|
4974
|
+
const time2 = ((_b = f2.result) == null ? void 0 : _b.startTime) || 0;
|
|
4975
|
+
return time1 - time2;
|
|
4976
|
+
});
|
|
4977
|
+
const errors = blobs.flatMap((blob) => blob.errors);
|
|
4978
|
+
const coverages = blobs.map((blob) => blob.coverage);
|
|
4979
|
+
return {
|
|
4980
|
+
files,
|
|
4981
|
+
errors,
|
|
4982
|
+
coverages
|
|
4983
|
+
};
|
|
4984
|
+
}
|
|
4985
|
+
|
|
4468
4986
|
const outputMap = /* @__PURE__ */ new WeakMap();
|
|
4469
4987
|
function formatFilepath(path) {
|
|
4470
4988
|
const lastSlash = Math.max(path.lastIndexOf("/") + 1, 0);
|
|
@@ -4477,7 +4995,7 @@ function formatFilepath(path) {
|
|
|
4477
4995
|
}
|
|
4478
4996
|
function formatNumber(number) {
|
|
4479
4997
|
const res = String(number.toFixed(number < 100 ? 4 : 2)).split(".");
|
|
4480
|
-
return res[0].replace(/(?=(?:\d{3})+$)
|
|
4998
|
+
return res[0].replace(/(?=(?:\d{3})+$)\B/g, ",") + (res[1] ? `.${res[1]}` : "");
|
|
4481
4999
|
}
|
|
4482
5000
|
const tableHead = ["name", "hz", "min", "max", "mean", "p75", "p99", "p995", "p999", "rme", "samples"];
|
|
4483
5001
|
function renderBenchmarkItems(result) {
|
|
@@ -4651,7 +5169,7 @@ function createTableRenderer(_tasks, options) {
|
|
|
4651
5169
|
update();
|
|
4652
5170
|
return this;
|
|
4653
5171
|
},
|
|
4654
|
-
|
|
5172
|
+
stop() {
|
|
4655
5173
|
if (timer) {
|
|
4656
5174
|
clearInterval(timer);
|
|
4657
5175
|
timer = void 0;
|
|
@@ -4669,14 +5187,14 @@ function createTableRenderer(_tasks, options) {
|
|
|
4669
5187
|
class TableReporter extends BaseReporter {
|
|
4670
5188
|
renderer;
|
|
4671
5189
|
rendererOptions = {};
|
|
4672
|
-
|
|
4673
|
-
|
|
5190
|
+
onTestRemoved(trigger) {
|
|
5191
|
+
this.stopListRender();
|
|
4674
5192
|
this.ctx.logger.clearScreen(c.yellow("Test removed...") + (trigger ? c.dim(` [ ${this.relative(trigger)} ]
|
|
4675
5193
|
`) : ""), true);
|
|
4676
5194
|
const files = this.ctx.state.getFiles(this.watchFilters);
|
|
4677
5195
|
createTableRenderer(files, this.rendererOptions).stop();
|
|
4678
5196
|
this.ctx.logger.log();
|
|
4679
|
-
|
|
5197
|
+
super.reportSummary(files, this.ctx.state.getUnhandledErrors());
|
|
4680
5198
|
super.onWatcherStart();
|
|
4681
5199
|
}
|
|
4682
5200
|
async onCollected() {
|
|
@@ -4727,9 +5245,9 @@ class TableReporter extends BaseReporter {
|
|
|
4727
5245
|
}
|
|
4728
5246
|
async onFinished(files = this.ctx.state.getFiles(), errors = this.ctx.state.getUnhandledErrors()) {
|
|
4729
5247
|
var _a;
|
|
4730
|
-
|
|
5248
|
+
this.stopListRender();
|
|
4731
5249
|
this.ctx.logger.log();
|
|
4732
|
-
|
|
5250
|
+
super.onFinished(files, errors);
|
|
4733
5251
|
let outputFile = (_a = this.ctx.config.benchmark) == null ? void 0 : _a.outputJson;
|
|
4734
5252
|
if (outputFile) {
|
|
4735
5253
|
outputFile = pathe.resolve(this.ctx.config.root, outputFile);
|
|
@@ -4742,16 +5260,16 @@ class TableReporter extends BaseReporter {
|
|
|
4742
5260
|
}
|
|
4743
5261
|
}
|
|
4744
5262
|
async onWatcherStart() {
|
|
4745
|
-
|
|
5263
|
+
this.stopListRender();
|
|
4746
5264
|
await super.onWatcherStart();
|
|
4747
5265
|
}
|
|
4748
|
-
|
|
5266
|
+
stopListRender() {
|
|
4749
5267
|
var _a;
|
|
4750
|
-
|
|
5268
|
+
(_a = this.renderer) == null ? void 0 : _a.stop();
|
|
4751
5269
|
this.renderer = void 0;
|
|
4752
5270
|
}
|
|
4753
5271
|
async onWatcherRerun(files, trigger) {
|
|
4754
|
-
|
|
5272
|
+
this.stopListRender();
|
|
4755
5273
|
await super.onWatcherRerun(files, trigger);
|
|
4756
5274
|
}
|
|
4757
5275
|
onUserConsoleLog(log) {
|
|
@@ -4777,6 +5295,7 @@ function createFormattedBenchamrkReport(files) {
|
|
|
4777
5295
|
benchmarks.push({
|
|
4778
5296
|
id: t.id,
|
|
4779
5297
|
sampleCount: samples.length,
|
|
5298
|
+
median: samples.length % 2 ? samples[Math.floor(samples.length / 2)] : (samples[samples.length / 2] + samples[samples.length / 2 - 1]) / 2,
|
|
4780
5299
|
...rest
|
|
4781
5300
|
});
|
|
4782
5301
|
}
|
|
@@ -4815,6 +5334,7 @@ const BenchmarkReportsMap = {
|
|
|
4815
5334
|
const ReportersMap = {
|
|
4816
5335
|
"default": DefaultReporter,
|
|
4817
5336
|
"basic": BasicReporter,
|
|
5337
|
+
"blob": BlobReporter,
|
|
4818
5338
|
"verbose": VerboseReporter,
|
|
4819
5339
|
"dot": DotReporter,
|
|
4820
5340
|
"json": JsonReporter,
|
|
@@ -4825,4 +5345,4 @@ const ReportersMap = {
|
|
|
4825
5345
|
"github-actions": GithubActionsReporter
|
|
4826
5346
|
};
|
|
4827
5347
|
|
|
4828
|
-
export { BaseSequencer as B, DefaultReporter as D, GithubActionsReporter as G, HangingProcessReporter as H, JsonReporter as J, Logger as L, ReportersMap as R, TapReporter as T, VerboseReporter as V, BasicReporter as a, DotReporter as b, JUnitReporter as c, TapFlatReporter as d, BenchmarkReportsMap as e, Typechecker as f, RandomSequencer as g,
|
|
5348
|
+
export { BaseSequencer as B, DefaultReporter as D, GithubActionsReporter as G, HangingProcessReporter as H, JsonReporter as J, Logger as L, ReportersMap as R, TapReporter as T, VerboseReporter as V, BasicReporter as a, DotReporter as b, JUnitReporter as c, TapFlatReporter as d, BenchmarkReportsMap as e, Typechecker as f, RandomSequencer as g, findNodeAround as h, generateCodeFrame as i, highlightCode as j, BlobReporter as k, parse as p, readBlobs as r, stringify as s, wrapSerializableConfig as w };
|