vitest 0.0.99 → 0.0.103

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 CHANGED
@@ -193,13 +193,6 @@ Repository: chalk/ansi-styles
193
193
 
194
194
  ---------------------------------------
195
195
 
196
- ## assertion-error
197
- License: MIT
198
- By: Jake Luer
199
- Repository: git@github.com:chaijs/assertion-error.git
200
-
201
- ---------------------------------------
202
-
203
196
  ## braces
204
197
  License: MIT
205
198
  By: Jon Schlinkert, Brian Woodward, Elan Shanker, Eugene Sharygin, hemanth.hm
@@ -258,35 +251,6 @@ Repository: egoist/cac
258
251
 
259
252
  ---------------------------------------
260
253
 
261
- ## chai
262
- License: MIT
263
- By: Jake Luer, Domenic Denicola, Veselin Todorov, John Firebaugh
264
- Repository: https://github.com/chaijs/chai
265
-
266
- > MIT License
267
- >
268
- > Copyright (c) 2017 Chai.js Assertion Library
269
- >
270
- > Permission is hereby granted, free of charge, to any person obtaining a copy
271
- > of this software and associated documentation files (the "Software"), to deal
272
- > in the Software without restriction, including without limitation the rights
273
- > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
274
- > copies of the Software, and to permit persons to whom the Software is
275
- > furnished to do so, subject to the following conditions:
276
- >
277
- > The above copyright notice and this permission notice shall be included in all
278
- > copies or substantial portions of the Software.
279
- >
280
- > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
281
- > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
282
- > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
283
- > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
284
- > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
285
- > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
286
- > SOFTWARE.
287
-
288
- ---------------------------------------
289
-
290
254
  ## chai-subset
291
255
  License: MIT
292
256
  By: Andrii Shumada, Robert Herhold
@@ -316,33 +280,6 @@ Repository: https://github.com/debitoor/chai-subset.git
316
280
 
317
281
  ---------------------------------------
318
282
 
