vitest 2.0.0-beta.1 → 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 +1 -1
- package/dist/browser.d.ts +22 -2
- package/dist/browser.js +3 -1
- package/dist/chunks/{integrations-globals.B5Jl0grA.js → integrations-globals.C6Ah-pUW.js} +3 -3
- package/dist/chunks/{runtime-console.CUES-L8X.js → runtime-console.DiVMr5d4.js} +54 -24
- package/dist/chunks/{runtime-runBaseTests._dXkRAZc.js → runtime-runBaseTests.Cukyr5-I.js} +5 -5
- package/dist/cli.js +2 -2
- package/dist/config.cjs +3 -3
- package/dist/config.d.ts +2 -2
- package/dist/config.js +3 -3
- package/dist/coverage.d.ts +1 -1
- package/dist/coverage.js +33 -7
- package/dist/environments.d.ts +1 -1
- package/dist/environments.js +1 -1
- package/dist/execute.d.ts +2 -2
- package/dist/execute.js +1 -1
- package/dist/index.d.ts +11 -47
- package/dist/index.js +3 -3
- package/dist/node.d.ts +7 -7
- package/dist/node.js +12 -10
- package/dist/{reporters-MGvT5U9f.d.ts → reporters-CYVC6LOl.d.ts} +424 -201
- package/dist/reporters.d.ts +1 -1
- package/dist/reporters.js +4 -4
- package/dist/runners.d.ts +4 -2
- package/dist/runners.js +9 -1
- package/dist/{suite-8WAe-urM.d.ts → suite-Dpu9EC_k.d.ts} +1 -1
- package/dist/suite.d.ts +2 -2
- package/dist/vendor/{base.VFkIJ66g.js → base.Dln9yllP.js} +2 -2
- package/dist/vendor/{cac.DzKZaJu2.js → cac.CtYFkoSJ.js} +65 -23
- package/dist/vendor/{cli-api.DTeni0Qq.js → cli-api.CUtJc4r3.js} +2425 -549
- package/dist/vendor/{constants.5SOfHUj0.js → constants.TCjCaw2D.js} +4 -3
- package/dist/vendor/{execute.CLLNVNnK.js → execute.BHj6OMh4.js} +3 -3
- package/dist/vendor/{index.BfoZyXD1.js → index.B5SKBLvV.js} +1 -1
- package/dist/vendor/{index.CRxYS9H3.js → index.BOMEjpjj.js} +271 -52
- package/dist/vendor/{index.DP-km6lF.js → index.CThipSqB.js} +2537 -2524
- package/dist/vendor/{index.CmILuxzC.js → index.D3hs2WiI.js} +1 -1
- package/dist/vendor/{index.DeR1hhfY.js → index.kpsSqFiz.js} +2 -1
- package/dist/vendor/{setup-common.XeoZAW8t.js → setup-common.DAu7t7mY.js} +1 -1
- package/dist/vendor/spy.Cf_4R5Oe.js +22 -0
- package/dist/vendor/{utils.D5gGkwyH.js → utils.YuQ3LT2a.js} +1 -1
- package/dist/vendor/{vi.ClD3hi7L.js → vi.hATFzZbX.js} +101 -46
- package/dist/vendor/{vm.Bi3bljci.js → vm.Ow-X2mkS.js} +2 -2
- package/dist/worker.js +1 -1
- package/dist/workers/forks.js +2 -2
- package/dist/workers/runVmTests.js +4 -4
- package/dist/workers/threads.js +2 -2
- package/dist/workers/vmForks.js +3 -3
- package/dist/workers/vmThreads.js +3 -3
- package/dist/workers.d.ts +1 -1
- package/dist/workers.js +5 -5
- package/package.json +20 -20
- package/suppress-warnings.cjs +2 -1
|
@@ -3,9 +3,10 @@ const defaultBrowserPort = 63315;
|
|
|
3
3
|
const defaultInspectPort = 9229;
|
|
4
4
|
const EXIT_CODE_RESTART = 43;
|
|
5
5
|
const API_PATH = "/__vitest_api__";
|
|
6
|
+
const BROWSER_API_PATH = "/__vitest_browser_api__";
|
|
6
7
|
const extraInlineDeps = [
|
|
7
|
-
/^(?!.*
|
|
8
|
-
/^(?!.*
|
|
8
|
+
/^(?!.*node_modules).*\.mjs$/,
|
|
9
|
+
/^(?!.*node_modules).*\.cjs\.js$/,
|
|
9
10
|
// Vite client
|
|
10
11
|
/vite\w*\/dist\/client\/env.mjs/,
|
|
11
12
|
// Nuxt
|
|
@@ -62,4 +63,4 @@ const globalApis = [
|
|
|
62
63
|
"onTestFailed"
|
|
63
64
|
];
|
|
64
65
|
|
|
65
|
-
export { API_PATH as A, CONFIG_NAMES as C, EXIT_CODE_RESTART as E, defaultBrowserPort as a, defaultInspectPort as b, configFiles as c, defaultPort as d, extraInlineDeps as e, globalApis as g, workspacesFiles as w };
|
|
66
|
+
export { API_PATH as A, BROWSER_API_PATH as B, CONFIG_NAMES as C, EXIT_CODE_RESTART as E, defaultBrowserPort as a, defaultInspectPort as b, configFiles as c, defaultPort as d, extraInlineDeps as e, globalApis as g, workspacesFiles as w };
|
|
@@ -68,7 +68,7 @@ class VitestMocker {
|
|
|
68
68
|
if (this.moduleCache.has(mockId))
|
|
69
69
|
this.moduleCache.delete(mockId);
|
|
70
70
|
}
|
|
71
|
-
|
|
71
|
+
isModuleDirectory(path) {
|
|
72
72
|
return this.moduleDirectories.some((dir) => path.includes(dir));
|
|
73
73
|
}
|
|
74
74
|
getSuiteFilepath() {
|
|
@@ -103,7 +103,7 @@ class VitestMocker {
|
|
|
103
103
|
throw error;
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
|
-
const external = !isAbsolute(fsPath) || this.
|
|
106
|
+
const external = !isAbsolute(fsPath) || this.isModuleDirectory(fsPath) ? rawId : null;
|
|
107
107
|
return {
|
|
108
108
|
id,
|
|
109
109
|
fsPath,
|
|
@@ -368,7 +368,7 @@ async function createVitestExecutor(options) {
|
|
|
368
368
|
return runner;
|
|
369
369
|
}
|
|
370
370
|
const externalizeMap = /* @__PURE__ */ new Map();
|
|
371
|
-
const bareVitestRegexp = /^@?vitest(
|
|
371
|
+
const bareVitestRegexp = /^@?vitest(?:\/|$)/;
|
|
372
372
|
const dispose = [];
|
|
373
373
|
function listenForErrors(state) {
|
|
374
374
|
dispose.forEach((fn) => fn());
|
|
@@ -4,7 +4,7 @@ import { distDir } from '../path.js';
|
|
|
4
4
|
import { g as getWorkerState } from './global.7bFbnyXl.js';
|
|
5
5
|
import { r as rpc } from './rpc.DRDE9Pu1.js';
|
|
6
6
|
import { t as takeCoverageInsideWorker } from './coverage.ChSqD-qS.js';
|
|
7
|
-
import { l as loadDiffConfig, a as loadSnapshotSerializers } from './setup-common.
|
|
7
|
+
import { l as loadDiffConfig, a as loadSnapshotSerializers } from './setup-common.DAu7t7mY.js';
|
|
8
8
|
|
|
9
9
|
function setupChaiConfig(config) {
|
|
10
10
|
Object.assign(chai.config, config);
|
|
@@ -5,17 +5,17 @@ import { basename, dirname, resolve, join, relative, extname, normalize } from '
|
|
|
5
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
7
|
import { i as isNode } from './env.bmJgw1qP.js';
|
|
8
|
-
import { g as getStateSymbol, f as formatProjectName, p as pointer, F as F_RIGHT, r as renderSnapshotSummary,
|
|
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 { TraceMap, generatedPositionFor, parseStacktrace, parseErrorStacktrace } from '@vitest/utils/source-map';
|
|
11
12
|
import { r as relativePath } from './index._7XLd8Kd.js';
|
|
12
|
-
import { UNKNOWN_TEST_ID } from '../chunks/runtime-console.
|
|
13
|
+
import { UNKNOWN_TEST_ID } from '../chunks/runtime-console.DiVMr5d4.js';
|
|
13
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';
|
|
@@ -28,9 +28,116 @@ import { g as getDefaultExportFromCjs, c as commonjsGlobal } from './_commonjsHe
|
|
|
28
28
|
import require$$0$2 from 'assert';
|
|
29
29
|
import require$$0$1 from 'events';
|
|
30
30
|
import { createHash } from 'node:crypto';
|
|
31
|
-
import { slash } from 'vite-node/utils';
|
|
31
|
+
import { slash, cleanUrl } from 'vite-node/utils';
|
|
32
32
|
import { createRequire } from 'node:module';
|
|
33
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
|
+
|
|
34
141
|
const REGEXP_WRAP_PREFIX = "$$vitest:";
|
|
35
142
|
function getOutputFile(config, reporter) {
|
|
36
143
|
if (!(config == null ? void 0 : config.outputFile))
|
|
@@ -61,7 +168,7 @@ function B(e){return e.startsWith("\\\\?\\")?e:e.replace(/\\/g,"/")}const W=e=>{
|
|
|
61
168
|
`+" ".repeat(t)),new Array(F).fill(0).map((e,t)=>"\r"+" ".repeat(t)),new Array(F).fill(0).map((e,t)=>`\r
|
|
62
169
|
`+" ".repeat(t)),new Array(F).fill(0).map((e,t)=>`
|
|
63
170
|
`+" ".repeat(t)),new Array(F).fill(0).map((e,t)=>"\r"+" ".repeat(t)),new Array(F).fill(0).map((e,t)=>`\r
|
|
64
|
-
`+" ".repeat(t));var P;(function(e){e.DEFAULT={allowTrailingComma:!1};})(P||(P={}));function we(e,t=[],i=P.DEFAULT){let n=null,l=[];const s=[];function o(u){Array.isArray(l)?l.push(u):n!==null&&(l[n]=u);}return Te(e,{onObjectBegin:()=>{const u={};o(u),s.push(l),l=u,n=null;},onObjectProperty:u=>{n=u;},onObjectEnd:()=>{l=s.pop();},onArrayBegin:()=>{const u=[];o(u),s.push(l),l=u,n=null;},onArrayEnd:()=>{l=s.pop();},onLiteralValue:o,onError:(u,w,v)=>{t.push({error:u,offset:w,length:v});}},i),l[0]}function Te(e,t,i=P.DEFAULT){const n=be(e,!1),l=[];function s(a){return a?()=>a(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter()):()=>!0}function o(a){return a?()=>a(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter(),()=>l.slice()):()=>!0}function m(a){return a?O=>a(O,n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter()):()=>!0}function u(a){return a?O=>a(O,n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter(),()=>l.slice()):()=>!0}const w=o(t.onObjectBegin),v=u(t.onObjectProperty),f=s(t.onObjectEnd),E=o(t.onArrayBegin),b=s(t.onArrayEnd),T=u(t.onLiteralValue),k=m(t.onSeparator),j=s(t.onComment),L=m(t.onError),U=i&&i.disallowComments,r=i&&i.allowTrailingComma;function g(){for(;;){const a=n.scan();switch(n.getTokenError()){case 4:c(14);break;case 5:c(15);break;case 3:c(13);break;case 1:U||c(11);break;case 2:c(12);break;case 6:c(16);break}switch(a){case 12:case 13:U?c(10):j();break;case 16:c(1);break;case 15:case 14:break;default:return a}}}function c(a,O=[],Z=[]){if(L(a),O.length+Z.length>0){let x=n.getToken();for(;x!==17;){if(O.indexOf(x)!==-1){g();break}else if(Z.indexOf(x)!==-1)break;x=g();}}}function $(a){const O=n.getTokenValue();return a?T(O):(v(O),l.push(O)),g(),!0}function A(){switch(n.getToken()){case 11:const a=n.getTokenValue();let O=Number(a);isNaN(O)&&(c(2),O=0),T(O);break;case 7:T(null);break;case 8:T(!0);break;case 9:T(!1);break;default:return !1}return g(),!0}function ce(){return n.getToken()!==10?(c(3,[],[2,5]),!1):($(!1),n.getToken()===6?(k(":"),g(),S()||c(4,[],[2,5])):c(5,[],[2,5]),l.pop(),!0)}function pe(){w(),g();let a=!1;for(;n.getToken()!==2&&n.getToken()!==17;){if(n.getToken()===5){if(a||c(4,[],[]),k(","),g(),n.getToken()===2&&r)break}else a&&c(6,[],[]);ce()||c(4,[],[2,5]),a=!0;}return f(),n.getToken()!==2?c(7,[2],[]):g(),!0}function me(){E(),g();let a=!0,O=!1;for(;n.getToken()!==4&&n.getToken()!==17;){if(n.getToken()===5){if(O||c(4,[],[]),k(","),g(),n.getToken()===4&&r)break}else O&&c(6,[],[]);a?(l.push(0),a=!1):l[l.length-1]++,S()||c(4,[],[4,5]),O=!0;}return b(),a||l.pop(),n.getToken()!==4?c(8,[4],[]):g(),!0}function S(){switch(n.getToken()){case 3:return me();case 1:return pe();case 10:return $(!0);default:return A()}}return g(),n.getToken()===17?i.allowEmptyContent?!0:(c(4,[],[]),!1):S()?(n.getToken()!==17&&c(9,[],[]),!0):(c(4,[],[]),!1)}var C;(function(e){e[e.None=0]="None",e[e.UnexpectedEndOfComment=1]="UnexpectedEndOfComment",e[e.UnexpectedEndOfString=2]="UnexpectedEndOfString",e[e.UnexpectedEndOfNumber=3]="UnexpectedEndOfNumber",e[e.InvalidUnicode=4]="InvalidUnicode",e[e.InvalidEscapeCharacter=5]="InvalidEscapeCharacter",e[e.InvalidCharacter=6]="InvalidCharacter";})(C||(C={}));var ee;(function(e){e[e.OpenBraceToken=1]="OpenBraceToken",e[e.CloseBraceToken=2]="CloseBraceToken",e[e.OpenBracketToken=3]="OpenBracketToken",e[e.CloseBracketToken=4]="CloseBracketToken",e[e.CommaToken=5]="CommaToken",e[e.ColonToken=6]="ColonToken",e[e.NullKeyword=7]="NullKeyword",e[e.TrueKeyword=8]="TrueKeyword",e[e.FalseKeyword=9]="FalseKeyword",e[e.StringLiteral=10]="StringLiteral",e[e.NumericLiteral=11]="NumericLiteral",e[e.LineCommentTrivia=12]="LineCommentTrivia",e[e.BlockCommentTrivia=13]="BlockCommentTrivia",e[e.LineBreakTrivia=14]="LineBreakTrivia",e[e.Trivia=15]="Trivia",e[e.Unknown=16]="Unknown",e[e.EOF=17]="EOF";})(ee||(ee={}));const ve=we;var ne;(function(e){e[e.InvalidSymbol=1]="InvalidSymbol",e[e.InvalidNumberFormat=2]="InvalidNumberFormat",e[e.PropertyNameExpected=3]="PropertyNameExpected",e[e.ValueExpected=4]="ValueExpected",e[e.ColonExpected=5]="ColonExpected",e[e.CommaExpected=6]="CommaExpected",e[e.CloseBraceExpected=7]="CloseBraceExpected",e[e.CloseBracketExpected=8]="CloseBracketExpected",e[e.EndOfFileExpected=9]="EndOfFileExpected",e[e.InvalidCommentToken=10]="InvalidCommentToken",e[e.UnexpectedEndOfComment=11]="UnexpectedEndOfComment",e[e.UnexpectedEndOfString=12]="UnexpectedEndOfString",e[e.UnexpectedEndOfNumber=13]="UnexpectedEndOfNumber",e[e.InvalidUnicode=14]="InvalidUnicode",e[e.InvalidEscapeCharacter=15]="InvalidEscapeCharacter",e[e.InvalidCharacter=16]="InvalidCharacter";})(ne||(ne={}));const te=(e,t)=>ve(ke(t,e,"utf8")),R=Symbol("implicitBaseUrl"),Ae=()=>{const{findPnpApi:e}=ge;return e&&e(process.cwd())},G=(e,t,i,n)=>{const l=`resolveFromPackageJsonPath:${e}:${t}:${i}`;if(n!=null&&n.has(l))return n.get(l);const s=te(e,n);if(!s)return;let o=t||"tsconfig.json";if(!i&&s.exports)try{const[m]=v(s.exports,t,["require","types"]);o=m;}catch{return !1}else !t&&s.tsconfig&&(o=s.tsconfig);return o=p$1.join(e,"..",o),n==null||n.set(l,o),o},z="package.json",Q="tsconfig.json",Oe=(e,t,i)=>{let n=e;if(e===".."&&(n=p$1.join(n,Q)),e[0]==="."&&(n=p$1.resolve(t,n)),p$1.isAbsolute(n)){if(_(i,n)){if(I(i,n).isFile())return n}else if(!n.endsWith(".json")){const b=`${n}.json`;if(_(i,b))return b}return}const[l,...s]=e.split("/"),o=l[0]==="@"?`${l}/${s.shift()}`:l,m=s.join("/"),u=Ae();if(u){const{resolveRequest:b}=u;try{if(o===e){const T=b(p$1.join(o,z),t);if(T){const k=G(T,m,!1,i);if(k&&_(i,k))return k}}else {let T;try{T=b(e,t,{extensions:[".json"]});}catch{T=b(p$1.join(e,Q),t);}if(T)return T}}catch{}}const w=q(t,p$1.join("node_modules",o),i);if(!w||!I(i,w).isDirectory())return;const v=p$1.join(w,z);if(_(i,v)){const b=G(v,m,!1,i);if(b===!1)return;if(b&&_(i,b)&&I(i,b).isFile())return b}const f=p$1.join(w,m),E=f.endsWith(".json");if(!E){const b=`${f}.json`;if(_(i,b))return b}if(_(i,f)){if(I(i,f).isDirectory()){const b=p$1.join(f,z);if(_(i,b)){const k=G(b,"",!0,i);if(k&&_(i,k))return k}const T=p$1.join(f,Q);if(_(i,T))return T}else if(E)return f}},je=(e,t,i,n)=>{const l=Oe(e,t,n);if(!l)throw new Error(`File '${e}' not found.`);if(i.has(l))throw new Error(`Circularity detected while resolving configuration: ${l}`);i.add(l);const s=p$1.dirname(l),o=ie(l,n,i);delete o.references;const{compilerOptions:m}=o;if(m){const u=["baseUrl","outDir"];for(const w of u){const v=m[w];v&&(m[w]=B(p$1.relative(t,p$1.join(s,v)))||"./");}}return o.files&&(o.files=o.files.map(u=>B(p$1.relative(t,p$1.join(s,u))))),o.include&&(o.include=o.include.map(u=>B(p$1.relative(t,p$1.join(s,u))))),o.exclude&&(o.exclude=o.exclude.map(u=>B(p$1.relative(t,p$1.join(s,u))))),o},ie=(e,t,i=new Set)=>{let n;try{n=te(e,t)||{};}catch{throw new Error(`Cannot resolve tsconfig at path: ${e}`)}if(typeof n!="object")throw new SyntaxError(`Failed to parse tsconfig at: ${e}`);const l=p$1.dirname(e);if(n.compilerOptions){const{compilerOptions:s}=n;s.paths&&!s.baseUrl&&(s[R]=l);}if(n.extends){const s=Array.isArray(n.extends)?n.extends:[n.extends];delete n.extends;for(const o of s.reverse()){const m=je(o,l,new Set(i),t),u={...m,...n,compilerOptions:{...m.compilerOptions,...n.compilerOptions}};m.watchOptions&&(u.watchOptions={...m.watchOptions,...n.watchOptions}),n=u;}}if(n.compilerOptions){const{compilerOptions:s}=n,o=["baseUrl","rootDir"];for(const u of o){const w=s[u];if(w){const v=p$1.resolve(l,w),f=J(p$1.relative(l,v));s[u]=f;}}const{outDir:m}=s;m&&(Array.isArray(n.exclude)||(n.exclude=[]),n.exclude.includes(m)||n.exclude.push(m),s.outDir=J(m));}else n.compilerOptions={};if(n.files&&(n.files=n.files.map(J)),n.include&&(n.include=n.include.map(B)),n.watchOptions){const{watchOptions:s}=n;s.excludeDirectories&&(s.excludeDirectories=s.excludeDirectories.map(o=>B(p$1.resolve(l,o))));}return n},le=(e,t=new Map)=>ie(e,t),$e=(e=process.cwd(),t="tsconfig.json",i=new Map)=>{const n=q(B(e),t,i);if(!n)return null;const l=le(n,i);return {path:n,config:l}};p$1.posix;process.platform==="win32";
|
|
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";
|
|
65
172
|
|
|
66
173
|
const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
|
|
67
174
|
const newLineRegExp = /\r?\n/;
|
|
@@ -69,8 +176,9 @@ const errCodeRegExp = /error TS(?<errCode>\d+)/;
|
|
|
69
176
|
async function makeTscErrorInfo(errInfo) {
|
|
70
177
|
var _a;
|
|
71
178
|
const [errFilePathPos = "", ...errMsgRawArr] = errInfo.split(":");
|
|
72
|
-
if (!errFilePathPos || errMsgRawArr.length === 0 || errMsgRawArr.join("").length === 0)
|
|
179
|
+
if (!errFilePathPos || errMsgRawArr.length === 0 || errMsgRawArr.join("").length === 0) {
|
|
73
180
|
return ["unknown filepath", null];
|
|
181
|
+
}
|
|
74
182
|
const errMsgRaw = errMsgRawArr.join("").trim();
|
|
75
183
|
const [errFilePath, errPos] = errFilePathPos.slice(0, -1).split("(");
|
|
76
184
|
if (!errFilePath || !errPos)
|
|
@@ -863,7 +971,6 @@ class Typechecker {
|
|
|
863
971
|
}
|
|
864
972
|
}
|
|
865
973
|
|
|
866
|
-
var _a;
|
|
867
974
|
const BADGE_PADDING = " ";
|
|
868
975
|
const HELP_HINT = `${c.dim("press ")}${c.bold("h")}${c.dim(" to show help")}`;
|
|
869
976
|
const HELP_UPDATE_SNAP = c.dim("press ") + c.bold(c.yellow("u")) + c.dim(" to update snapshot");
|
|
@@ -879,7 +986,7 @@ class BaseReporter {
|
|
|
879
986
|
start = 0;
|
|
880
987
|
end = 0;
|
|
881
988
|
watchFilters;
|
|
882
|
-
isTTY
|
|
989
|
+
isTTY;
|
|
883
990
|
ctx = void 0;
|
|
884
991
|
_filesInWatchMode = /* @__PURE__ */ new Map();
|
|
885
992
|
_lastRunTimeout = 0;
|
|
@@ -887,7 +994,9 @@ class BaseReporter {
|
|
|
887
994
|
_lastRunCount = 0;
|
|
888
995
|
_timeStart = /* @__PURE__ */ new Date();
|
|
889
996
|
_offUnhandledRejection;
|
|
890
|
-
constructor() {
|
|
997
|
+
constructor(options = {}) {
|
|
998
|
+
var _a;
|
|
999
|
+
this.isTTY = options.isTTY ?? (isNode && ((_a = process.stdout) == null ? void 0 : _a.isTTY) && !isCI);
|
|
891
1000
|
this.registerUnhandledRejection();
|
|
892
1001
|
}
|
|
893
1002
|
get mode() {
|
|
@@ -896,8 +1005,8 @@ class BaseReporter {
|
|
|
896
1005
|
onInit(ctx) {
|
|
897
1006
|
this.ctx = ctx;
|
|
898
1007
|
ctx.onClose(() => {
|
|
899
|
-
var
|
|
900
|
-
(
|
|
1008
|
+
var _a;
|
|
1009
|
+
(_a = this._offUnhandledRejection) == null ? void 0 : _a.call(this);
|
|
901
1010
|
});
|
|
902
1011
|
ctx.logger.printBanner();
|
|
903
1012
|
this.start = performance.now();
|
|
@@ -914,17 +1023,17 @@ class BaseReporter {
|
|
|
914
1023
|
}
|
|
915
1024
|
}
|
|
916
1025
|
onTaskUpdate(packs) {
|
|
917
|
-
var
|
|
1026
|
+
var _a, _b, _c, _d;
|
|
918
1027
|
if (this.isTTY)
|
|
919
1028
|
return;
|
|
920
1029
|
const logger = this.ctx.logger;
|
|
921
1030
|
for (const pack of packs) {
|
|
922
1031
|
const task = this.ctx.state.idMap.get(pack[0]);
|
|
923
|
-
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") {
|
|
924
1033
|
const tests = getTests(task);
|
|
925
1034
|
const failed = tests.filter((t) => {
|
|
926
|
-
var
|
|
927
|
-
return ((
|
|
1035
|
+
var _a2;
|
|
1036
|
+
return ((_a2 = t.result) == null ? void 0 : _a2.state) === "fail";
|
|
928
1037
|
});
|
|
929
1038
|
const skipped = tests.filter((t) => t.mode === "skip" || t.mode === "todo");
|
|
930
1039
|
let state = c.dim(`${tests.length} test${tests.length > 1 ? "s" : ""}`);
|
|
@@ -1035,15 +1144,32 @@ ${PROJECT_FILTER}${FILENAME_PATTERN}${TESTNAME_PATTERN}`);
|
|
|
1035
1144
|
const task = log.taskId ? this.ctx.state.idMap.get(log.taskId) : void 0;
|
|
1036
1145
|
const header = c.gray(log.type + c.dim(` | ${task ? getFullName(task, c.dim(" > ")) : log.taskId !== UNKNOWN_TEST_ID ? log.taskId : "unknown test"}`));
|
|
1037
1146
|
const output = log.type === "stdout" ? this.ctx.logger.outputStream : this.ctx.logger.errorStream;
|
|
1038
|
-
output.write(
|
|
1039
|
-
|
|
1040
|
-
`);
|
|
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");
|
|
1041
1167
|
}
|
|
1042
1168
|
shouldLog(log) {
|
|
1043
|
-
var
|
|
1169
|
+
var _a, _b;
|
|
1044
1170
|
if (this.ctx.config.silent)
|
|
1045
1171
|
return false;
|
|
1046
|
-
const shouldLog = (_b = (
|
|
1172
|
+
const shouldLog = (_b = (_a = this.ctx.config).onConsoleLog) == null ? void 0 : _b.call(_a, log.content, log.type);
|
|
1047
1173
|
if (shouldLog === false)
|
|
1048
1174
|
return shouldLog;
|
|
1049
1175
|
return true;
|
|
@@ -1067,8 +1193,8 @@ ${log.content}
|
|
|
1067
1193
|
const collectTime = files.reduce((acc, test) => acc + Math.max(0, test.collectDuration || 0), 0);
|
|
1068
1194
|
const setupTime = files.reduce((acc, test) => acc + Math.max(0, test.setupDuration || 0), 0);
|
|
1069
1195
|
const testsTime = files.reduce((acc, test) => {
|
|
1070
|
-
var
|
|
1071
|
-
return acc + Math.max(0, ((
|
|
1196
|
+
var _a;
|
|
1197
|
+
return acc + Math.max(0, ((_a = test.result) == null ? void 0 : _a.duration) || 0);
|
|
1072
1198
|
}, 0);
|
|
1073
1199
|
const transformTime = this.ctx.projects.flatMap((w) => w.vitenode.getTotalDuration()).reduce((a, b) => a + b, 0);
|
|
1074
1200
|
const environmentTime = files.reduce((acc, file) => acc + Math.max(0, file.environmentLoad || 0), 0);
|
|
@@ -1092,8 +1218,8 @@ ${log.content}
|
|
|
1092
1218
|
logger.log(padTitle("Tests"), getStateString(tests));
|
|
1093
1219
|
if (this.ctx.projects.some((c2) => c2.config.typecheck.enabled)) {
|
|
1094
1220
|
const failed = tests.filter((t) => {
|
|
1095
|
-
var
|
|
1096
|
-
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);
|
|
1097
1223
|
});
|
|
1098
1224
|
logger.log(padTitle("Type Errors"), failed.length ? c.bold(c.red(`${failed.length} failed`)) : c.dim("no errors"));
|
|
1099
1225
|
}
|
|
@@ -1105,8 +1231,8 @@ ${log.content}
|
|
|
1105
1231
|
} else {
|
|
1106
1232
|
let timers = `transform ${time(transformTime)}, setup ${time(setupTime)}, collect ${time(collectTime)}, tests ${time(testsTime)}, environment ${time(environmentTime)}, prepare ${time(prepareTime)}`;
|
|
1107
1233
|
const typecheck = this.ctx.projects.reduce((acc, c2) => {
|
|
1108
|
-
var
|
|
1109
|
-
return acc + (((
|
|
1234
|
+
var _a;
|
|
1235
|
+
return acc + (((_a = c2.typechecker) == null ? void 0 : _a.getResult().time) || 0);
|
|
1110
1236
|
}, 0);
|
|
1111
1237
|
if (typecheck)
|
|
1112
1238
|
timers += `, typecheck ${time(typecheck)}`;
|
|
@@ -1119,12 +1245,12 @@ ${log.content}
|
|
|
1119
1245
|
const suites = getSuites(files);
|
|
1120
1246
|
const tests = getTests(files);
|
|
1121
1247
|
const failedSuites = suites.filter((i) => {
|
|
1122
|
-
var
|
|
1123
|
-
return (
|
|
1248
|
+
var _a;
|
|
1249
|
+
return (_a = i.result) == null ? void 0 : _a.errors;
|
|
1124
1250
|
});
|
|
1125
1251
|
const failedTests = tests.filter((i) => {
|
|
1126
|
-
var
|
|
1127
|
-
return ((
|
|
1252
|
+
var _a;
|
|
1253
|
+
return ((_a = i.result) == null ? void 0 : _a.state) === "fail";
|
|
1128
1254
|
});
|
|
1129
1255
|
const failedTotal = countTestErrors(failedSuites) + countTestErrors(failedTests);
|
|
1130
1256
|
let current = 1;
|
|
@@ -1150,8 +1276,8 @@ ${log.content}
|
|
|
1150
1276
|
const logger = this.ctx.logger;
|
|
1151
1277
|
const benches = getTests(files);
|
|
1152
1278
|
const topBenches = benches.filter((i) => {
|
|
1153
|
-
var
|
|
1154
|
-
return ((_b = (
|
|
1279
|
+
var _a, _b;
|
|
1280
|
+
return ((_b = (_a = i.result) == null ? void 0 : _a.benchmark) == null ? void 0 : _b.rank) === 1;
|
|
1155
1281
|
});
|
|
1156
1282
|
logger.log(`
|
|
1157
1283
|
${c.cyan(c.inverse(c.bold(" BENCH ")))} ${c.cyan("Summary")}
|
|
@@ -1163,8 +1289,8 @@ ${c.cyan(c.inverse(c.bold(" BENCH ")))} ${c.cyan("Summary")}
|
|
|
1163
1289
|
const groupName = getFullName(group, c.dim(" > "));
|
|
1164
1290
|
logger.log(` ${bench.name}${c.dim(` - ${groupName}`)}`);
|
|
1165
1291
|
const siblings = group.tasks.filter((i) => {
|
|
1166
|
-
var
|
|
1167
|
-
return i.meta.benchmark && ((
|
|
1292
|
+
var _a;
|
|
1293
|
+
return i.meta.benchmark && ((_a = i.result) == null ? void 0 : _a.benchmark) && i !== bench;
|
|
1168
1294
|
}).sort((a, b) => a.result.benchmark.rank - b.result.benchmark.rank);
|
|
1169
1295
|
if (siblings.length === 0) {
|
|
1170
1296
|
logger.log("");
|
|
@@ -1178,17 +1304,17 @@ ${c.cyan(c.inverse(c.bold(" BENCH ")))} ${c.cyan("Summary")}
|
|
|
1178
1304
|
}
|
|
1179
1305
|
}
|
|
1180
1306
|
printTaskErrors(tasks, errorDivider) {
|
|
1181
|
-
var
|
|
1307
|
+
var _a, _b, _c;
|
|
1182
1308
|
const errorsQueue = [];
|
|
1183
1309
|
for (const task of tasks) {
|
|
1184
|
-
(_b = (
|
|
1310
|
+
(_b = (_a = task.result) == null ? void 0 : _a.errors) == null ? void 0 : _b.forEach((error) => {
|
|
1185
1311
|
const errorItem = (error == null ? void 0 : error.stackStr) && errorsQueue.find((i) => {
|
|
1186
|
-
var
|
|
1187
|
-
const hasStr = ((
|
|
1312
|
+
var _a2, _b2, _c2, _d;
|
|
1313
|
+
const hasStr = ((_a2 = i[0]) == null ? void 0 : _a2.stackStr) === error.stackStr;
|
|
1188
1314
|
if (!hasStr)
|
|
1189
1315
|
return false;
|
|
1190
|
-
const currentProjectName = (task == null ? void 0 : task.projectName) || ((_b2 = task.file) == null ? void 0 : _b2.projectName);
|
|
1191
|
-
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) || "";
|
|
1192
1318
|
return projectName === currentProjectName;
|
|
1193
1319
|
});
|
|
1194
1320
|
if (errorItem)
|
|
@@ -1200,7 +1326,7 @@ ${c.cyan(c.inverse(c.bold(" BENCH ")))} ${c.cyan("Summary")}
|
|
|
1200
1326
|
for (const [error, tasks2] of errorsQueue) {
|
|
1201
1327
|
for (const task of tasks2) {
|
|
1202
1328
|
const filepath = (task == null ? void 0 : task.filepath) || "";
|
|
1203
|
-
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) || "";
|
|
1204
1330
|
let name = getFullName(task, c.dim(" > "));
|
|
1205
1331
|
if (filepath)
|
|
1206
1332
|
name = `${name} ${c.dim(`[ ${this.relative(filepath)} ]`)}`;
|
|
@@ -2140,7 +2266,7 @@ function formatFilepath$1(path) {
|
|
|
2140
2266
|
}
|
|
2141
2267
|
function formatNumber$1(number) {
|
|
2142
2268
|
const res = String(number.toFixed(number < 100 ? 4 : 2)).split(".");
|
|
2143
|
-
return res[0].replace(/(?=(?:\d{3})+$)
|
|
2269
|
+
return res[0].replace(/(?=(?:\d{3})+$)\B/g, ",") + (res[1] ? `.${res[1]}` : "");
|
|
2144
2270
|
}
|
|
2145
2271
|
function renderHookState(task, hookName, level = 0) {
|
|
2146
2272
|
var _a, _b;
|
|
@@ -2573,7 +2699,8 @@ class JsonReporter {
|
|
|
2573
2699
|
title: t.name,
|
|
2574
2700
|
duration: (_b2 = t.result) == null ? void 0 : _b2.duration,
|
|
2575
2701
|
failureMessages: ((_d2 = (_c2 = t.result) == null ? void 0 : _c2.errors) == null ? void 0 : _d2.map((e) => e.stack || e.message)) || [],
|
|
2576
|
-
location: t.location
|
|
2702
|
+
location: t.location,
|
|
2703
|
+
meta: t.meta
|
|
2577
2704
|
};
|
|
2578
2705
|
});
|
|
2579
2706
|
if (tests2.some((t) => {
|
|
@@ -4304,6 +4431,8 @@ const skipErrorProperties = /* @__PURE__ */ new Set([
|
|
|
4304
4431
|
"stackStr",
|
|
4305
4432
|
"type",
|
|
4306
4433
|
"showDiff",
|
|
4434
|
+
"ok",
|
|
4435
|
+
"operator",
|
|
4307
4436
|
"diff",
|
|
4308
4437
|
"codeFrame",
|
|
4309
4438
|
"actual",
|
|
@@ -4456,12 +4585,14 @@ function flattenTasks$1(task, baseName = "") {
|
|
|
4456
4585
|
}
|
|
4457
4586
|
}
|
|
4458
4587
|
function removeInvalidXMLCharacters(value, removeDiscouragedChars) {
|
|
4459
|
-
let regex = /(
|
|
4588
|
+
let regex = /([\0-\x08\v\f\x0E-\x1F\uFFFD\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/g;
|
|
4460
4589
|
value = String(value || "").replace(regex, "");
|
|
4461
4590
|
{
|
|
4462
4591
|
regex = new RegExp(
|
|
4463
|
-
|
|
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]))",
|
|
4464
4594
|
"g"
|
|
4595
|
+
/* eslint-enable */
|
|
4465
4596
|
);
|
|
4466
4597
|
value = value.replace(regex, "");
|
|
4467
4598
|
}
|
|
@@ -4543,8 +4674,7 @@ class JUnitReporter {
|
|
|
4543
4674
|
async writeTasks(tasks, filename) {
|
|
4544
4675
|
for (const task of tasks) {
|
|
4545
4676
|
await this.writeElement("testcase", {
|
|
4546
|
-
|
|
4547
|
-
classname: this.options.classname ?? process.env.VITEST_JUNIT_CLASSNAME ?? filename,
|
|
4677
|
+
classname: this.options.classname ?? filename,
|
|
4548
4678
|
file: this.options.addFileAttribute ? filename : void 0,
|
|
4549
4679
|
name: task.name,
|
|
4550
4680
|
time: getDuration(task)
|
|
@@ -4628,8 +4758,7 @@ class JUnitReporter {
|
|
|
4628
4758
|
stats2.failures += file.stats.failures;
|
|
4629
4759
|
return stats2;
|
|
4630
4760
|
}, {
|
|
4631
|
-
|
|
4632
|
-
name: this.options.suiteName || process.env.VITEST_JUNIT_SUITE_NAME || "vitest tests",
|
|
4761
|
+
name: this.options.suiteName || "vitest tests",
|
|
4633
4762
|
tests: 0,
|
|
4634
4763
|
failures: 0,
|
|
4635
4764
|
errors: 0,
|
|
@@ -4766,6 +4895,94 @@ function escapeProperty(s) {
|
|
|
4766
4895
|
return s.replace(/%/g, "%25").replace(/\r/g, "%0D").replace(/\n/g, "%0A").replace(/:/g, "%3A").replace(/,/g, "%2C");
|
|
4767
4896
|
}
|
|
4768
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
|
+
|
|
4769
4986
|
const outputMap = /* @__PURE__ */ new WeakMap();
|
|
4770
4987
|
function formatFilepath(path) {
|
|
4771
4988
|
const lastSlash = Math.max(path.lastIndexOf("/") + 1, 0);
|
|
@@ -4778,7 +4995,7 @@ function formatFilepath(path) {
|
|
|
4778
4995
|
}
|
|
4779
4996
|
function formatNumber(number) {
|
|
4780
4997
|
const res = String(number.toFixed(number < 100 ? 4 : 2)).split(".");
|
|
4781
|
-
return res[0].replace(/(?=(?:\d{3})+$)
|
|
4998
|
+
return res[0].replace(/(?=(?:\d{3})+$)\B/g, ",") + (res[1] ? `.${res[1]}` : "");
|
|
4782
4999
|
}
|
|
4783
5000
|
const tableHead = ["name", "hz", "min", "max", "mean", "p75", "p99", "p995", "p999", "rme", "samples"];
|
|
4784
5001
|
function renderBenchmarkItems(result) {
|
|
@@ -5078,6 +5295,7 @@ function createFormattedBenchamrkReport(files) {
|
|
|
5078
5295
|
benchmarks.push({
|
|
5079
5296
|
id: t.id,
|
|
5080
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,
|
|
5081
5299
|
...rest
|
|
5082
5300
|
});
|
|
5083
5301
|
}
|
|
@@ -5116,6 +5334,7 @@ const BenchmarkReportsMap = {
|
|
|
5116
5334
|
const ReportersMap = {
|
|
5117
5335
|
"default": DefaultReporter,
|
|
5118
5336
|
"basic": BasicReporter,
|
|
5337
|
+
"blob": BlobReporter,
|
|
5119
5338
|
"verbose": VerboseReporter,
|
|
5120
5339
|
"dot": DotReporter,
|
|
5121
5340
|
"json": JsonReporter,
|
|
@@ -5126,4 +5345,4 @@ const ReportersMap = {
|
|
|
5126
5345
|
"github-actions": GithubActionsReporter
|
|
5127
5346
|
};
|
|
5128
5347
|
|
|
5129
|
-
export { BaseSequencer as B, DefaultReporter as D, GithubActionsReporter as G, HangingProcessReporter as H, JsonReporter as J, Logger as L, ReportersMap as R, TapReporter as T, VerboseReporter as V, BasicReporter as a, DotReporter as b, JUnitReporter as c, TapFlatReporter as d, BenchmarkReportsMap as e, Typechecker as f, RandomSequencer as g, findNodeAround as h, generateCodeFrame as i, highlightCode as j, wrapSerializableConfig as w };
|
|
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 };
|