vitest 0.24.5 → 0.25.0

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.
Files changed (48) hide show
  1. package/LICENSE.md +286 -57
  2. package/dist/browser.d.ts +3 -3
  3. package/dist/browser.js +17 -10
  4. package/dist/{chunk-api-setup.629f8133.js → chunk-api-setup.a13c5f9d.js} +38 -19
  5. package/dist/{chunk-install-pkg.22707ee4.js → chunk-install-pkg.55bfe508.js} +4 -5
  6. package/dist/{chunk-integrations-coverage.cca09977.js → chunk-integrations-coverage.befed097.js} +57 -1
  7. package/dist/chunk-integrations-globals.391b3839.js +25 -0
  8. package/dist/{chunk-node-git.82174cfe.js → chunk-node-git.af5c9d73.js} +5 -6
  9. package/dist/{chunk-runtime-chain.37ec5d73.js → chunk-runtime-chain.3b531731.js} +27 -23
  10. package/dist/{chunk-runtime-error.17751c39.js → chunk-runtime-error.3cc15c6f.js} +9 -2
  11. package/dist/{chunk-runtime-mocker.41b92ec9.js → chunk-runtime-mocker.a5d87666.js} +4 -4
  12. package/dist/{chunk-runtime-rpc.b418c0ab.js → chunk-runtime-rpc.4a2d45ab.js} +2 -2
  13. package/dist/chunk-runtime-setup.f644ac4c.js +1350 -0
  14. package/dist/{chunk-runtime-hooks.d748b085.js → chunk-runtime-test-state.31ce8643.js} +106 -6
  15. package/dist/{chunk-mock-date.030959d3.js → chunk-typecheck-constants.410fa7b2.js} +23 -4
  16. package/dist/{chunk-utils-env.b1281522.js → chunk-utils-env.7fe285cc.js} +2 -0
  17. package/dist/chunk-utils-source-map.1a66263d.js +90 -0
  18. package/dist/{chunk-utils-timers.8fca243e.js → chunk-utils-timers.d1fcc6bb.js} +86 -79
  19. package/dist/{chunk-vite-node-client.3868b3ba.js → chunk-vite-node-client.13ea0a59.js} +25 -5
  20. package/dist/{chunk-vite-node-externalize.d9033432.js → chunk-vite-node-externalize.01d0d22c.js} +821 -92
  21. package/dist/chunk-vite-node-utils.b89230f3.js +1400 -0
  22. package/dist/cli-wrapper.js +5 -6
  23. package/dist/cli.js +27 -13
  24. package/dist/config.cjs +6 -1
  25. package/dist/config.d.ts +6 -1
  26. package/dist/config.js +6 -1
  27. package/dist/entry.js +11 -10
  28. package/dist/environments.d.ts +1 -1
  29. package/dist/index-b68b3c09.d.ts +256 -0
  30. package/dist/index.d.ts +4 -4
  31. package/dist/index.js +13 -7
  32. package/dist/loader.js +4 -3
  33. package/dist/node.d.ts +2 -2
  34. package/dist/node.js +18 -11
  35. package/dist/suite.js +6 -6
  36. package/dist/{global-58e8e951.d.ts → types-b3ff5eea.d.ts} +215 -18
  37. package/dist/{vendor-index.cc8d244b.js → vendor-index.16d769d7.js} +1 -2
  38. package/dist/{vendor-index.12d51d29.js → vendor-index.22806ffb.js} +279 -7
  39. package/dist/{vendor-index.9c919048.js → vendor-index.808a85a6.js} +0 -0
  40. package/dist/worker.js +9 -8
  41. package/globals.d.ts +2 -0
  42. package/package.json +13 -9
  43. package/dist/chunk-integrations-globals.32ef80c3.js +0 -25
  44. package/dist/chunk-runtime-setup.ab6b6274.js +0 -676
  45. package/dist/chunk-utils-source-map.663e2952.js +0 -3429
  46. package/dist/chunk-vite-node-utils.2144000e.js +0 -6946
  47. package/dist/index-220c1d70.d.ts +0 -117
  48. package/dist/vendor-index.1a291e86.js +0 -275
@@ -1,7 +1,7 @@
1
- import { b as resolve, p as picocolors, j as join, c as basename, d as dirname, e as distDir, f as rootDir, g as isAbsolute, r as relative, i as isNode, h as configFiles, k as defaultPort, n as normalize, t as toNamespacedPath, E as EXIT_CODE_RESTART } from './chunk-utils-env.b1281522.js';
2
- import { p as pLimit, g as getCoverageProvider, C as CoverageProviderMap } from './chunk-integrations-coverage.cca09977.js';
1
+ import { b as resolve, p as picocolors, j as join, c as basename, d as dirname, r as relative, e as distDir, f as rootDir, g as isAbsolute, i as isNode, h as configFiles, k as defaultPort, n as normalize, t as toNamespacedPath, E as EXIT_CODE_RESTART } from './chunk-utils-env.7fe285cc.js';
2
+ import { p as pLimit, s as someTasksAreOnly, i as interpretTaskModes, g as getCoverageProvider, C as CoverageProviderMap } from './chunk-integrations-coverage.befed097.js';
3
3
  import { g as getEnvPackageName } from './chunk-env-node.700b7e95.js';
4
- import { A as AggregateErrorPonyfill, s as slash$2, k as relativePath, x as getTests, e as getFullName, q as hasFailed, y as hasFailedSnapshot, z as getSuites, j as notNullish, l as shuffle, t as toArray$1, n as noop$1, B as deepMerge, b as getCallLastIndex, C as ensurePackageInstalled, D as stdout } from './chunk-mock-date.030959d3.js';
4
+ import { T as TYPECHECK_SUITE, x as ensurePackageInstalled, A as AggregateErrorPonyfill, s as slash$2, k as relativePath, y as getTests, e as getFullName, q as hasFailed, z as hasFailedSnapshot, B as getTypecheckTests, C as getSuites, D as isTypecheckTest, j as notNullish, l as shuffle, t as toArray$1, n as noop$1, E as deepMerge, b as getCallLastIndex, F as removeUndefinedValues, G as stdout } from './chunk-typecheck-constants.410fa7b2.js';
5
5
  import { loadConfigFromFile, normalizePath, createServer, mergeConfig } from 'vite';
6
6
  import path$a from 'path';
7
7
  import url, { fileURLToPath } from 'url';
@@ -12,24 +12,30 @@ import util$2 from 'util';
12
12
  import require$$0$1 from 'stream';
13
13
  import require$$2 from 'events';
14
14
  import { c as commonjsGlobal } from './vendor-_commonjsHelpers.addc3445.js';
15
- import { c as createBirpc, V as ViteNodeRunner } from './chunk-vite-node-client.3868b3ba.js';
15
+ import { c as createBirpc, V as ViteNodeRunner } from './chunk-vite-node-client.13ea0a59.js';
16
16
  import { performance } from 'perf_hooks';
17
17
  import createDebug from 'debug';
18
- import { i as isNodeBuiltin, a as isValidNodeImport, s as slash$1, t as toArray, b as toFilePath, w as withInlineSourcemap } from './chunk-vite-node-utils.2144000e.js';
18
+ import { i as isNodeBuiltin, a as isValidNodeImport, s as slash$1, t as toArray, b as toFilePath, w as withInlineSourcemap } from './chunk-vite-node-utils.b89230f3.js';
19
+ import { writeFile, rm } from 'fs/promises';
20
+ import { e as execa } from './vendor-index.16d769d7.js';
21
+ import { SourceMapConsumer } from 'source-map';
22
+ import H from 'module';
23
+ import { parse as parse$4 } from 'acorn';
24
+ import { ancestor } from 'acorn-walk';
19
25
  import { MessageChannel } from 'worker_threads';
20
26
  import { Tinypool } from 'tinypool';
21
- import { c as stripAnsi, d as safeSetInterval, e as safeClearInterval, g as cliTruncate, s as safeSetTimeout, h as stringWidth, i as ansiStyles, j as sliceAnsi, a as stringify$5, u as unifiedDiff, b as safeClearTimeout } from './chunk-utils-timers.8fca243e.js';
22
- import { p as parseStacktrace, i as interpretSourcePos, a as posToNumber, l as lineSplitRE } from './chunk-utils-source-map.663e2952.js';
27
+ import { c as stripAnsi, d as safeSetInterval, e as safeClearInterval, g as cliTruncate, s as safeSetTimeout, h as stringWidth, i as ansiStyles, j as sliceAnsi, a as stringify$5, u as unifiedDiff, b as safeClearTimeout } from './chunk-utils-timers.d1fcc6bb.js';
28
+ import { p as parseStacktrace, a as posToNumber, l as lineSplitRE } from './chunk-utils-source-map.1a66263d.js';
23
29
  import { resolveModule } from 'local-pkg';
24
30
  import { createHash } from 'crypto';
25
- import { o as onetime } from './vendor-index.9c919048.js';
26
- import { s as signalExit } from './vendor-index.1a291e86.js';
31
+ import { o as onetime } from './vendor-index.808a85a6.js';
32
+ import { s as signalExit } from './vendor-index.22806ffb.js';
27
33
  import MagicString from './chunk-magic-string.ffe2b171.js';
28
34
  import { stripLiteral } from 'strip-literal';
29
35
  import require$$0$2 from 'readline';
30
36
  import { p as prompts } from './vendor-index.9f20a9be.js';
31
37
 
32
- var version$1 = "0.24.5";
38
+ var version$1 = "0.25.0";
33
39
 