319
- ## check-error
320
- License: MIT
321
- By: Jake Luer, David Losert, Keith Cirkel, Miroslav Bajtoš, Lucas Fernandes da Costa
322
- Repository: git+ssh://git@github.com/chaijs/check-error.git
323
-
324
- > Copyright (c) 2013 Jake Luer <jake@alogicalparadox.com> (http://alogicalparadox.com)
325
- >
326
- > Permission is hereby granted, free of charge, to any person obtaining a copy
327
- > of this software and associated documentation files (the "Software"), to deal
328
- > in the Software without restriction, including without limitation the rights
329
- > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
330
- > copies of the Software, and to permit persons to whom the Software is
331
- > furnished to do so, subject to the following conditions:
332
- >
333
- > The above copyright notice and this permission notice shall be included in
334
- > all copies or substantial portions of the Software.
335
- >
336
- > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
337
- > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
338
- > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
339
- > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
340
- > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
341
- > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
342
- > THE SOFTWARE.
343
-
344
- ---------------------------------------
345
-
346
283
  ## cli-cursor
347
284
  License: MIT
348
285
  By: Sindre Sorhus
@@ -406,33 +343,6 @@ Repository: git@github.com:moxystudio/node-cross-spawn.git
406
343
 
407
344
  ---------------------------------------
408
345
 
409
- ## deep-eql
410
- License: MIT
411
- By: Jake Luer, Keith Cirkel, dougluce, Lorenz Leutgeb
412
- Repository: git@github.com:chaijs/deep-eql.git
413
-
414
- > Copyright (c) 2013 Jake Luer <jake@alogicalparadox.com> (http://alogicalparadox.com)
415
- >
416
- > Permission is hereby granted, free of charge, to any person obtaining a copy
417
- > of this software and associated documentation files (the "Software"), to deal
418
- > in the Software without restriction, including without limitation the rights
419
- > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
420
- > copies of the Software, and to permit persons to whom the Software is
421
- > furnished to do so, subject to the following conditions:
422
- >
423
- > The above copyright notice and this permission notice shall be included in
424
- > all copies or substantial portions of the Software.
425
- >
426
- > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
427
- > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
428
- > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
429
- > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
430
- > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
431
- > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
432
- > THE SOFTWARE.
433
-
434
- ---------------------------------------
435
-
436
346
  ## diff
437
347
  License: BSD-3-Clause
438
348
  Repository: git://github.com/kpdecker/jsdiff.git
@@ -635,33 +545,6 @@ Repository: git+https://github.com/WebReflection/flatted.git
635
545
 
636
546
  ---------------------------------------
637
547
 
638
- ## get-func-name
639
- License: MIT
640
- By: Jake Luer, Keith Cirkel, Lucas Fernandes da Costa, Grant Snodgrass, Lucas Vieira, Aleksey Shvayka
641
- Repository: git+ssh://git@github.com/chaijs/get-func-name.git
642
-
643
- > Copyright (c) 2013 Jake Luer <jake@alogicalparadox.com> (http://alogicalparadox.com)
644
- >
645
- > Permission is hereby granted, free of charge, to any person obtaining a copy
646
- > of this software and associated documentation files (the "Software"), to deal
647
- > in the Software without restriction, including without limitation the rights
648
- > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
649
- > copies of the Software, and to permit persons to whom the Software is
650
- > furnished to do so, subject to the following conditions:
651
- >
652
- > The above copyright notice and this permission notice shall be included in
653
- > all copies or substantial portions of the Software.
654
- >
655
- > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
656
- > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
657
- > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
658
- > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
659
- > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
660
- > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
661
- > THE SOFTWARE.
662
-
663
- ---------------------------------------
664
-
665
548
  ## get-stream
666
549
  License: MIT
667
550
  By: Sindre Sorhus
@@ -1437,30 +1320,6 @@ Repository: unjs/pathe
1437
1320
 
1438
1321
  ---------------------------------------
1439
1322
 
1440
- ## pathval
1441
- License: MIT
1442
- By: Veselin Todorov
1443
- Repository: git+ssh://git@github.com/chaijs/pathval.git
1444
-
1445
- > MIT License
1446
- >
1447
- > Copyright (c) 2011-2013 Jake Luer jake@alogicalparadox.com
1448
- >
1449
- > Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
1450
- > documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights
1451
- > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
1452
- > persons to whom the Software is furnished to do so, subject to the following conditions:
1453
- >
1454
- > The above copyright notice and this permission notice shall be included in all copies or substantial
1455
- > portions of the Software.
1456
- >
1457
- > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
1458
- > THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1459
- > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
1460
- > TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1461
-
1462
- ---------------------------------------
1463
-
1464
1323
  ## picocolors
1465
1324
  License: ISC
1466
1325
  By: Alexey Raspopov
@@ -1920,33 +1779,6 @@ Repository: micromatch/to-regex-range
1920
1779
 
1921
1780
  ---------------------------------------
1922
1781
 
1923
- ## type-detect
1924
- License: MIT
1925
- By: Jake Luer, Keith Cirkel, David Losert, Aleksey Shvayka, Lucas Fernandes da Costa, Grant Snodgrass, Jeremy Tice, Edward Betts, dvlsg, Amila Welihinda, Jake Champion, Miroslav Bajtoš
1926
- Repository: git+ssh://git@github.com/chaijs/type-detect.git
1927
-
1928
- > Copyright (c) 2013 Jake Luer <jake@alogicalparadox.com> (http://alogicalparadox.com)
1929
- >
1930
- > Permission is hereby granted, free of charge, to any person obtaining a copy
1931
- > of this software and associated documentation files (the "Software"), to deal
1932
- > in the Software without restriction, including without limitation the rights
1933
- > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1934
- > copies of the Software, and to permit persons to whom the Software is
1935
- > furnished to do so, subject to the following conditions:
1936
- >
1937
- > The above copyright notice and this permission notice shall be included in
1938
- > all copies or substantial portions of the Software.
1939
- >
1940
- > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1941
- > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1942
- > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1943
- > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1944
- > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1945
- > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1946
- > THE SOFTWARE.
1947
-
1948
- ---------------------------------------
1949
-
1950
1782
  ## which
1951
1783
  License: ISC
1952
1784
  By: Isaac Z. Schlueter
package/dist/cli.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import require$$0 from 'readline';
2
2
  import { EventEmitter } from 'events';
3
- import { e as ensurePackageInstalled } from './utils-b780070b.js';
4
- import { c as createVitest } from './index-d5bb350e.js';
3
+ import { e as ensurePackageInstalled } from './utils-c8e62373.js';
4
+ import { c as createVitest } from './index-6f17b444.js';
5
5
  import 'tty';
6
6
  import 'local-pkg';
7
7
  import 'path';
@@ -11,10 +11,10 @@ import 'fs';
11
11
  import 'os';
12
12
  import 'util';
13
13
  import 'stream';
14
- import './constants-3cbd9066.js';
14
+ import './constants-a1417084.js';
15
15
  import 'url';
16
16
  import 'perf_hooks';
17
- import './error-34c1d9e5.js';
17
+ import './error-0e2f75a4.js';
18
18
  import './index-825cb54c.js';
19
19
  import './_commonjsHelpers-bdec4bbd.js';
20
20
  import 'assert';
@@ -634,12 +634,10 @@ class CAC extends EventEmitter {
634
634
 
635
635
  const cac = (name = "") => new CAC(name);
636
636
 
637
- var version = "0.0.99";
637
+ var version = "0.0.103";
638
638
 
639
639
  const cli = cac("vitest");
640
- cli.version(version).option("-r, --root <path>", "root path").option("-c, --config <path>", "path to config file").option("-u, --update", "update snapshot").option("-w, --watch", "watch mode").option("-o, --open", "open Vitest UI").option("--api", "listen to port and serve API").option("--threads", "enabled threads", { default: true }).option("--silent", "silent").option("--run", "do not watch").option("--global", "inject apis globally").option("--dom", "mock browser api with happy-dom").option("--environment <env>", "runner environment", {
641
- default: "node"
642
- }).help();
640
+ cli.version(version).option("-r, --root <path>", "root path").option("-c, --config <path>", "path to config file").option("-u, --update", "update snapshot").option("-w, --watch", "watch mode").option("-o, --open", "open Vitest UI").option("--api", "listen to port and serve API").option("--threads", "enabled threads", { default: true }).option("--silent", "silent").option("--run", "do not watch").option("--global", "inject apis globally").option("--dom", "mock browser api with happy-dom").option("--environment <env>", "runner environment", { default: "node" }).option("--passWithNoTests", "pass when no tests found").help();
643
641
  cli.command("run [...filters]").action(run);
644
642
  cli.command("watch [...filters]").action(dev);
645
643
  cli.command("dev [...filters]").action(dev);
@@ -679,8 +677,8 @@ function registerConsoleShortcuts(ctx) {
679
677
  if (process.stdin.isTTY) {
680
678
  require$$0.emitKeypressEvents(process.stdin);
681
679
  process.stdin.setRawMode(true);
682
- process.stdin.on("keypress", (str) => {
683
- if (str === "" || str === "")
680
+ process.stdin.on("keypress", (str, key) => {
681
+ if (str === "" || str === "" || key && key.ctrl && key.name === "c")
684
682
  process.exit();
685
683
  if (ctx.runningPromise)
686
684
  return;
@@ -1,9 +1,9 @@
1
1
  import { fileURLToPath } from 'url';
2
- import { h as resolve } from './utils-b780070b.js';
2
+ import { h as resolve } from './utils-c8e62373.js';
3
3
 
4
4
  const distDir = resolve(fileURLToPath(import.meta.url), "../../dist");
5
5
  const defaultInclude = ["**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"];
6
- const defaultExclude = ["**/node_modules/**", "**/dist/**"];
6
+ const defaultExclude = ["node_modules", "dist", ".idea", ".git", ".cache"];
7
7
  const defaultPort = 51204;
8
8
  const API_PATH = "/__vitest_api__";
9
9
  const configFiles = [
package/dist/entry.js CHANGED
@@ -2,12 +2,13 @@ import fs, { promises } from 'fs';
2
2
  import { Console } from 'console';
3
3
  import { Writable } from 'stream';
4
4
  import { importModule } from 'local-pkg';
5
- import { e as expect, f as chai$1, u as util, h as setHooks, j as createSuiteHooks, k as clearContext, l as defaultSuite, m as context, n as getHooks, o as getFn } from './index-aa25bceb.js';
5
+ import chai$1, { expect, util } from 'chai';
6
6
  import { a as commonjsRequire, c as commonjsGlobal } from './_commonjsHelpers-bdec4bbd.js';
7
- import { l as index, g as getNames, c as c$1, t as toArray, b as basename, m as interpretOnlyMode, p as partitionSuiteChildren, o as hasTests, j as hasFailed } from './utils-b780070b.js';
7
+ import { l as index, g as getNames, c as c$1, t as toArray, b as basename, m as interpretOnlyMode, p as partitionSuiteChildren, o as hasTests, j as hasFailed } from './utils-c8e62373.js';
8
8
  import { r as rpc, s as send } from './rpc-7de86f29.js';
9
- import { u as unifiedDiff } from './error-34c1d9e5.js';
9
+ import { u as unifiedDiff } from './error-0e2f75a4.js';
10
10
  import { performance } from 'perf_hooks';
11
+ import { c as clearContext, b as defaultSuite, e as setHooks, f as getHooks, h as context, j as getFn } from './suite-64b3e636.js';
11
12
  import { n as nanoid } from './index-9e71c815.js';
12
13
  import { format as format$1 } from 'util';
13
14
  import 'tty';
@@ -3886,7 +3887,7 @@ async function setupGlobalEnv(config) {
3886
3887
  setupConsoleLogSpy();
3887
3888
  await setupChai();
3888
3889
  if (config.global)
3889
- (await import('./global-0be1f687.js')).registerApiGlobally();
3890
+ (await import('./global-12f52a87.js')).registerApiGlobally();
3890
3891
  }
3891
3892
  function setupConsoleLogSpy() {
3892
3893
  const stdout = new Writable({
@@ -3975,12 +3976,12 @@ async function collectTests(paths, config) {
3975
3976
  filepath,
3976
3977
  tasks: []
3977
3978
  };
3978
- setHooks(file, createSuiteHooks());
3979
3979
  clearContext();
3980
3980
  try {
3981
3981
  await runSetupFiles(config);
3982
3982
  await import(filepath);
3983
3983
  const defaultTasks = await defaultSuite.collect(file);
3984
+ setHooks(file, getHooks(defaultTasks));
3984
3985
  for (const c of [...defaultTasks.tasks, ...context.tasks]) {
3985
3986
  if (c.type === "test") {
3986
3987
  file.tasks.push(c);
@@ -1,6 +1,6 @@
1
1
  import { existsSync, promises } from 'fs';
2
2
  import { format } from 'util';
3
- import { k as notNullish, c, r as relative } from './utils-b780070b.js';
3
+ import { k as notNullish, c, r as relative } from './utils-c8e62373.js';
4
4
 
5
5
  function Diff() {}
6
6
  Diff.prototype = {
@@ -4521,7 +4521,7 @@ async function printError(error, ctx) {
4521
4521
  await printStack(ctx, stacks, nearest, async (s, pos) => {
4522
4522
  if (s === nearest) {
4523
4523
  const sourceCode = await promises.readFile(nearest.file, "utf-8");
4524
- ctx.console.log(c.yellow(generateCodeFrame(sourceCode, 4, pos)));
4524
+ ctx.log(c.yellow(generateCodeFrame(sourceCode, 4, pos)));
4525
4525
  }
4526
4526
  });
4527
4527
  }
@@ -4577,14 +4577,12 @@ async function printStack(ctx, stack, highlight, onStack) {
4577
4577
  const pos = await getSourcePos(ctx, frame) || frame;
4578
4578
  const color = frame === highlight ? c.yellow : c.gray;
4579
4579
  const path = relative(ctx.config.root, frame.file);
4580
- if (!ctx.config.silent)
4581
- ctx.console.log(color(` ${c.dim(F_POINTER)} ${[frame.method, c.dim(`${path}:${pos.line}:${pos.column}`)].filter(Boolean).join(" ")}`));
4580
+ ctx.log(color(` ${c.dim(F_POINTER)} ${[frame.method, c.dim(`${path}:${pos.line}:${pos.column}`)].filter(Boolean).join(" ")}`));
4582
4581
  await (onStack == null ? void 0 : onStack(frame, pos));
4583
4582
  if (frame.file in ctx.state.filesMap)
4584
4583
  break;
4585
4584
  }
4586
- if (!ctx.config.silent)
4587
- ctx.console.log();
4585
+ ctx.log();
4588
4586
  }
4589
4587
  function getOriginalPos(map, { line, column }) {
4590
4588
  return new Promise((resolve) => {
@@ -4617,6 +4615,7 @@ function generateCodeFrame(source, indent = 0, start = 0, end, range = 2) {
4617
4615
  const lines = source.split(splitRE);
4618
4616
  let count = 0;
4619
4617
  let res = [];
4618
+ const columns = process.stdout.columns || 80;
4620
4619
  function lineNo(no = "") {
4621
4620
  return c.gray(`${String(no).padStart(3, " ")}| `);
4622
4621
  }
@@ -4629,7 +4628,7 @@ function generateCodeFrame(source, indent = 0, start = 0, end, range = 2) {
4629
4628
  const lineLength = lines[j].length;
4630
4629
  if (lineLength > 200)
4631
4630
  return "";
4632
- res.push(lineNo(j + 1) + cliTruncate(lines[j], process.stdout.columns - 5 - indent));
4631
+ res.push(lineNo(j + 1) + cliTruncate(lines[j], columns - 5 - indent));
4633
4632
  if (j === i) {
4634
4633
  const pad = start - (count - lineLength);
4635
4634
  const length = Math.max(1, end > count ? lineLength - pad : end - start);
@@ -4726,7 +4725,7 @@ ${indent}${c.red("+ actual")}
4726
4725
  ${cleanLines.map((l) => l()).join("\n")}`;
4727
4726
  }
4728
4727
  function formatLine(line) {
4729
- return cliTruncate(line, (process.stdout.columns || 40) - 1);
4728
+ return cliTruncate(line, (process.stdout.columns || 80) - 1);
4730
4729
  }
4731
4730
  function renderTruncateMessage(indent) {
4732
4731
  return `
@@ -1,13 +1,13 @@
1
- import { g as globalApis } from './constants-3cbd9066.js';
2
- import { i as index } from './index-af51d171.js';
1
+ import { g as globalApis } from './constants-a1417084.js';
2
+ import { i as index } from './index-a190f5a1.js';
3
3
  import 'url';
4
- import './utils-b780070b.js';
4
+ import './utils-c8e62373.js';
5
5
  import 'tty';
6
6
  import 'local-pkg';
7
7
  import 'path';
8
- import './index-aa25bceb.js';
8
+ import './suite-64b3e636.js';
9
9
  import './index-9e71c815.js';
10
- import './_commonjsHelpers-bdec4bbd.js';
10
+ import 'chai';
11
11
  import 'tinyspy';
12
12
 
13
13
  function registerApiGlobally() {
@@ -1,4 +1,4 @@
1
- import { c, g as getNames, s as slash$1, a as getTests, i as isAbsolute, r as relative, d as dirname, b as basename, f as getSuites, h as resolve, n as noop$1, t as toArray, j as hasFailed } from './utils-b780070b.js';
1
+ import { c, g as getNames, s as slash$1, a as getTests, i as isAbsolute, r as relative, d as dirname, b as basename, f as getSuites, h as resolve, n as noop$1, t as toArray, j as hasFailed } from './utils-c8e62373.js';
2
2
  import { createServer, mergeConfig } from 'vite';
3
3
  import path$a from 'path';
4
4
  import process$1 from 'process';
@@ -7,9 +7,9 @@ import require$$0 from 'os';
7
7
  import require$$0$1 from 'util';
8
8
  import require$$0$2 from 'stream';
9
9
  import require$$2 from 'events';
10
- import { d as defaultInclude, a as defaultExclude, b as defaultPort, c as distDir, e as configFiles } from './constants-3cbd9066.js';
10
+ import { d as defaultInclude, a as defaultExclude, b as defaultPort, c as distDir, e as configFiles } from './constants-a1417084.js';
11
11
  import { performance } from 'perf_hooks';
12
- import { s as stringWidth, a as ansiStyles, b as stripAnsi, c as sliceAnsi, F as F_POINTER, d as F_DOWN, e as F_LONG_DASH, f as F_DOWN_RIGHT, g as F_DOT, h as F_CHECK, i as F_CROSS, j as cliTruncate, k as F_RIGHT, p as printError } from './error-34c1d9e5.js';
12
+ import { s as stringWidth, a as ansiStyles, b as stripAnsi, c as sliceAnsi, F as F_POINTER, d as F_DOWN, e as F_LONG_DASH, f as F_DOWN_RIGHT, g as F_DOT, h as F_CHECK, i as F_CROSS, j as cliTruncate, k as F_RIGHT, p as printError } from './error-0e2f75a4.js';
13
13
  import { o as onetime, s as signalExit } from './index-825cb54c.js';
14
14
  import { MessageChannel } from 'worker_threads';
15
15
  import { pathToFileURL } from 'url';
@@ -7432,21 +7432,11 @@ class ConsoleReporter {
7432
7432
  this.end = 0;
7433
7433
  this.isFirstWatchRun = true;
7434
7434
  const mode = ctx.config.watch ? c.yellow(" DEV ") : c.cyan(" RUN ");
7435
- this.log(`
7435
+ this.ctx.log(`
7436
7436
  ${c.inverse(c.bold(mode))} ${c.gray(this.ctx.config.root)}
7437
7437
  `);
7438
7438
  this.start = performance.now();
7439
7439
  }
7440
- log(...args) {
7441
- if (this.ctx.config.silent)
7442
- return;
7443
- this.ctx.console.log(...args);
7444
- }
7445
- error(...args) {
7446
- if (this.ctx.config.silent)
7447
- return;
7448
- this.ctx.console.error(...args);
7449
- }
7450
7440
  relative(path) {
7451
7441
  return relative(this.ctx.config.root, path);
7452
7442
  }
@@ -7465,16 +7455,16 @@ ${c.inverse(c.bold(mode))} ${c.gray(this.ctx.config.root)}
7465
7455
  return;
7466
7456
  const task = this.ctx.state.idMap[pack[0]];
7467
7457
  if (task.type === "test" && ((_a = task.result) == null ? void 0 : _a.state) && ((_b = task.result) == null ? void 0 : _b.state) !== "run") {
7468
- this.log(` ${getStateSymbol(task)} ${getFullName(task)}`);
7458
+ this.ctx.log(` ${getStateSymbol(task)} ${getFullName(task)}`);
7469
7459
  if (task.result.state === "fail")
7470
- this.log(c.red(` ${F_RIGHT} ${(_c = task.result.error) == null ? void 0 : _c.message}`));
7460
+ this.ctx.log(c.red(` ${F_RIGHT} ${(_c = task.result.error) == null ? void 0 : _c.message}`));
7471
7461
  }
7472
7462
  }
7473
7463
  async onFinished(files = this.ctx.state.getFiles()) {
7474
7464
  var _a, _b;
7475
7465
  this.end = performance.now();
7476
7466
  await this.stopListRender();
7477
- this.log();
7467
+ this.ctx.log();
7478
7468
  const suites = getSuites(files);
7479
7469
  const tests = getTests(files);
7480
7470
  const failedSuites = suites.filter((i) => {
@@ -7487,23 +7477,23 @@ ${c.inverse(c.bold(mode))} ${c.gray(this.ctx.config.root)}
7487
7477
  });
7488
7478
  const failedTotal = failedSuites.length + failedTests.length;
7489
7479
  let current = 1;
7490
- const errorDivider = () => this.error(`${c.red(c.dim(divider(`[${current++}/${failedTotal}]`, void 0, 1)))}
7480
+ const errorDivider = () => this.ctx.error(`${c.red(c.dim(divider(`[${current++}/${failedTotal}]`, void 0, 1)))}
7491
7481
  `);
7492
7482
  if (failedSuites.length) {
7493
- this.error(c.red(divider(c.bold(c.inverse(` Failed Suites ${failedSuites.length} `)))));
7494
- this.error();
7483
+ this.ctx.error(c.red(divider(c.bold(c.inverse(` Failed Suites ${failedSuites.length} `)))));
7484
+ this.ctx.error();
7495
7485
  for (const suite of failedSuites) {
7496
- this.error(c.red(`
7486
+ this.ctx.error(c.red(`
7497
7487
  - ${getFullName(suite)}`));
7498
7488
  await printError((_a = suite.result) == null ? void 0 : _a.error, this.ctx);
7499
7489
  errorDivider();
7500
7490
  }
7501
7491
  }
7502
7492
  if (failedTests.length) {
7503
- this.error(c.red(divider(c.bold(c.inverse(` Failed Tests ${failedTests.length} `)))));
7504
- this.error();
7493
+ this.ctx.error(c.red(divider(c.bold(c.inverse(` Failed Tests ${failedTests.length} `)))));
7494
+ this.ctx.error();
7505
7495
  for (const test of failedTests) {
7506
- this.error(`${c.red(c.bold(c.inverse(" FAIL ")))} ${getFullName(test)}`);
7496
+ this.ctx.error(`${c.red(c.bold(c.inverse(" FAIL ")))} ${getFullName(test)}`);
7507
7497
  await printError((_b = test.result) == null ? void 0 : _b.error, this.ctx);
7508
7498
  errorDivider();
7509
7499
  }
@@ -7521,17 +7511,17 @@ ${c.inverse(c.bold(mode))} ${c.gray(this.ctx.config.root)}
7521
7511
  };
7522
7512
  const snapshotOutput = renderSnapshotSummary(this.ctx.config.root, this.ctx.snapshot.summary);
7523
7513
  if (snapshotOutput.length) {
7524
- this.log(snapshotOutput.map((t, i) => i === 0 ? `${padTitle("Snapshots")} ${t}` : `${padTitle("")} ${t}`).join("\n"));
7514
+ this.ctx.log(snapshotOutput.map((t, i) => i === 0 ? `${padTitle("Snapshots")} ${t}` : `${padTitle("")} ${t}`).join("\n"));
7525
7515
  if (snapshotOutput.length > 1)
7526
- this.log();
7516
+ this.ctx.log();
7527
7517
  }
7528
- this.log(padTitle("Test Files"), getStateString(files));
7529
- this.log(padTitle("Tests"), getStateString(tests));
7518
+ this.ctx.log(padTitle("Test Files"), getStateString(files));
7519
+ this.ctx.log(padTitle("Tests"), getStateString(tests));
7530
7520
  if (this.watchFilters)
7531
- this.log(padTitle("Time"), time(threadTime));
7521
+ this.ctx.log(padTitle("Time"), time(threadTime));
7532
7522
  else
7533
- this.log(padTitle("Time"), time(executionTime) + c.gray(` (in thread ${time(threadTime)}, ${(executionTime / threadTime * 100).toFixed(2)}%)`));
7534
- this.log();
7523
+ this.ctx.log(padTitle("Time"), time(executionTime) + c.gray(` (in thread ${time(threadTime)}, ${(executionTime / threadTime * 100).toFixed(2)}%)`));
7524
+ this.ctx.log();
7535
7525
  }
7536
7526
  async onWatcherStart() {
7537
7527
  await this.stopListRender();
@@ -7540,14 +7530,14 @@ ${c.inverse(c.bold(mode))} ${c.gray(this.ctx.config.root)}
7540
7530
  return ((_a = i.result) == null ? void 0 : _a.state) === "fail";
7541
7531
  });
7542
7532
  if (failed.length)
7543
- this.log(`
7533
+ this.ctx.log(`
7544
7534
  ${c.bold(c.inverse(c.red(" FAIL ")))}${c.red(` ${failed.length} tests failed. Watching for file changes...`)}`);
7545
7535
  else
7546
- this.log(`
7536
+ this.ctx.log(`
7547
7537
  ${c.bold(c.inverse(c.green(" PASS ")))}${c.green(" Waiting for file changes...")}`);
7548
7538
  if (this.isFirstWatchRun) {
7549
7539
  this.isFirstWatchRun = false;
7550
- this.log(c.gray("press any key to exit..."));
7540
+ this.ctx.log(c.gray("press any key to exit..."));
7551
7541
  }
7552
7542
  }
7553
7543
  async onWatcherRerun(files, trigger) {
@@ -7555,7 +7545,7 @@ ${c.bold(c.inverse(c.green(" PASS ")))}${c.green(" Waiting for file changes...")
7555
7545
  this.watchFilters = files;
7556
7546
  if (!this.ctx.config.silent) {
7557
7547
  this.ctx.console.clear();
7558
- this.log(c.blue("Re-running tests...") + c.dim(` [ ${this.relative(trigger)} ]
7548
+ this.ctx.log(c.blue("Re-running tests...") + c.dim(` [ ${this.relative(trigger)} ]
7559
7549
  `));
7560
7550
  }
7561
7551
  }
@@ -7569,12 +7559,12 @@ ${c.bold(c.inverse(c.green(" PASS ")))}${c.green(" Waiting for file changes...")
7569
7559
  var _a;
7570
7560
  (_a = this.renderer) == null ? void 0 : _a.clear();
7571
7561
  const task = log.taskId ? this.ctx.state.idMap[log.taskId] : void 0;
7572
- this.log(c.gray(log.type + c.dim(` | ${task ? getFullName(task) : "unknown test"}`)));
7562
+ this.ctx.log(c.gray(log.type + c.dim(` | ${task ? getFullName(task) : "unknown test"}`)));
7573
7563
  process[log.type].write(`${log.content}
7574
7564
  `);
7575
7565
  }
7576
7566
  onServerRestart() {
7577
- this.log(c.cyan("Restarted due to config changes..."));
7567
+ this.ctx.log(c.cyan("Restarted due to config changes..."));
7578
7568
  }
7579
7569
  }
7580
7570
 
@@ -7646,6 +7636,8 @@ function resolveConfig(options, viteConfig) {
7646
7636
  resolved.interpretDefault = resolved.interpretDefault ?? true;
7647
7637
  resolved.include = resolved.include ?? defaultInclude;
7648
7638
  resolved.exclude = resolved.exclude ?? defaultExclude;
7639
+ resolved.testTimeout = resolved.testTimeout ?? 5e3;
7640
+ resolved.hookTimeout = resolved.hookTimeout ?? 1e4;
7649
7641
  resolved.watchIgnore = resolved.watchIgnore ?? [/\/node_modules\//, /\/dist\//];
7650
7642
  const CI = !!process.env.CI;
7651
7643
  const UPDATE_SNAPSHOT = resolved.update || process.env.UPDATE_SNAPSHOT;
@@ -7662,7 +7654,17 @@ function resolveConfig(options, viteConfig) {
7662
7654
  return resolved;
7663
7655
  }
7664
7656
 
7657
+ const promiseMap = /* @__PURE__ */ new Map();
7665
7658
  async function transformRequest(server, id) {
7659
+ if (!promiseMap.has(id)) {
7660
+ promiseMap.set(id, _transformRequest(server, id).then((r) => {
7661
+ promiseMap.delete(id);
7662
+ return r;
7663
+ }));
7664
+ }
7665
+ return promiseMap.get(id);
7666
+ }
7667
+ async function _transformRequest(server, id) {
7666
7668
  let result = null;
7667
7669
  if (id.match(/\.(?:[cm]?[jt]sx?|json)$/)) {
7668
7670
  result = await server.transformRequest(id, { ssr: true });
@@ -7835,8 +7837,11 @@ class Vitest {
7835
7837
  async start(filters) {
7836
7838
  const files = await this.globTestFiles(filters);
7837
7839
  if (!files.length) {
7838
- console.error("No test files found");
7839
- process.exitCode = 1;
7840
+ if (this.config.passWithNoTests)
7841
+ this.log("No test files found\n");
7842
+ else
7843
+ this.error(c.red("No test files found\n"));
7844
+ process.exit(this.config.passWithNoTests ? 0 : 1);
7840
7845
  }
7841
7846
  await this.runFiles(files);
7842
7847
  if (this.config.watch)
@@ -7858,6 +7863,16 @@ class Vitest {
7858
7863
  });
7859
7864
  return await this.runningPromise;
7860
7865
  }
7866
+ log(...args) {
7867
+ if (this.config.silent)
7868
+ return;
7869
+ this.console.log(...args);
7870
+ }
7871
+ error(...args) {
7872
+ if (this.config.silent)
7873
+ return;
7874
+ this.console.error(...args);
7875
+ }
7861
7876
  async scheduleRerun(triggerId) {
7862
7877
  const currentCount = this.restartsCount;
7863
7878
  clearTimeout(this._rerunTimer);
@@ -7979,7 +7994,7 @@ async function createVitest(options, viteOverrides = {}) {
7979
7994
  ctx.setServer(options, server2);
7980
7995
  haveStarted = true;
7981
7996
  if (options.api)
7982
- server2.middlewares.use((await import('./middleware-991dfa87.js')).default(ctx));
7997
+ server2.middlewares.use((await import('./middleware-05e03d95.js')).default(ctx));
7983
7998
  }
7984
7999
  }
7985
8000
  ],
@@ -1,4 +1,5 @@
1
- import { g as getCurrentSuite, w as withTimeout, a as getDefaultHookTimeout, u as util, s as suite, t as test, d as describe, i as it, b as assert, c as should, e as expect, f as chai } from './index-aa25bceb.js';
1
+ import { g as getCurrentSuite, w as withTimeout, a as getDefaultHookTimeout, s as suite, t as test, d as describe, i as it } from './suite-64b3e636.js';
2
+ import chai, { util, assert, should, expect } from 'chai';
2
3
  import * as tinyspy from 'tinyspy';
3
4
  import { spies } from 'tinyspy';
4
5
 
package/dist/index.d.ts CHANGED
@@ -303,12 +303,12 @@ interface InlineConfig {
303
303
  /**
304
304
  * Include globs for test files
305
305
  *
306
- * @default ['**\/*.test.ts']
306
+ * @default ['**\/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}']
307
307
  */
308
308
  include?: string[];
309
309
  /**
310
310
  * Exclude globs for test files
311
- * @default ['**\/node_modules\/**']
311
+ * @default ['node_modules', 'dist', '.idea', '.git', '.cache']
312
312
  */
313
313
  exclude?: string[];
314
314
  /**
@@ -446,6 +446,10 @@ interface UserConfig extends InlineConfig {
446
446
  * Do not watch
447
447
  */
448
448
  run?: boolean;
449
+ /**
450
+ * Pass with no tests
451
+ */
452
+ passWithNoTests?: boolean;
449
453
  }
450
454
  interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters'> {
451
455
  config?: string;
@@ -570,12 +574,14 @@ declare class VitestUtils {
570
574
  declare const vitest: VitestUtils;
571
575
  declare const vi: VitestUtils;
572
576
 
577
+ declare type VitestInlineConfig = InlineConfig;
578
+
573
579
  declare module 'vite' {
574
580
  interface UserConfig {
575
581
  /**
576
582
  * Options for Vitest
577
583
  */
578
- test?: InlineConfig;
584
+ test?: VitestInlineConfig;
579
585
  }
580
586
  }
581
587
  declare global {