34
40
  class EndError extends Error {
35
41
  constructor(value) {
@@ -6969,6 +6975,14 @@ class ViteNodeServer {
6969
6975
  const mode = importer && this.getTransformMode(importer) || "ssr";
6970
6976
  return this.server.pluginContainer.resolveId(id, importer, { ssr: mode === "ssr" });
6971
6977
  }
6978
+ getSourceMap(source) {
6979
+ var _a, _b;
6980
+ const fetchResult = (_a = this.fetchCache.get(source)) == null ? void 0 : _a.result;
6981
+ if (fetchResult == null ? void 0 : fetchResult.map)
6982
+ return fetchResult.map;
6983
+ const ssrTransformResult = (_b = this.server.moduleGraph.getModuleById(source)) == null ? void 0 : _b.ssrTransformResult;
6984
+ return (ssrTransformResult == null ? void 0 : ssrTransformResult.map) || null;
6985
+ }
6972
6986
  async fetchModule(id) {
6973
6987
  if (!this.fetchPromiseMap.has(id)) {
6974
6988
  this.fetchPromiseMap.set(
@@ -7124,6 +7138,419 @@ function addSnapshotResult(summary, result) {
7124
7138
  summary.total += result.added + result.matched + result.unmatched + result.updated;
7125
7139
  }
7126
7140
 
7141
+ function T(r){const t=/^\\\\\?\\/.test(r),n=/[^\u0000-\u0080]+/.test(r);return t||n?r:r.replace(/\\/g,"/")}function B(r,t){for(;;){const n=path$a.join(r,t);if(fs$8.existsSync(n))return T(n);const e=path$a.dirname(r);if(e===r)return;r=e;}}function G(r,t){t===void 0&&(t=!1);var n=r.length,e=0,i="",a=0,o=16,u=0,f=0,d=0,C=0,c=0;function y(s,m){for(var v=0,b=0;v<s||!m;){var h=r.charCodeAt(e);if(h>=48&&h<=57)b=b*16+h-48;else if(h>=65&&h<=70)b=b*16+h-65+10;else if(h>=97&&h<=102)b=b*16+h-97+10;else break;e++,v++;}return v<s&&(b=-1),b}function V(s){e=s,i="",a=0,o=16,c=0;}function $(){var s=e;if(r.charCodeAt(e)===48)e++;else for(e++;e<r.length&&j(r.charCodeAt(e));)e++;if(e<r.length&&r.charCodeAt(e)===46)if(e++,e<r.length&&j(r.charCodeAt(e)))for(e++;e<r.length&&j(r.charCodeAt(e));)e++;else return c=3,r.substring(s,e);var m=e;if(e<r.length&&(r.charCodeAt(e)===69||r.charCodeAt(e)===101))if(e++,(e<r.length&&r.charCodeAt(e)===43||r.charCodeAt(e)===45)&&e++,e<r.length&&j(r.charCodeAt(e))){for(e++;e<r.length&&j(r.charCodeAt(e));)e++;m=e;}else c=3;return r.substring(s,m)}function _(){for(var s="",m=e;;){if(e>=n){s+=r.substring(m,e),c=2;break}var v=r.charCodeAt(e);if(v===34){s+=r.substring(m,e),e++;break}if(v===92){if(s+=r.substring(m,e),e++,e>=n){c=2;break}var b=r.charCodeAt(e++);switch(b){case 34:s+='"';break;case 92:s+="\\";break;case 47:s+="/";break;case 98:s+="\b";break;case 102:s+="\f";break;case 110:s+=`
7142
+ `;break;case 114:s+="\r";break;case 116:s+=" ";break;case 117:var h=y(4,!0);h>=0?s+=String.fromCharCode(h):c=4;break;default:c=5;}m=e;continue}if(v>=0&&v<=31)if(P(v)){s+=r.substring(m,e),c=2;break}else c=6;e++;}return s}function S(){if(i="",c=0,a=e,f=u,C=d,e>=n)return a=n,o=17;var s=r.charCodeAt(e);if(U(s)){do e++,i+=String.fromCharCode(s),s=r.charCodeAt(e);while(U(s));return o=15}if(P(s))return e++,i+=String.fromCharCode(s),s===13&&r.charCodeAt(e)===10&&(e++,i+=`
7143
+ `),u++,d=e,o=14;switch(s){case 123:return e++,o=1;case 125:return e++,o=2;case 91:return e++,o=3;case 93:return e++,o=4;case 58:return e++,o=6;case 44:return e++,o=5;case 34:return e++,i=_(),o=10;case 47:var m=e-1;if(r.charCodeAt(e+1)===47){for(e+=2;e<n&&!P(r.charCodeAt(e));)e++;return i=r.substring(m,e),o=12}if(r.charCodeAt(e+1)===42){e+=2;for(var v=n-1,b=!1;e<v;){var h=r.charCodeAt(e);if(h===42&&r.charCodeAt(e+1)===47){e+=2,b=!0;break}e++,P(h)&&(h===13&&r.charCodeAt(e)===10&&e++,u++,d=e);}return b||(e++,c=1),i=r.substring(m,e),o=13}return i+=String.fromCharCode(s),e++,o=16;case 45:if(i+=String.fromCharCode(s),e++,e===n||!j(r.charCodeAt(e)))return o=16;case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return i+=$(),o=11;default:for(;e<n&&k(s);)e++,s=r.charCodeAt(e);if(a!==e){switch(i=r.substring(a,e),i){case"true":return o=8;case"false":return o=9;case"null":return o=7}return o=16}return i+=String.fromCharCode(s),e++,o=16}}function k(s){if(U(s)||P(s))return !1;switch(s){case 125:case 93:case 123:case 91:case 34:case 58:case 44:case 47:return !1}return !0}function l(){var s;do s=S();while(s>=12&&s<=15);return s}return {setPosition:V,getPosition:function(){return e},scan:t?l:S,getToken:function(){return o},getTokenValue:function(){return i},getTokenOffset:function(){return a},getTokenLength:function(){return e-a},getTokenStartLine:function(){return f},getTokenStartCharacter:function(){return a-C},getTokenError:function(){return c}}}function U(r){return r===32||r===9||r===11||r===12||r===160||r===5760||r>=8192&&r<=8203||r===8239||r===8287||r===12288||r===65279}function P(r){return r===10||r===13||r===8232||r===8233}function j(r){return r>=48&&r<=57}var N;(function(r){r.DEFAULT={allowTrailingComma:!1};})(N||(N={}));function K(r,t,n){t===void 0&&(t=[]),n===void 0&&(n=N.DEFAULT);var e=null,i=[],a=[];function o(f){Array.isArray(i)?i.push(f):e!==null&&(i[e]=f);}var u={onObjectBegin:function(){var f={};o(f),a.push(i),i=f,e=null;},onObjectProperty:function(f){e=f;},onObjectEnd:function(){i=a.pop();},onArrayBegin:function(){var f=[];o(f),a.push(i),i=f,e=null;},onArrayEnd:function(){i=a.pop();},onLiteralValue:o,onError:function(f,d,C){t.push({error:f,offset:d,length:C});}};return Q(r,u,n),i[0]}function Q(r,t,n){n===void 0&&(n=N.DEFAULT);var e=G(r,!1);function i(p){return p?function(){return p(e.getTokenOffset(),e.getTokenLength(),e.getTokenStartLine(),e.getTokenStartCharacter())}:function(){return !0}}function a(p){return p?function(w){return p(w,e.getTokenOffset(),e.getTokenLength(),e.getTokenStartLine(),e.getTokenStartCharacter())}:function(){return !0}}var o=i(t.onObjectBegin),u=a(t.onObjectProperty),f=i(t.onObjectEnd),d=i(t.onArrayBegin),C=i(t.onArrayEnd),c=a(t.onLiteralValue),y=a(t.onSeparator),V=i(t.onComment),$=a(t.onError),_=n&&n.disallowComments,S=n&&n.allowTrailingComma;function k(){for(;;){var p=e.scan();switch(e.getTokenError()){case 4:l(14);break;case 5:l(15);break;case 3:l(13);break;case 1:_||l(11);break;case 2:l(12);break;case 6:l(16);break}switch(p){case 12:case 13:_?l(10):V();break;case 16:l(1);break;case 15:case 14:break;default:return p}}}function l(p,w,L){if(w===void 0&&(w=[]),L===void 0&&(L=[]),$(p),w.length+L.length>0)for(var D=e.getToken();D!==17;){if(w.indexOf(D)!==-1){k();break}else if(L.indexOf(D)!==-1)break;D=k();}}function s(p){var w=e.getTokenValue();return p?c(w):u(w),k(),!0}function m(){switch(e.getToken()){case 11:var p=e.getTokenValue(),w=Number(p);isNaN(w)&&(l(2),w=0),c(w);break;case 7:c(null);break;case 8:c(!0);break;case 9:c(!1);break;default:return !1}return k(),!0}function v(){return e.getToken()!==10?(l(3,[],[2,5]),!1):(s(!1),e.getToken()===6?(y(":"),k(),F()||l(4,[],[2,5])):l(5,[],[2,5]),!0)}function b(){o(),k();for(var p=!1;e.getToken()!==2&&e.getToken()!==17;){if(e.getToken()===5){if(p||l(4,[],[]),y(","),k(),e.getToken()===2&&S)break}else p&&l(6,[],[]);v()||l(4,[],[2,5]),p=!0;}return f(),e.getToken()!==2?l(7,[2],[]):k(),!0}function h(){d(),k();for(var p=!1;e.getToken()!==4&&e.getToken()!==17;){if(e.getToken()===5){if(p||l(4,[],[]),y(","),k(),e.getToken()===4&&S)break}else p&&l(6,[],[]);F()||l(4,[],[4,5]),p=!0;}return C(),e.getToken()!==4?l(8,[4],[]):k(),!0}function F(){switch(e.getToken()){case 3:return h();case 1:return b();case 10:return s(!0);default:return m()}}return k(),e.getToken()===17?n.allowEmptyContent?!0:(l(4,[],[]),!1):F()?(e.getToken()!==17&&l(9,[],[]),!0):(l(4,[],[]),!1)}var X=K;const W=/^\.{1,2}(\/.*)?$/,J=r=>T(W.test(r)?r:`./${r}`),{existsSync:E}=fs$8,Y=r=>{try{return JSON.parse(r)}catch{}},Z=()=>{const{findPnpApi:r}=H;return r&&r(process.cwd())};function I(r){const t=Y(fs$8.readFileSync(r,"utf8"));return path$a.join(r,"..",t&&"tsconfig"in t?t.tsconfig:"tsconfig.json")}function x(r,t){let n=r;if(n===".."&&(n+="/tsconfig.json"),n.startsWith(".")){let a=path$a.resolve(t,n);if(E(a)&&fs$8.statSync(a).isFile()||!a.endsWith(".json")&&(a+=".json",E(a)))return a;throw new Error(`File '${r}' not found.`)}const e=Z();if(e){const{resolveRequest:a}=e,[o,u]=r.split("/"),f=o.startsWith("@")?`${o}/${u}`:o;try{if(f===r){const d=a(path$a.join(f,"package.json"),t);if(d){const C=I(d);if(E(C))return C}}else try{return a(r,t,{extensions:[".json"]})}catch{return a(path$a.join(r,"tsconfig.json"),t)}}catch{}}let i=B(t,path$a.join("node_modules",n));if(i){if(fs$8.statSync(i).isDirectory()){const a=path$a.join(i,"package.json");if(E(a)?i=I(a):i=path$a.join(i,"tsconfig.json"),E(i))return i}else if(i.endsWith(".json"))return i}if(!n.endsWith(".json")&&(n+=".json",i=B(t,path$a.join("node_modules",n)),i))return i;throw new Error(`File '${r}' not found.`)}var ee=Object.defineProperty,re=Object.defineProperties,ne=Object.getOwnPropertyDescriptors,R=Object.getOwnPropertySymbols,te=Object.prototype.hasOwnProperty,ae=Object.prototype.propertyIsEnumerable,q=(r,t,n)=>t in r?ee(r,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[t]=n,A=(r,t)=>{for(var n in t||(t={}))te.call(t,n)&&q(r,n,t[n]);if(R)for(var n of R(t))ae.call(t,n)&&q(r,n,t[n]);return r},oe=(r,t)=>re(r,ne(t));function M(r){var t;let n;try{n=fs$8.realpathSync(r);}catch{throw new Error(`Cannot resolve tsconfig at path: ${r}`)}const e=path$a.dirname(n),i=fs$8.readFileSync(n,"utf8").trim();let a={};if(i&&(a=X(i),!a||typeof a!="object"))throw new SyntaxError(`Failed to parse tsconfig at: ${r}`);if(a.extends){const o=x(a.extends,e),u=M(o);if(delete u.references,(t=u.compilerOptions)!=null&&t.baseUrl){const{compilerOptions:d}=u;d.baseUrl=path$a.relative(e,path$a.join(path$a.dirname(o),d.baseUrl))||"./";}u.files&&(u.files=u.files.map(d=>path$a.relative(e,path$a.join(path$a.dirname(o),d)))),u.include&&(u.include=u.include.map(d=>path$a.relative(e,path$a.join(path$a.dirname(o),d)))),delete a.extends;const f=oe(A(A({},u),a),{compilerOptions:A(A({},u.compilerOptions),a.compilerOptions)});u.watchOptions&&(f.watchOptions=A(A({},u.watchOptions),a.watchOptions)),a=f;}if(a.compilerOptions){const{compilerOptions:o}=a;o.baseUrl&&(o.baseUrl=J(o.baseUrl)),o.outDir&&(Array.isArray(a.exclude)||(a.exclude=[]),a.exclude.push(o.outDir),o.outDir=J(o.outDir));}if(a.files&&(a.files=a.files.map(J)),a.include&&(a.include=a.include.map(T)),a.watchOptions){const{watchOptions:o}=a;o.excludeDirectories&&(o.excludeDirectories=o.excludeDirectories.map(u=>T(path$a.resolve(e,u))));}return a}function ie(r=process.cwd(),t="tsconfig.json"){const n=B(r,t);if(!n)return null;const e=M(n);return {path:n,config:e}}
7144
+
7145
+ const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
7146
+ const newLineRegExp = /\r?\n/;
7147
+ const errCodeRegExp = /error TS(?<errCode>\d+)/;
7148
+ async function makeTscErrorInfo(errInfo) {
7149
+ var _a;
7150
+ const [errFilePathPos = "", ...errMsgRawArr] = errInfo.split(":");
7151
+ if (!errFilePathPos || errMsgRawArr.length === 0 || errMsgRawArr.join("").length === 0)
7152
+ return ["unknown filepath", null];
7153
+ const errMsgRaw = errMsgRawArr.join("").trim();
7154
+ const [errFilePath, errPos] = errFilePathPos.slice(0, -1).split("(");
7155
+ if (!errFilePath || !errPos)
7156
+ return ["unknown filepath", null];
7157
+ const [errLine, errCol] = errPos.split(",");
7158
+ if (!errLine || !errCol)
7159
+ return [errFilePath, null];
7160
+ const execArr = errCodeRegExp.exec(errMsgRaw);
7161
+ if (!execArr)
7162
+ return [errFilePath, null];
7163
+ const errCodeStr = ((_a = execArr.groups) == null ? void 0 : _a.errCode) ?? "";
7164
+ if (!errCodeStr)
7165
+ return [errFilePath, null];
7166
+ const line = Number(errLine);
7167
+ const col = Number(errCol);
7168
+ const errCode = Number(errCodeStr);
7169
+ return [
7170
+ errFilePath,
7171
+ {
7172
+ filePath: errFilePath,
7173
+ errCode,
7174
+ line,
7175
+ column: col,
7176
+ errMsg: errMsgRaw.slice(`error TS${errCode} `.length)
7177
+ }
7178
+ ];
7179
+ }
7180
+ async function getTsconfigPath(root, config) {
7181
+ var _a;
7182
+ const tempConfigPath = path$a.join(root, "tsconfig.temp.json");
7183
+ const configName = ((_a = config.tsconfig) == null ? void 0 : _a.includes("jsconfig.json")) ? "jsconfig.json" : void 0;
7184
+ const tsconfig = ie(config.tsconfig || root, configName);
7185
+ if (!tsconfig)
7186
+ throw new Error("no tsconfig.json found");
7187
+ try {
7188
+ const tmpTsConfig = { ...tsconfig.config };
7189
+ tmpTsConfig.compilerOptions ?? (tmpTsConfig.compilerOptions = {});
7190
+ tmpTsConfig.compilerOptions.emitDeclarationOnly = false;
7191
+ tmpTsConfig.compilerOptions.incremental = true;
7192
+ tmpTsConfig.compilerOptions.tsBuildInfoFile = path$a.join(
7193
+ __dirname,
7194
+ "tsconfig.tmp.tsbuildinfo"
7195
+ );
7196
+ const tsconfigFinalContent = JSON.stringify(tmpTsConfig, null, 2);
7197
+ await writeFile(tempConfigPath, tsconfigFinalContent);
7198
+ return tempConfigPath;
7199
+ } catch (err) {
7200
+ throw new Error("failed to write tsconfig.temp.json", { cause: err });
7201
+ }
7202
+ }
7203
+ async function getRawErrsMapFromTsCompile(tscErrorStdout) {
7204
+ const rawErrsMap = /* @__PURE__ */ new Map();
7205
+ const infos = await Promise.all(
7206
+ tscErrorStdout.split(newLineRegExp).reduce((prev, next) => {
7207
+ if (!next)
7208
+ return prev;
7209
+ else if (!next.startsWith(" "))
7210
+ prev.push(next);
7211
+ else
7212
+ prev[prev.length - 1] += `
7213
+ ${next}`;
7214
+ return prev;
7215
+ }, []).map((errInfoLine) => makeTscErrorInfo(errInfoLine))
7216
+ );
7217
+ infos.forEach(([errFilePath, errInfo]) => {
7218
+ var _a;
7219
+ if (!errInfo)
7220
+ return;
7221
+ if (!rawErrsMap.has(errFilePath))
7222
+ rawErrsMap.set(errFilePath, [errInfo]);
7223
+ else
7224
+ (_a = rawErrsMap.get(errFilePath)) == null ? void 0 : _a.push(errInfo);
7225
+ });
7226
+ return rawErrsMap;
7227
+ }
7228
+
7229
+ const createIndexMap = (source) => {
7230
+ const map = /* @__PURE__ */ new Map();
7231
+ let index = 0;
7232
+ let line = 1;
7233
+ let column = 1;
7234
+ for (const char of source) {
7235
+ map.set(`${line}:${column}`, index++);
7236
+ if (char === "\n" || char === "\r\n") {
7237
+ line++;
7238
+ column = 0;
7239
+ } else {
7240
+ column++;
7241
+ }
7242
+ }
7243
+ return map;
7244
+ };
7245
+
7246
+ async function collectTests(ctx, filepath) {
7247
+ const request = await ctx.vitenode.transformRequest(filepath);
7248
+ if (!request)
7249
+ return null;
7250
+ const ast = parse$4(request.code, {
7251
+ ecmaVersion: "latest",
7252
+ allowAwaitOutsideFunction: true
7253
+ });
7254
+ const file = {
7255
+ filepath,
7256
+ type: "suite",
7257
+ id: "-1",
7258
+ name: relative(ctx.config.root, filepath),
7259
+ mode: "run",
7260
+ tasks: [],
7261
+ start: ast.start,
7262
+ end: ast.end,
7263
+ result: {
7264
+ state: "pass"
7265
+ }
7266
+ };
7267
+ const definitions = [];
7268
+ const getName = (callee) => {
7269
+ var _a, _b, _c;
7270
+ if (!callee)
7271
+ return null;
7272
+ if (callee.type === "Identifier")
7273
+ return callee.name;
7274
+ if (callee.type === "MemberExpression") {
7275
+ if ((_b = (_a = callee.object) == null ? void 0 : _a.name) == null ? void 0 : _b.startsWith("__vite_ssr_"))
7276
+ return getName(callee.property);
7277
+ return getName((_c = callee.object) == null ? void 0 : _c.property);
7278
+ }
7279
+ return null;
7280
+ };
7281
+ ancestor(ast, {
7282
+ CallExpression(node) {
7283
+ var _a;
7284
+ const { callee } = node;
7285
+ const name = getName(callee);
7286
+ if (!name)
7287
+ return;
7288
+ if (!["it", "test", "describe", "suite"].includes(name))
7289
+ return;
7290
+ const { arguments: [{ value: message }] } = node;
7291
+ const property = (_a = callee == null ? void 0 : callee.property) == null ? void 0 : _a.name;
7292
+ const mode = !property || property === name ? "run" : property;
7293
+ if (!["run", "skip", "todo", "only"].includes(mode))
7294
+ throw new Error(`${name}.${mode} syntax is not supported when testing types`);
7295
+ definitions.push({
7296
+ start: node.start,
7297
+ end: node.end,
7298
+ name: message,
7299
+ type: name,
7300
+ mode
7301
+ });
7302
+ }
7303
+ });
7304
+ let lastSuite = file;
7305
+ const updateLatestSuite = (index) => {
7306
+ const suite = lastSuite;
7307
+ while (lastSuite !== file && lastSuite.end < index)
7308
+ lastSuite = suite.suite;
7309
+ return lastSuite;
7310
+ };
7311
+ definitions.sort((a, b) => a.start - b.start).forEach((definition, idx) => {
7312
+ const latestSuite = updateLatestSuite(definition.start);
7313
+ let mode = definition.mode;
7314
+ if (latestSuite.mode !== "run")
7315
+ mode = latestSuite.mode;
7316
+ const state = mode === "run" ? "pass" : mode;
7317
+ const task = {
7318
+ type: "suite",
7319
+ id: idx.toString(),
7320
+ suite: latestSuite,
7321
+ file,
7322
+ tasks: [],
7323
+ mode,
7324
+ name: definition.name,
7325
+ end: definition.end,
7326
+ start: definition.start,
7327
+ result: {
7328
+ state
7329
+ }
7330
+ };
7331
+ definition.task = task;
7332
+ latestSuite.tasks.push(task);
7333
+ if (definition.type === "describe" || definition.type === "suite")
7334
+ lastSuite = task;
7335
+ else
7336
+ Object.defineProperty(task, TYPECHECK_SUITE, { value: true });
7337
+ });
7338
+ const hasOnly = someTasksAreOnly(file);
7339
+ interpretTaskModes(file, ctx.config.testNamePattern, hasOnly, false, ctx.config.allowOnly);
7340
+ return {
7341
+ file,
7342
+ parsed: request.code,
7343
+ filepath,
7344
+ map: request.map,
7345
+ definitions
7346
+ };
7347
+ }
7348
+
7349
+ class TypeCheckError extends Error {
7350
+ constructor(message, stacks) {
7351
+ super(message);
7352
+ this.message = message;
7353
+ this.stacks = stacks;
7354
+ this.name = "TypeCheckError";
7355
+ }
7356
+ }
7357
+ class Typechecker {
7358
+ constructor(ctx, files) {
7359
+ this.ctx = ctx;
7360
+ this.files = files;
7361
+ this._result = {
7362
+ files: [],
7363
+ sourceErrors: []
7364
+ };
7365
+ this._tests = {};
7366
+ }
7367
+ onParseStart(fn) {
7368
+ this._onParseStart = fn;
7369
+ }
7370
+ onParseEnd(fn) {
7371
+ this._onParseEnd = fn;
7372
+ }
7373
+ onWatcherRerun(fn) {
7374
+ this._onWatcherRerun = fn;
7375
+ }
7376
+ async collectFileTests(filepath) {
7377
+ return collectTests(this.ctx, filepath);
7378
+ }
7379
+ async collectTests() {
7380
+ const tests = (await Promise.all(
7381
+ this.files.map((filepath) => this.collectFileTests(filepath))
7382
+ )).reduce((acc, data) => {
7383
+ if (!data)
7384
+ return acc;
7385
+ acc[data.filepath] = data;
7386
+ return acc;
7387
+ }, {});
7388
+ this._tests = tests;
7389
+ return tests;
7390
+ }
7391
+ async prepareResults(output) {
7392
+ const typeErrors = await this.parseTscLikeOutput(output);
7393
+ const testFiles = new Set(this.files);
7394
+ if (!this._tests)
7395
+ this._tests = await this.collectTests();
7396
+ const sourceErrors = [];
7397
+ const files = [];
7398
+ testFiles.forEach((path) => {
7399
+ const { file, definitions, map, parsed } = this._tests[path];
7400
+ const errors = typeErrors.get(path);
7401
+ files.push(file);
7402
+ if (!errors)
7403
+ return;
7404
+ const sortedDefinitions = [...definitions.sort((a, b) => b.start - a.start)];
7405
+ const mapConsumer = map && new SourceMapConsumer(map);
7406
+ const indexMap = createIndexMap(parsed);
7407
+ const markFailed = (task) => {
7408
+ task.result = {
7409
+ state: task.mode === "run" || task.mode === "only" ? "fail" : task.mode
7410
+ };
7411
+ if (task.suite)
7412
+ markFailed(task.suite);
7413
+ };
7414
+ errors.forEach(({ error, originalError }, idx) => {
7415
+ const originalPos = (mapConsumer == null ? void 0 : mapConsumer.generatedPositionFor({
7416
+ line: originalError.line,
7417
+ column: originalError.column,
7418
+ source: path
7419
+ })) || originalError;
7420
+ const index = indexMap.get(`${originalPos.line}:${originalPos.column}`);
7421
+ const definition = index != null && sortedDefinitions.find((def) => def.start <= index && def.end >= index) || file;
7422
+ const suite = "task" in definition ? definition.task : definition;
7423
+ const state = suite.mode === "run" || suite.mode === "only" ? "fail" : suite.mode;
7424
+ const task = {
7425
+ type: "typecheck",
7426
+ id: idx.toString(),
7427
+ name: `error expect ${idx + 1}`,
7428
+ mode: suite.mode,
7429
+ file,
7430
+ suite,
7431
+ result: {
7432
+ state,
7433
+ error: state === "fail" ? error : void 0
7434
+ }
7435
+ };
7436
+ if (state === "fail")
7437
+ markFailed(suite);
7438
+ suite.tasks.push(task);
7439
+ });
7440
+ });
7441
+ typeErrors.forEach((errors, path) => {
7442
+ if (!testFiles.has(path))
7443
+ sourceErrors.push(...errors.map(({ error }) => error));
7444
+ });
7445
+ return {
7446
+ files,
7447
+ sourceErrors
7448
+ };
7449
+ }
7450
+ async parseTscLikeOutput(output) {
7451
+ const errorsMap = await getRawErrsMapFromTsCompile(output);
7452
+ const typesErrors = /* @__PURE__ */ new Map();
7453
+ errorsMap.forEach((errors, path) => {
7454
+ const filepath = resolve(this.ctx.config.root, path);
7455
+ const suiteErrors = errors.map((info) => {
7456
+ const limit = Error.stackTraceLimit;
7457
+ Error.stackTraceLimit = 0;
7458
+ const error = new TypeCheckError(info.errMsg, [
7459
+ {
7460
+ file: filepath,
7461
+ line: info.line,
7462
+ column: info.column,
7463
+ method: "",
7464
+ sourcePos: {
7465
+ line: info.line,
7466
+ column: info.column
7467
+ }
7468
+ }
7469
+ ]);
7470
+ Error.stackTraceLimit = limit;
7471
+ return {
7472
+ originalError: info,
7473
+ error
7474
+ };
7475
+ });
7476
+ typesErrors.set(filepath, suiteErrors);
7477
+ });
7478
+ return typesErrors;
7479
+ }
7480
+ async clear() {
7481
+ if (this.tempConfigPath)
7482
+ await rm(this.tempConfigPath, { force: true });
7483
+ }
7484
+ async stop() {
7485
+ var _a;
7486
+ await this.clear();
7487
+ (_a = this.process) == null ? void 0 : _a.kill();
7488
+ }
7489
+ async ensurePackageInstalled(root, checker) {
7490
+ if (checker !== "tsc" && checker !== "vue-tsc")
7491
+ return;
7492
+ const packageName = checker === "tsc" ? "typescript" : "vue-tsc";
7493
+ await ensurePackageInstalled(packageName, root);
7494
+ }
7495
+ async start() {
7496
+ var _a, _b, _c;
7497
+ const { root, watch, typecheck } = this.ctx.config;
7498
+ await this.ensurePackageInstalled(root, typecheck.checker);
7499
+ this.tempConfigPath = await getTsconfigPath(root, typecheck);
7500
+ const args = ["--noEmit", "--pretty", "false", "-p", this.tempConfigPath];
7501
+ if (watch)
7502
+ args.push("--watch");
7503
+ if (typecheck.allowJs)
7504
+ args.push("--allowJs", "--checkJs");
7505
+ let output = "";
7506
+ const child = execa(typecheck.checker, args, {
7507
+ cwd: root,
7508
+ stdout: "pipe",
7509
+ reject: false
7510
+ });
7511
+ this.process = child;
7512
+ await ((_a = this._onParseStart) == null ? void 0 : _a.call(this));
7513
+ let rerunTriggered = false;
7514
+ (_b = child.stdout) == null ? void 0 : _b.on("data", (chunk) => {
7515
+ var _a2;
7516
+ output += chunk;
7517
+ if (!watch)
7518
+ return;
7519
+ if (output.includes("File change detected") && !rerunTriggered) {
7520
+ (_a2 = this._onWatcherRerun) == null ? void 0 : _a2.call(this);
7521
+ this._result.sourceErrors = [];
7522
+ this._result.files = [];
7523
+ this._tests = null;
7524
+ rerunTriggered = true;
7525
+ }
7526
+ if (/Found \w+ errors*. Watching for/.test(output)) {
7527
+ rerunTriggered = false;
7528
+ this.prepareResults(output).then((result) => {
7529
+ var _a3;
7530
+ this._result = result;
7531
+ (_a3 = this._onParseEnd) == null ? void 0 : _a3.call(this, result);
7532
+ });
7533
+ output = "";
7534
+ }
7535
+ });
7536
+ if (!watch) {
7537
+ await child;
7538
+ this._result = await this.prepareResults(output);
7539
+ await ((_c = this._onParseEnd) == null ? void 0 : _c.call(this, this._result));
7540
+ await this.clear();
7541
+ }
7542
+ }
7543
+ getResult() {
7544
+ return this._result;
7545
+ }
7546
+ getTestFiles() {
7547
+ return Object.values(this._tests || {}).map(({ file }) => ({
7548
+ ...file,
7549
+ result: void 0
7550
+ }));
7551
+ }
7552
+ }
7553
+
7127
7554
  const workerPath = url.pathToFileURL(resolve(distDir, "./worker.js")).href;
7128
7555
  const loaderPath = url.pathToFileURL(resolve(distDir, "./loader.js")).href;
7129
7556
  const suppressLoaderWarningsPath = resolve(rootDir, "./suppress-warnings.cjs");
@@ -7132,7 +7559,7 @@ function createPool(ctx) {
7132
7559
  const threadsCount = ctx.config.watch ? Math.max(Math.floor(cpus().length / 2), 1) : Math.max(cpus().length - 1, 1);
7133
7560
  const maxThreads = ctx.config.maxThreads ?? threadsCount;
7134
7561
  const minThreads = ctx.config.minThreads ?? threadsCount;
7135
- const conditions = ((_a = ctx.server.config.resolve.conditions) == null ? void 0 : _a.flatMap((c) => ["-C", c])) || [];
7562
+ const conditions = ((_a = ctx.server.config.resolve.conditions) == null ? void 0 : _a.flatMap((c) => ["--conditions", c])) || [];
7136
7563
  const options = {
7137
7564
  filename: workerPath,
7138
7565
  useAtomics: false,
@@ -7355,7 +7782,7 @@ function renderSnapshotSummary(rootDir, snapshots) {
7355
7782
  }
7356
7783
  return summary;
7357
7784
  }
7358
- function getStateString(tasks, name = "tests") {
7785
+ function getStateString(tasks, name = "tests", showTotal = true) {
7359
7786
  if (tasks.length === 0)
7360
7787
  return picocolors.exports.dim(`no ${name}`);
7361
7788
  const passed = tasks.filter((i) => {
@@ -7373,7 +7800,7 @@ function getStateString(tasks, name = "tests") {
7373
7800
  passed.length ? picocolors.exports.bold(picocolors.exports.green(`${passed.length} passed`)) : null,
7374
7801
  skipped2.length ? picocolors.exports.yellow(`${skipped2.length} skipped`) : null,
7375
7802
  todo.length ? picocolors.exports.gray(`${todo.length} todo`) : null
7376
- ].filter(Boolean).join(picocolors.exports.dim(" | ")) + picocolors.exports.gray(` (${tasks.length})`);
7803
+ ].filter(Boolean).join(picocolors.exports.dim(" | ")) + (showTotal ? picocolors.exports.gray(` (${tasks.length})`) : "");
7377
7804
  }
7378
7805
  function getStateSymbol(task) {
7379
7806
  if (task.mode === "skip" || task.mode === "todo")
@@ -7436,7 +7863,7 @@ const WAIT_FOR_CHANGE_PASS = `
7436
7863
  ${picocolors.exports.bold(picocolors.exports.inverse(picocolors.exports.green(" PASS ")))}${picocolors.exports.green(" Waiting for file changes...")}`;
7437
7864
  const WAIT_FOR_CHANGE_FAIL = `
7438
7865
  ${picocolors.exports.bold(picocolors.exports.inverse(picocolors.exports.red(" FAIL ")))}${picocolors.exports.red(" Tests failed. Watching for file changes...")}`;
7439
- const DURATION_LONG$1 = 300;
7866
+ const DURATION_LONG$2 = 300;
7440
7867
  const LAST_RUN_LOG_TIMEOUT = 1500;
7441
7868
  class BaseReporter {
7442
7869
  constructor() {
@@ -7467,7 +7894,7 @@ class BaseReporter {
7467
7894
  if (errors.length) {
7468
7895
  if (!this.ctx.config.dangerouslyIgnoreUnhandledErrors)
7469
7896
  process.exitCode = 1;
7470
- this.ctx.logger.printUnhandledErrors(errors);
7897
+ await this.ctx.logger.printUnhandledErrors(errors);
7471
7898
  }
7472
7899
  }
7473
7900
  onTaskUpdate(packs) {
@@ -7491,7 +7918,7 @@ class BaseReporter {
7491
7918
  state += ` ${picocolors.exports.dim("|")} ${picocolors.exports.yellow(`${skipped.length} skipped`)}`;
7492
7919
  let suffix = picocolors.exports.dim(" (") + state + picocolors.exports.dim(")");
7493
7920
  if (task.result.duration) {
7494
- const color = task.result.duration > DURATION_LONG$1 ? picocolors.exports.yellow : picocolors.exports.gray;
7921
+ const color = task.result.duration > DURATION_LONG$2 ? picocolors.exports.yellow : picocolors.exports.gray;
7495
7922
  suffix += color(` ${Math.round(task.result.duration)}${picocolors.exports.dim("ms")}`);
7496
7923
  }
7497
7924
  if (this.ctx.config.logHeapUsage && task.result.heap != null)
@@ -7504,17 +7931,17 @@ class BaseReporter {
7504
7931
  }
7505
7932
  }
7506
7933
  }
7507
- async onWatcherStart() {
7934
+ async onWatcherStart(files = this.ctx.state.getFiles(), errors = this.ctx.state.getUnhandledErrors()) {
7508
7935
  this.resetLastRunLog();
7509
- const files = this.ctx.state.getFiles();
7510
- const errors = this.ctx.state.getUnhandledErrors();
7511
7936
  const failed = errors.length > 0 || hasFailed(files);
7512
7937
  const failedSnap = hasFailedSnapshot(files);
7513
7938
  if (failed)
7514
7939
  this.ctx.logger.log(WAIT_FOR_CHANGE_FAIL);
7515
7940
  else
7516
7941
  this.ctx.logger.log(WAIT_FOR_CHANGE_PASS);
7517
- const hints = [HELP_HINT];
7942
+ const hints = [];
7943
+ if (this.mode !== "typecheck")
7944
+ hints.push(HELP_HINT);
7518
7945
  if (failedSnap)
7519
7946
  hints.unshift(HELP_UPDATE_SNAP);
7520
7947
  else
@@ -7556,14 +7983,14 @@ class BaseReporter {
7556
7983
  const BADGE = picocolors.exports.inverse(picocolors.exports.bold(picocolors.exports.blue(" RERUN ")));
7557
7984
  const TRIGGER = trigger ? picocolors.exports.dim(` ${this.relative(trigger)}`) : "";
7558
7985
  if (files.length > 1) {
7559
- this.ctx.logger.clearScreen(`
7986
+ this.ctx.logger.clearFullScreen(`
7560
7987
  ${BADGE}${TRIGGER}
7561
- `, true);
7988
+ `);
7562
7989
  this._lastRunCount = 0;
7563
7990
  } else if (files.length === 1) {
7564
7991
  const rerun = this._filesInWatchMode.get(files[0]) ?? 1;
7565
7992
  this._lastRunCount = rerun;
7566
- this.ctx.logger.clearScreen(`
7993
+ this.ctx.logger.clearFullScreen(`
7567
7994
  ${BADGE}${TRIGGER} ${picocolors.exports.blue(`x${rerun}`)}
7568
7995
  `);
7569
7996
  }
@@ -7600,7 +8027,7 @@ ${BADGE}${TRIGGER} ${picocolors.exports.blue(`x${rerun}`)}
7600
8027
  await this.reportTestSummary(files);
7601
8028
  }
7602
8029
  async reportTestSummary(files) {
7603
- const tests = getTests(files);
8030
+ const tests = this.mode === "typecheck" ? getTypecheckTests(files) : getTests(files);
7604
8031
  const logger = this.ctx.logger;
7605
8032
  const executionTime = this.end - this.start;
7606
8033
  const collectTime = files.reduce((acc, test) => acc + Math.max(0, test.collectDuration || 0), 0);
@@ -7611,7 +8038,7 @@ ${BADGE}${TRIGGER} ${picocolors.exports.blue(`x${rerun}`)}
7611
8038
  }, 0);
7612
8039
  const transformTime = Array.from(this.ctx.vitenode.fetchCache.values()).reduce((a, b) => a + ((b == null ? void 0 : b.duration) || 0), 0);
7613
8040
  const threadTime = collectTime + testsTime + setupTime;
7614
- const padTitle = (str) => picocolors.exports.dim(`${str.padStart(10)} `);
8041
+ const padTitle = (str) => picocolors.exports.dim(`${str.padStart(11)} `);
7615
8042
  const time = (time2) => {
7616
8043
  if (time2 > 1e3)
7617
8044
  return `${(time2 / 1e3).toFixed(2)}s`;
@@ -7627,9 +8054,15 @@ ${BADGE}${TRIGGER} ${picocolors.exports.blue(`x${rerun}`)}
7627
8054
  }
7628
8055
  logger.log(padTitle("Test Files"), getStateString(files));
7629
8056
  logger.log(padTitle("Tests"), getStateString(tests));
8057
+ if (this.mode === "typecheck") {
8058
+ const typechecks = getTests(files).filter((t) => t.type === "typecheck");
8059
+ logger.log(padTitle("Type Errors"), getStateString(typechecks, "errors", false));
8060
+ }
7630
8061
  logger.log(padTitle("Start at"), formatTimeString(this._timeStart));
7631
8062
  if (this.watchFilters)
7632
8063
  logger.log(padTitle("Duration"), time(threadTime));
8064
+ else if (this.mode === "typecheck")
8065
+ logger.log(padTitle("Duration"), time(executionTime));
7633
8066
  else
7634
8067
  logger.log(padTitle("Duration"), time(executionTime) + picocolors.exports.dim(` (transform ${time(transformTime)}, setup ${time(setupTime)}, collect ${time(collectTime)}, tests ${time(testsTime)})`));
7635
8068
  logger.log();
@@ -7656,7 +8089,8 @@ ${BADGE}${TRIGGER} ${picocolors.exports.blue(`x${rerun}`)}
7656
8089
  await this.printTaskErrors(failedSuites, errorDivider);
7657
8090
  }
7658
8091
  if (failedTests.length) {
7659
- logger.error(picocolors.exports.red(divider(picocolors.exports.bold(picocolors.exports.inverse(` Failed Tests ${failedTests.length} `)))));
8092
+ const message = this.mode === "typecheck" ? "Type Errors" : "Failed Tests";
8093
+ logger.error(picocolors.exports.red(divider(picocolors.exports.bold(picocolors.exports.inverse(` ${message} ${failedTests.length} `)))));
7660
8094
  logger.error();
7661
8095
  await this.printTaskErrors(failedTests, errorDivider);
7662
8096
  }
@@ -7674,6 +8108,8 @@ ${picocolors.exports.cyan(picocolors.exports.inverse(picocolors.exports.bold(" B
7674
8108
  `);
7675
8109
  for (const bench of topBenchs) {
7676
8110
  const group = bench.suite;
8111
+ if (!group)
8112
+ continue;
7677
8113
  const groupName = getFullName(group);
7678
8114
  logger.log(` ${bench.name}${picocolors.exports.dim(` - ${groupName}`)}`);
7679
8115
  const siblings = group.tasks.filter((i) => {
@@ -7724,9 +8160,9 @@ ${picocolors.exports.cyan(picocolors.exports.inverse(picocolors.exports.bold(" B
7724
8160
  }
7725
8161
  }
7726
8162
 
7727
- const DURATION_LONG = 300;
7728
- const outputMap = /* @__PURE__ */ new WeakMap();
7729
- function formatFilepath(path) {
8163
+ const DURATION_LONG$1 = 300;
8164
+ const outputMap$1 = /* @__PURE__ */ new WeakMap();
8165
+ function formatFilepath$1(path) {
7730
8166
  const lastSlash = Math.max(path.lastIndexOf("/") + 1, 0);
7731
8167
  const basename = path.slice(lastSlash);
7732
8168
  let firstDot = basename.indexOf(".");
@@ -7735,7 +8171,7 @@ function formatFilepath(path) {
7735
8171
  firstDot += lastSlash;
7736
8172
  return picocolors.exports.dim(path.slice(0, lastSlash)) + path.slice(lastSlash, firstDot) + picocolors.exports.dim(path.slice(firstDot));
7737
8173
  }
7738
- function formatNumber(number) {
8174
+ function formatNumber$1(number) {
7739
8175
  const res = String(number.toFixed(number < 100 ? 4 : 2)).split(".");
7740
8176
  return res[0].replace(/(?=(?:\d{3})+$)(?!\b)/g, ",") + (res[1] ? `.${res[1]}` : "");
7741
8177
  }
@@ -7746,16 +8182,16 @@ function renderHookState(task, hookName, level = 0) {
7746
8182
  return `${" ".repeat(level)} ${getHookStateSymbol(task, hookName)} ${picocolors.exports.dim(`[ ${hookName} ]`)}`;
7747
8183
  return "";
7748
8184
  }
7749
- function renderBenchmarkItems(result) {
8185
+ function renderBenchmarkItems$1(result) {
7750
8186
  return [
7751
8187
  result.name,
7752
- formatNumber(result.hz || 0),
7753
- formatNumber(result.p99 || 0),
8188
+ formatNumber$1(result.hz || 0),
8189
+ formatNumber$1(result.p99 || 0),
7754
8190
  `\xB1${result.rme.toFixed(2)}%`,
7755
8191
  result.samples.length.toString()
7756
8192
  ];
7757
8193
  }
7758
- function renderBenchmark(task, tasks) {
8194
+ function renderBenchmark$1(task, tasks) {
7759
8195
  var _a;
7760
8196
  const result = (_a = task.result) == null ? void 0 : _a.benchmark;
7761
8197
  if (!result)
@@ -7764,8 +8200,8 @@ function renderBenchmark(task, tasks) {
7764
8200
  var _a2;
7765
8201
  return i.type === "benchmark" ? (_a2 = i.result) == null ? void 0 : _a2.benchmark : void 0;
7766
8202
  }).filter(notNullish);
7767
- const allItems = benchs.map(renderBenchmarkItems);
7768
- const items = renderBenchmarkItems(result);
8203
+ const allItems = benchs.map(renderBenchmarkItems$1);
8204
+ const items = renderBenchmarkItems$1(result);
7769
8205
  const padded = items.map((i, idx) => {
7770
8206
  const width = Math.max(...allItems.map((i2) => i2[idx].length));
7771
8207
  return idx ? i.padStart(width, " ") : i.padEnd(width, " ");
@@ -7780,7 +8216,7 @@ function renderBenchmark(task, tasks) {
7780
8216
  result.rank === 1 ? picocolors.exports.bold(picocolors.exports.green(" fastest")) : result.rank === benchs.length && benchs.length > 2 ? picocolors.exports.bold(picocolors.exports.gray(" slowest")) : ""
7781
8217
  ].join("");
7782
8218
  }
7783
- function renderTree(tasks, options, level = 0) {
8219
+ function renderTree$1(tasks, options, level = 0) {
7784
8220
  var _a, _b, _c, _d, _e, _f;
7785
8221
  let output = [];
7786
8222
  for (const task of tasks) {
@@ -7788,24 +8224,26 @@ function renderTree(tasks, options, level = 0) {
7788
8224
  const prefix = ` ${getStateSymbol(task)} `;
7789
8225
  if (task.type === "test" && ((_a = task.result) == null ? void 0 : _a.retryCount) && task.result.retryCount > 1)
7790
8226
  suffix += picocolors.exports.yellow(` (retry x${task.result.retryCount})`);
7791
- if (task.type === "suite")
7792
- suffix += picocolors.exports.dim(` (${getTests(task).length})`);
8227
+ if (task.type === "suite" && !isTypecheckTest(task)) {
8228
+ const tests = options.mode === "typecheck" ? getTypecheckTests(task) : getTests(task);
8229
+ suffix += picocolors.exports.dim(` (${tests.length})`);
8230
+ }
7793
8231
  if (task.mode === "skip" || task.mode === "todo")
7794
8232
  suffix += ` ${picocolors.exports.dim(picocolors.exports.gray("[skipped]"))}`;
7795
8233
  if (((_b = task.result) == null ? void 0 : _b.duration) != null) {
7796
- if (task.result.duration > DURATION_LONG)
8234
+ if (task.result.duration > DURATION_LONG$1)
7797
8235
  suffix += picocolors.exports.yellow(` ${Math.round(task.result.duration)}${picocolors.exports.dim("ms")}`);
7798
8236
  }
7799
8237
  if (options.showHeap && ((_c = task.result) == null ? void 0 : _c.heap) != null)
7800
8238
  suffix += picocolors.exports.magenta(` ${Math.floor(task.result.heap / 1024 / 1024)} MB heap used`);
7801
8239
  let name = task.name;
7802
8240
  if (level === 0)
7803
- name = formatFilepath(name);
8241
+ name = formatFilepath$1(name);
7804
8242
  const padding = " ".repeat(level);
7805
- const body = task.type === "benchmark" ? renderBenchmark(task, tasks) : name;
8243
+ const body = task.type === "benchmark" ? renderBenchmark$1(task, tasks) : name;
7806
8244
  output.push(padding + prefix + body + suffix);
7807
- if (((_d = task.result) == null ? void 0 : _d.state) !== "pass" && outputMap.get(task) != null) {
7808
- let data = outputMap.get(task);
8245
+ if (((_d = task.result) == null ? void 0 : _d.state) !== "pass" && outputMap$1.get(task) != null) {
8246
+ let data = outputMap$1.get(task);
7809
8247
  if (typeof data === "string") {
7810
8248
  data = stripAnsi(data.trim().split("\n").filter(Boolean).pop());
7811
8249
  if (data === "")
@@ -7820,7 +8258,7 @@ function renderTree(tasks, options, level = 0) {
7820
8258
  output = output.concat(renderHookState(task, "beforeEach", level + 1));
7821
8259
  if (task.type === "suite" && task.tasks.length > 0) {
7822
8260
  if (((_e = task.result) == null ? void 0 : _e.state) === "fail" || ((_f = task.result) == null ? void 0 : _f.state) === "run" || options.renderSucceed)
7823
- output = output.concat(renderTree(task.tasks, options, level + 1));
8261
+ output = output.concat(renderTree$1(task.tasks, options, level + 1));
7824
8262
  }
7825
8263
  output = output.concat(renderHookState(task, "afterAll", level + 1));
7826
8264
  output = output.concat(renderHookState(task, "afterEach", level + 1));
@@ -7832,7 +8270,7 @@ const createListRenderer = (_tasks, options) => {
7832
8270
  let timer;
7833
8271
  const log = options.logger.logUpdate;
7834
8272
  function update() {
7835
- log(renderTree(tasks, options));
8273
+ log(renderTree$1(tasks, options));
7836
8274
  }
7837
8275
  return {
7838
8276
  start() {
@@ -7852,7 +8290,7 @@ const createListRenderer = (_tasks, options) => {
7852
8290
  timer = void 0;
7853
8291
  }
7854
8292
  log.clear();
7855
- options.logger.log(renderTree(tasks, options));
8293
+ options.logger.log(renderTree$1(tasks, options));
7856
8294
  return this;
7857
8295
  },
7858
8296
  clear() {
@@ -7876,11 +8314,13 @@ class DefaultReporter extends BaseReporter {
7876
8314
  await super.reportSummary(files);
7877
8315
  super.onWatcherStart();
7878
8316
  }
7879
- onCollected() {
8317
+ onCollected(files) {
7880
8318
  if (this.isTTY) {
7881
8319
  this.rendererOptions.logger = this.ctx.logger;
7882
8320
  this.rendererOptions.showHeap = this.ctx.config.logHeapUsage;
7883
- const files = this.ctx.state.getFiles(this.watchFilters);
8321
+ this.rendererOptions.mode = this.mode;
8322
+ if (!files)
8323
+ files = this.ctx.state.getFiles(this.watchFilters);
7884
8324
  if (!this.renderer)
7885
8325
  this.renderer = createListRenderer(files, this.rendererOptions).start();
7886
8326
  else
@@ -7892,9 +8332,9 @@ class DefaultReporter extends BaseReporter {
7892
8332
  this.ctx.logger.log();
7893
8333
  await super.onFinished(files, errors);
7894
8334
  }
7895
- async onWatcherStart() {
8335
+ async onWatcherStart(files = this.ctx.state.getFiles(), errors = this.ctx.state.getUnhandledErrors()) {
7896
8336
  await this.stopListRender();
7897
- await super.onWatcherStart();
8337
+ await super.onWatcherStart(files, errors);
7898
8338
  }
7899
8339
  async stopListRender() {
7900
8340
  var _a;
@@ -8142,7 +8582,6 @@ class JsonReporter$1 {
8142
8582
  if (!error)
8143
8583
  return;
8144
8584
  const stack = parseStacktrace(error);
8145
- await interpretSourcePos(stack, this.ctx);
8146
8585
  const frame = stack[stack.length - 1];
8147
8586
  if (!frame)
8148
8587
  return;
@@ -8503,8 +8942,215 @@ class JsonReporter {
8503
8942
  }
8504
8943
  }
8505
8944
 
8945
+ const DURATION_LONG = 300;
8946
+ const outputMap = /* @__PURE__ */ new WeakMap();
8947
+ function formatFilepath(path) {
8948
+ const lastSlash = Math.max(path.lastIndexOf("/") + 1, 0);
8949
+ const basename = path.slice(lastSlash);
8950
+ let firstDot = basename.indexOf(".");
8951
+ if (firstDot < 0)
8952
+ firstDot = basename.length;
8953
+ firstDot += lastSlash;
8954
+ return picocolors.exports.dim(path.slice(0, lastSlash)) + path.slice(lastSlash, firstDot) + picocolors.exports.dim(path.slice(firstDot));
8955
+ }
8956
+ function formatNumber(number) {
8957
+ const res = String(number.toFixed(number < 100 ? 4 : 2)).split(".");
8958
+ return res[0].replace(/(?=(?:\d{3})+$)(?!\b)/g, ",") + (res[1] ? `.${res[1]}` : "");
8959
+ }
8960
+ const tableHead = ["name", "hz", "min", "max", "mean", "p75", "p99", "p995", "p999", "rme", "samples"];
8961
+ function renderTableHead(tasks) {
8962
+ const benchs = tasks.map((i) => {
8963
+ var _a;
8964
+ return i.type === "benchmark" ? (_a = i.result) == null ? void 0 : _a.benchmark : void 0;
8965
+ }).filter(notNullish);
8966
+ const allItems = benchs.map(renderBenchmarkItems).concat([tableHead]);
8967
+ return `${" ".repeat(3)}${tableHead.map((i, idx) => {
8968
+ const width = Math.max(...allItems.map((i2) => i2[idx].length));
8969
+ return idx ? i.padStart(width, " ") : i.padEnd(width, " ");
8970
+ }).map(picocolors.exports.bold).join(" ")}`;
8971
+ }
8972
+ function renderBenchmarkItems(result) {
8973
+ return [
8974
+ result.name,
8975
+ formatNumber(result.hz || 0),
8976
+ formatNumber(result.min || 0),
8977
+ formatNumber(result.max || 0),
8978
+ formatNumber(result.mean || 0),
8979
+ formatNumber(result.p75 || 0),
8980
+ formatNumber(result.p99 || 0),
8981
+ formatNumber(result.p995 || 0),
8982
+ formatNumber(result.p999 || 0),
8983
+ `\xB1${(result.rme || 0).toFixed(2)}%`,
8984
+ result.samples.length.toString()
8985
+ ];
8986
+ }
8987
+ function renderBenchmark(task, tasks) {
8988
+ var _a;
8989
+ const result = (_a = task.result) == null ? void 0 : _a.benchmark;
8990
+ if (!result)
8991
+ return task.name;
8992
+ const benchs = tasks.map((i) => {
8993
+ var _a2;
8994
+ return i.type === "benchmark" ? (_a2 = i.result) == null ? void 0 : _a2.benchmark : void 0;
8995
+ }).filter(notNullish);
8996
+ const allItems = benchs.map(renderBenchmarkItems).concat([tableHead]);
8997
+ const items = renderBenchmarkItems(result);
8998
+ const padded = items.map((i, idx) => {
8999
+ const width = Math.max(...allItems.map((i2) => i2[idx].length));
9000
+ return idx ? i.padStart(width, " ") : i.padEnd(width, " ");
9001
+ });
9002
+ return [
9003
+ padded[0],
9004
+ picocolors.exports.blue(padded[1]),
9005
+ picocolors.exports.cyan(padded[2]),
9006
+ picocolors.exports.cyan(padded[3]),
9007
+ picocolors.exports.cyan(padded[4]),
9008
+ picocolors.exports.cyan(padded[5]),
9009
+ picocolors.exports.cyan(padded[6]),
9010
+ picocolors.exports.cyan(padded[7]),
9011
+ picocolors.exports.cyan(padded[8]),
9012
+ picocolors.exports.dim(padded[9]),
9013
+ picocolors.exports.dim(padded[10]),
9014
+ result.rank === 1 ? picocolors.exports.bold(picocolors.exports.green(" fastest")) : result.rank === benchs.length && benchs.length > 2 ? picocolors.exports.bold(picocolors.exports.gray(" slowest")) : ""
9015
+ ].join(" ");
9016
+ }
9017
+ function renderTree(tasks, options, level = 0) {
9018
+ var _a, _b, _c, _d;
9019
+ let output = [];
9020
+ let idx = 0;
9021
+ for (const task of tasks) {
9022
+ const padding = " ".repeat(level ? 1 : 0);
9023
+ let prefix = "";
9024
+ if (idx === 0 && task.type === "benchmark")
9025
+ prefix += `${renderTableHead(tasks)}
9026
+ ${padding}`;
9027
+ prefix += ` ${getStateSymbol(task)} `;
9028
+ let suffix = "";
9029
+ if (task.type === "suite")
9030
+ suffix += picocolors.exports.dim(` (${getTests(task).length})`);
9031
+ if (task.mode === "skip" || task.mode === "todo")
9032
+ suffix += ` ${picocolors.exports.dim(picocolors.exports.gray("[skipped]"))}`;
9033
+ if (((_a = task.result) == null ? void 0 : _a.duration) != null) {
9034
+ if (task.result.duration > DURATION_LONG)
9035
+ suffix += picocolors.exports.yellow(` ${Math.round(task.result.duration)}${picocolors.exports.dim("ms")}`);
9036
+ }
9037
+ if (options.showHeap && ((_b = task.result) == null ? void 0 : _b.heap) != null)
9038
+ suffix += picocolors.exports.magenta(` ${Math.floor(task.result.heap / 1024 / 1024)} MB heap used`);
9039
+ let name = task.name;
9040
+ if (level === 0)
9041
+ name = formatFilepath(name);
9042
+ const body = task.type === "benchmark" ? renderBenchmark(task, tasks) : name;
9043
+ output.push(padding + prefix + body + suffix);
9044
+ if (((_c = task.result) == null ? void 0 : _c.state) !== "pass" && outputMap.get(task) != null) {
9045
+ let data = outputMap.get(task);
9046
+ if (typeof data === "string") {
9047
+ data = stripAnsi(data.trim().split("\n").filter(Boolean).pop());
9048
+ if (data === "")
9049
+ data = void 0;
9050
+ }
9051
+ if (data != null) {
9052
+ const out = `${" ".repeat(level)}${F_RIGHT} ${data}`;
9053
+ output.push(` ${picocolors.exports.gray(cliTruncate(out, getCols(-3)))}`);
9054
+ }
9055
+ }
9056
+ if (task.type === "suite" && task.tasks.length > 0) {
9057
+ if ((_d = task.result) == null ? void 0 : _d.state)
9058
+ output = output.concat(renderTree(task.tasks, options, level + 1));
9059
+ }
9060
+ idx++;
9061
+ }
9062
+ return output.filter(Boolean).join("\n");
9063
+ }
9064
+ const createTableRenderer = (_tasks, options) => {
9065
+ let tasks = _tasks;
9066
+ let timer;
9067
+ const log = options.logger.logUpdate;
9068
+ function update() {
9069
+ log(renderTree(tasks, options));
9070
+ }
9071
+ return {
9072
+ start() {
9073
+ if (timer)
9074
+ return this;
9075
+ timer = safeSetInterval(update, 200);
9076
+ return this;
9077
+ },
9078
+ update(_tasks2) {
9079
+ tasks = _tasks2;
9080
+ update();
9081
+ return this;
9082
+ },
9083
+ async stop() {
9084
+ if (timer) {
9085
+ safeClearInterval(timer);
9086
+ timer = void 0;
9087
+ }
9088
+ log.clear();
9089
+ options.logger.log(renderTree(tasks, options));
9090
+ return this;
9091
+ },
9092
+ clear() {
9093
+ log.clear();
9094
+ }
9095
+ };
9096
+ };
9097
+
9098
+ class TableReporter extends BaseReporter {
9099
+ constructor() {
9100
+ super(...arguments);
9101
+ this.rendererOptions = {};
9102
+ }
9103
+ async onTestRemoved(trigger) {
9104
+ await this.stopListRender();
9105
+ this.ctx.logger.clearScreen(picocolors.exports.yellow("Test removed...") + (trigger ? picocolors.exports.dim(` [ ${this.relative(trigger)} ]
9106
+ `) : ""), true);
9107
+ const files = this.ctx.state.getFiles(this.watchFilters);
9108
+ createTableRenderer(files, this.rendererOptions).stop();
9109
+ this.ctx.logger.log();
9110
+ await super.reportSummary(files);
9111
+ super.onWatcherStart();
9112
+ }
9113
+ onCollected() {
9114
+ if (this.isTTY) {
9115
+ this.rendererOptions.logger = this.ctx.logger;
9116
+ this.rendererOptions.showHeap = this.ctx.config.logHeapUsage;
9117
+ const files = this.ctx.state.getFiles(this.watchFilters);
9118
+ if (!this.renderer)
9119
+ this.renderer = createTableRenderer(files, this.rendererOptions).start();
9120
+ else
9121
+ this.renderer.update(files);
9122
+ }
9123
+ }
9124
+ async onFinished(files = this.ctx.state.getFiles(), errors = this.ctx.state.getUnhandledErrors()) {
9125
+ await this.stopListRender();
9126
+ this.ctx.logger.log();
9127
+ await super.onFinished(files, errors);
9128
+ }
9129
+ async onWatcherStart() {
9130
+ await this.stopListRender();
9131
+ await super.onWatcherStart();
9132
+ }
9133
+ async stopListRender() {
9134
+ var _a;
9135
+ await ((_a = this.renderer) == null ? void 0 : _a.stop());
9136
+ this.renderer = void 0;
9137
+ }
9138
+ async onWatcherRerun(files, trigger) {
9139
+ await this.stopListRender();
9140
+ await super.onWatcherRerun(files, trigger);
9141
+ }
9142
+ onUserConsoleLog(log) {
9143
+ var _a;
9144
+ if (!this.shouldLog(log))
9145
+ return;
9146
+ (_a = this.renderer) == null ? void 0 : _a.clear();
9147
+ super.onUserConsoleLog(log);
9148
+ }
9149
+ }
9150
+
8506
9151
  const BenchmarkReportsMap = {
8507
- default: VerboseReporter,
9152
+ default: TableReporter,
9153
+ verbose: VerboseReporter,
8508
9154
  json: JsonReporter
8509
9155
  };
8510
9156
 
@@ -8739,7 +9385,12 @@ const config = {
8739
9385
  coverage: coverageConfigDefaults,
8740
9386
  fakeTimers: fakeTimersDefaults,
8741
9387
  maxConcurrency: 5,
8742
- dangerouslyIgnoreUnhandledErrors: false
9388
+ dangerouslyIgnoreUnhandledErrors: false,
9389
+ typecheck: {
9390
+ checker: "tsc",
9391
+ include: ["**/*.{test,spec}-d.{ts,js}"],
9392
+ exclude: defaultExclude
9393
+ }
8743
9394
  };
8744
9395
  const configDefaults = Object.freeze(config);
8745
9396
 
@@ -9043,6 +9694,14 @@ function resolveConfig(mode, options, viteConfig) {
9043
9694
  resolved.sequence ?? (resolved.sequence = {});
9044
9695
  resolved.sequence.sequencer = resolved.sequence.shuffle ? RandomSequencer : BaseSequencer;
9045
9696
  }
9697
+ resolved.typecheck = {
9698
+ ...configDefaults.typecheck,
9699
+ ...resolved.typecheck
9700
+ };
9701
+ if (mode === "typecheck") {
9702
+ resolved.include = resolved.typecheck.include;
9703
+ resolved.exclude = resolved.typecheck.exclude;
9704
+ }
9046
9705
  return resolved;
9047
9706
  }
9048
9707
 
@@ -9532,7 +10191,7 @@ createLogUpdate(process$1.stdout);
9532
10191
 
9533
10192
  createLogUpdate(process$1.stderr);
9534
10193
 
9535
- var version = "0.24.5";
10194
+ var version = "0.25.0";
9536
10195
 
9537
10196
  function fileFromParsedStack(stack) {
9538
10197
  var _a, _b;
@@ -9557,23 +10216,26 @@ async function printError(error, ctx, options = {}) {
9557
10216
  };
9558
10217
  }
9559
10218
  const stacks = parseStacktrace(e, fullStack);
9560
- await interpretSourcePos(stacks, ctx);
9561
- const nearest = stacks.find(
10219
+ const nearest = error instanceof TypeCheckError ? error.stacks[0] : stacks.find(
9562
10220
  (stack) => ctx.server.moduleGraph.getModuleById(stack.file) && existsSync(stack.file)
9563
10221
  );
9564
10222
  const errorProperties = getErrorProperties(e);
9565
10223
  if (type)
9566
10224
  printErrorType(type, ctx);
9567
10225
  printErrorMessage(e, ctx.logger);
9568
- printStack(ctx, stacks, nearest, errorProperties, (s, pos) => {
9569
- if (showCodeFrame && s === nearest && nearest) {
9570
- const file = fileFromParsedStack(nearest);
9571
- if (existsSync(file)) {
9572
- const sourceCode = readFileSync(file, "utf-8");
9573
- ctx.logger.log(picocolors.exports.yellow(generateCodeFrame(sourceCode, 4, pos)));
10226
+ if (e.frame) {
10227
+ ctx.logger.error(picocolors.exports.yellow(e.frame));
10228
+ } else {
10229
+ printStack(ctx, stacks, nearest, errorProperties, (s, pos) => {
10230
+ if (showCodeFrame && s === nearest && nearest) {
10231
+ const file = fileFromParsedStack(nearest);
10232
+ if (nearest.file === file || existsSync(file)) {
10233
+ const sourceCode = readFileSync(file, "utf-8");
10234
+ ctx.logger.error(picocolors.exports.yellow(generateCodeFrame(sourceCode, 4, pos)));
10235
+ }
9574
10236
  }
9575
- }
9576
- });
10237
+ });
10238
+ }
9577
10239
  if (e.cause && "name" in e.cause) {
9578
10240
  e.cause.name = `Caused by: ${e.cause.name}`;
9579
10241
  await printError(e.cause, ctx, { fullStack, showCodeFrame: false });
@@ -9590,7 +10252,7 @@ function printErrorType(type, ctx) {
9590
10252
  ctx.logger.error(`
9591
10253
  ${picocolors.exports.red(divider(picocolors.exports.bold(picocolors.exports.inverse(` ${type} `))))}`);
9592
10254
  }
9593
- const skipErrorProperties = [
10255
+ const skipErrorProperties = /* @__PURE__ */ new Set([
9594
10256
  "nameStr",
9595
10257
  "stack",
9596
10258
  "cause",
@@ -9602,13 +10264,13 @@ const skipErrorProperties = [
9602
10264
  "expected",
9603
10265
  ...Object.getOwnPropertyNames(Error.prototype),
9604
10266
  ...Object.getOwnPropertyNames(Object.prototype)
9605
- ];
10267
+ ]);
9606
10268
  function getErrorProperties(e) {
9607
10269
  const errorObject = /* @__PURE__ */ Object.create(null);
9608
10270
  if (e.name === "AssertionError")
9609
10271
  return errorObject;
9610
10272
  for (const key of Object.getOwnPropertyNames(e)) {
9611
- if (!skipErrorProperties.includes(key))
10273
+ if (!skipErrorProperties.has(key))
9612
10274
  errorObject[key] = e[key];
9613
10275
  }
9614
10276
  return errorObject;
@@ -9659,17 +10321,17 @@ function printStack(ctx, stack, highlight, errorProperties, onStack) {
9659
10321
  const color = frame === highlight ? picocolors.exports.yellow : picocolors.exports.gray;
9660
10322
  const file = fileFromParsedStack(frame);
9661
10323
  const path = relative(ctx.config.root, file);
9662
- logger.log(color(` ${picocolors.exports.dim(F_POINTER)} ${[frame.method, picocolors.exports.dim(`${path}:${pos.line}:${pos.column}`)].filter(Boolean).join(" ")}`));
10324
+ logger.error(color(` ${picocolors.exports.dim(F_POINTER)} ${[frame.method, picocolors.exports.dim(`${path}:${pos.line}:${pos.column}`)].filter(Boolean).join(" ")}`));
9663
10325
  onStack == null ? void 0 : onStack(frame, pos);
9664
10326
  if (frame.file in ctx.state.filesMap)
9665
10327
  break;
9666
10328
  }
9667
- logger.log();
10329
+ logger.error();
9668
10330
  const hasProperties = Object.keys(errorProperties).length > 0;
9669
10331
  if (hasProperties) {
9670
- logger.log(picocolors.exports.red(picocolors.exports.dim(divider())));
10332
+ logger.error(picocolors.exports.red(picocolors.exports.dim(divider())));
9671
10333
  const propertiesString = stringify$5(errorProperties, 10, { printBasicPrototype: false });
9672
- logger.log(picocolors.exports.red(picocolors.exports.bold("Serialized Error:")), picocolors.exports.gray(propertiesString));
10334
+ logger.error(picocolors.exports.red(picocolors.exports.bold("Serialized Error:")), picocolors.exports.gray(propertiesString));
9673
10335
  }
9674
10336
  }
9675
10337
  function generateCodeFrame(source, indent = 0, start = 0, end, range = 2) {
@@ -9733,6 +10395,13 @@ class Logger {
9733
10395
  this._clearScreen();
9734
10396
  this.console.warn(...args);
9735
10397
  }
10398
+ clearFullScreen(message) {
10399
+ if (this.ctx.server.config.clearScreen === false) {
10400
+ this.console.log(message);
10401
+ return;
10402
+ }
10403
+ this.console.log(`\x1Bc${message}`);
10404
+ }
9736
10405
  clearScreen(message, force = false) {
9737
10406
  if (this.ctx.server.config.clearScreen === false) {
9738
10407
  this.console.log(message);
@@ -9747,7 +10416,7 @@ class Logger {
9747
10416
  return;
9748
10417
  const log = this._clearScreenPending;
9749
10418
  this._clearScreenPending = void 0;
9750
- this.console.log(`\x1Bc${log}`);
10419
+ this.console.log(`\x1B[1;1H\x1B[J${log}`);
9751
10420
  }
9752
10421
  printError(err, fullStack = false, type) {
9753
10422
  return printError(err, this.ctx, {
@@ -9776,7 +10445,7 @@ No ${config.mode} files found, exiting with code 1`));
9776
10445
  }
9777
10446
  printBanner() {
9778
10447
  var _a, _b, _c;
9779
- this.clearScreen("", true);
10448
+ this.log();
9780
10449
  const versionTest = this.ctx.config.watch ? picocolors.exports.blue(`v${version}`) : picocolors.exports.cyan(`v${version}`);
9781
10450
  const mode = this.ctx.config.watch ? picocolors.exports.blue(" DEV ") : picocolors.exports.cyan(" RUN ");
9782
10451
  this.log(`${picocolors.exports.inverse(picocolors.exports.bold(mode))} ${versionTest} ${picocolors.exports.gray(this.ctx.config.root)}`);
@@ -9803,6 +10472,18 @@ This might cause false positive tests. Resolve unhandled errors to make sure you
9803
10472
  }));
9804
10473
  this.log(picocolors.exports.red(divider()));
9805
10474
  }
10475
+ async printSourceTypeErrors(errors) {
10476
+ const errorMessage = picocolors.exports.red(picocolors.exports.bold(
10477
+ `
10478
+ Vitest found ${errors.length} error${errors.length > 1 ? "s" : ""} not related to your test files.`
10479
+ ));
10480
+ this.log(picocolors.exports.red(divider(picocolors.exports.bold(picocolors.exports.inverse(" Source Errors ")))));
10481
+ this.log(errorMessage);
10482
+ await Promise.all(errors.map(async (err) => {
10483
+ await this.printError(err, true);
10484
+ }));
10485
+ this.log(picocolors.exports.red(divider()));
10486
+ }
9806
10487
  }
9807
10488
 
9808
10489
  const WATCHER_DEBOUNCE = 100;
@@ -9908,8 +10589,49 @@ class Vitest {
9908
10589
  this.configOverride || {}
9909
10590
  );
9910
10591
  }
10592
+ async typecheck(filters) {
10593
+ const testsFilesList = await this.globTestFiles(filters);
10594
+ const checker = new Typechecker(this, testsFilesList);
10595
+ this.typechecker = checker;
10596
+ checker.onParseEnd(async ({ files, sourceErrors }) => {
10597
+ await this.report("onCollected", files);
10598
+ if (!files.length)
10599
+ this.logger.printNoTestFound();
10600
+ else
10601
+ await this.report("onFinished", files);
10602
+ if (sourceErrors.length && !this.config.typecheck.ignoreSourceErrors) {
10603
+ process.exitCode = 1;
10604
+ await this.logger.printSourceTypeErrors(sourceErrors);
10605
+ }
10606
+ if (!files.length) {
10607
+ const exitCode = this.config.passWithNoTests ? process.exitCode ?? 0 : 1;
10608
+ process.exit(exitCode);
10609
+ }
10610
+ if (this.config.watch) {
10611
+ await this.report("onWatcherStart", files, [
10612
+ ...sourceErrors,
10613
+ ...this.state.getUnhandledErrors()
10614
+ ]);
10615
+ }
10616
+ });
10617
+ checker.onParseStart(async () => {
10618
+ await this.report("onInit", this);
10619
+ await this.report("onCollected", checker.getTestFiles());
10620
+ });
10621
+ checker.onWatcherRerun(async () => {
10622
+ await this.report("onWatcherRerun", testsFilesList, "File change detected. Triggering rerun.");
10623
+ await checker.collectTests();
10624
+ await this.report("onCollected", checker.getTestFiles());
10625
+ });
10626
+ await checker.collectTests();
10627
+ await checker.start();
10628
+ }
9911
10629
  async start(filters) {
9912
10630
  var _a;
10631
+ if (this.mode === "typecheck") {
10632
+ await this.typecheck(filters);
10633
+ return;
10634
+ }
9913
10635
  try {
9914
10636
  await this.initCoverageProvider();
9915
10637
  await ((_a = this.coverageProvider) == null ? void 0 : _a.clean(this.config.coverage.clean));
@@ -9956,7 +10678,7 @@ class Vitest {
9956
10678
  }
9957
10679
  async filterTestsBySource(tests) {
9958
10680
  if (this.config.changed && !this.config.related) {
9959
- const { VitestGit } = await import('./chunk-node-git.82174cfe.js');
10681
+ const { VitestGit } = await import('./chunk-node-git.af5c9d73.js');
9960
10682
  const vitestGit = new VitestGit(this.config.root);
9961
10683
  const related2 = await vitestGit.findChangedFiles({
9962
10684
  changedSince: this.config.changed
@@ -10146,11 +10868,12 @@ class Vitest {
10146
10868
  return rerun;
10147
10869
  }
10148
10870
  async close() {
10149
- var _a;
10871
+ var _a, _b;
10150
10872
  if (!this.closingPromise) {
10151
10873
  this.closingPromise = Promise.allSettled([
10152
10874
  (_a = this.pool) == null ? void 0 : _a.close(),
10153
- this.server.close()
10875
+ this.server.close(),
10876
+ (_b = this.typechecker) == null ? void 0 : _b.stop()
10154
10877
  ].filter(Boolean)).then((results) => {
10155
10878
  results.filter((r) => r.status === "rejected").forEach((err) => {
10156
10879
  this.logger.error("error during close", err.reason);
@@ -10432,7 +11155,7 @@ function getIndexStatus(code, from) {
10432
11155
  inString = char;
10433
11156
  }
10434
11157
  }
10435
- beforeChar = code[index];
11158
+ beforeChar = char;
10436
11159
  index++;
10437
11160
  }
10438
11161
  return {
@@ -10533,7 +11256,12 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
10533
11256
  },
10534
11257
  config(viteConfig) {
10535
11258
  var _a, _b, _c;
10536
- const preOptions = deepMerge({}, configDefaults, options, viteConfig.test ?? {});
11259
+ const preOptions = deepMerge(
11260
+ {},
11261
+ configDefaults,
11262
+ options,
11263
+ removeUndefinedValues(viteConfig.test ?? {})
11264
+ );
10537
11265
  preOptions.api = resolveApiConfig(preOptions);
10538
11266
  if (viteConfig.define) {
10539
11267
  delete viteConfig.define["import.meta.vitest"];
@@ -10629,7 +11357,7 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
10629
11357
  try {
10630
11358
  await ctx.setServer(options, server);
10631
11359
  if (options.api && options.watch)
10632
- (await import('./chunk-api-setup.629f8133.js')).setup(ctx);
11360
+ (await import('./chunk-api-setup.a13c5f9d.js')).setup(ctx);
10633
11361
  } catch (err) {
10634
11362
  ctx.logger.printError(err, true);
10635
11363
  process.exit(1);
@@ -10691,6 +11419,10 @@ function registerConsoleShortcuts(ctx) {
10691
11419
  if (ctx.runningPromise)
10692
11420
  return;
10693
11421
  const name = key == null ? void 0 : key.name;
11422
+ if (name === "q")
11423
+ return ctx.exit(true);
11424
+ if (ctx.mode === "typecheck")
11425
+ return;
10694
11426
  if (name === "h")
10695
11427
  return printShortcutsHelp();
10696
11428
  if (name === "u")
@@ -10703,8 +11435,6 @@ function registerConsoleShortcuts(ctx) {
10703
11435
  return inputNamePattern();
10704
11436
  if (name === "p")
10705
11437
  return inputFilePattern();
10706
- if (name === "q")
10707
- return ctx.exit(true);
10708
11438
  }
10709
11439
  async function keypressHandler(str, key) {
10710
11440
  await _keypressHandler(str, key);
@@ -10764,25 +11494,25 @@ async function startVitest(mode, cliFilters, options, viteOverrides) {
10764
11494
  const root = resolve(options.root || process.cwd());
10765
11495
  if (!await ensurePackageInstalled("vite", root)) {
10766
11496
  process.exitCode = 1;
10767
- return false;
11497
+ return;
10768
11498
  }
10769
11499
  if (typeof options.coverage === "boolean")
10770
11500
  options.coverage = { enabled: options.coverage };
10771
11501
  const ctx = await createVitest(mode, options, viteOverrides);
10772
- if (mode !== "benchmark" && ctx.config.coverage.enabled) {
11502
+ if (mode === "test" && ctx.config.coverage.enabled) {
10773
11503
  const provider = ctx.config.coverage.provider || "c8";
10774
11504
  if (typeof provider === "string") {
10775
11505
  const requiredPackages = CoverageProviderMap[provider];
10776
11506
  if (!await ensurePackageInstalled(requiredPackages, root)) {
10777
11507
  process.exitCode = 1;
10778
- return false;
11508
+ return ctx;
10779
11509
  }
10780
11510
  }
10781
11511
  }
10782
11512
  const environmentPackage = getEnvPackageName(ctx.config.environment);
10783
11513
  if (environmentPackage && !await ensurePackageInstalled(environmentPackage, root)) {
10784
11514
  process.exitCode = 1;
10785
- return false;
11515
+ return ctx;
10786
11516
  }
10787
11517
  if (process.stdin.isTTY && ctx.config.watch)
10788
11518
  registerConsoleShortcuts(ctx);
@@ -10799,13 +11529,12 @@ async function startVitest(mode, cliFilters, options, viteOverrides) {
10799
11529
  process.exitCode = 1;
10800
11530
  await ctx.logger.printError(e, true, "Unhandled Error");
10801
11531
  ctx.logger.error("\n\n");
10802
- return false;
10803
- }
10804
- if (!ctx.config.watch) {
10805
- await ctx.exit();
10806
- return !process.exitCode;
11532
+ return ctx;
10807
11533
  }
10808
- return true;
11534
+ if (ctx.config.watch)
11535
+ return ctx;
11536
+ await ctx.close();
11537
+ return ctx;
10809
11538
  }
10810
11539
 
10811
11540
  export { BaseSequencer as B, VitestPlugin as V, createVitest as c, divider as d, startVitest as s, version$1 as v };