vitest 0.0.114 → 0.0.115

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.
@@ -345,11 +345,36 @@ async function ensurePackageInstalled(dependency, promptInstall = !process.env.C
345
345
  message: c.reset(`Do you want to install ${c.green(dependency)}?`)
346
346
  });
347
347
  if (install) {
348
- await (await import('./index-9f4b9905.js')).installPackage(dependency, { dev: true });
348
+ await (await import('./index-ce49e384.js')).installPackage(dependency, { dev: true });
349
349
  return true;
350
350
  }
351
351
  return false;
352
352
  }
353
+ function deepMerge(target, ...sources) {
354
+ if (!sources.length)
355
+ return target;
356
+ const source = sources.shift();
357
+ if (source === void 0)
358
+ return target;
359
+ if (isMergableObject(target) && isMergableObject(source)) {
360
+ Object.keys(source).forEach((key) => {
361
+ if (isMergableObject(source[key])) {
362
+ if (!target[key])
363
+ target[key] = {};
364
+ deepMerge(target[key], source[key]);
365
+ } else {
366
+ target[key] = source[key];
367
+ }
368
+ });
369
+ }
370
+ return deepMerge(target, ...sources);
371
+ }
372
+ function isMergableObject(item) {
373
+ return isObject(item) && !Array.isArray(item);
374
+ }
375
+ function isObject(val) {
376
+ return toString.call(val) === "[object Object]";
377
+ }
353
378
  function toFilePath(id, root) {
354
379
  let absolute = slash(id).startsWith("/@fs/") ? id.slice(4) : id.startsWith(dirname(root)) ? id : id.startsWith("/") ? slash(resolve(root, id.slice(1))) : id;
355
380
  if (absolute.startsWith("//"))
@@ -357,4 +382,4 @@ function toFilePath(id, root) {
357
382
  return isWindows && absolute.startsWith("/") ? fileURLToPath(pathToFileURL(absolute.slice(1)).href) : absolute;
358
383
  }
359
384
 
360
- export { getSuites as a, basename as b, c, dirname as d, ensurePackageInstalled as e, getTests as f, getFullName as g, hasFailed as h, isAbsolute as i, resolve as j, toArray as k, join as l, notNullish as m, noop as n, mergeSlashes as o, index as p, getNames as q, relative as r, slash as s, toFilePath as t, interpretOnlyMode as u, partitionSuiteChildren as v, hasTests as w, isWindows as x, getTasks as y };
385
+ export { isAbsolute as a, basename as b, c, dirname as d, ensurePackageInstalled as e, getSuites as f, getFullName as g, hasFailed as h, isObject as i, getTests as j, resolve as k, deepMerge as l, toFilePath as m, noop as n, notNullish as o, mergeSlashes as p, index as q, relative as r, slash as s, toArray as t, getNames as u, interpretOnlyMode as v, partitionSuiteChildren as w, hasTests as x, isWindows as y, getTasks as z };
@@ -1,4 +1,4 @@
1
- import { g as getCurrentSuite, w as withTimeout, a as getDefaultHookTimeout, b as getState, s as setState, c as suite, t as test, d as describe, i as it, v as vitest, e as vi } from './vi-67e478ef.js';
1
+ import { g as getCurrentSuite, w as withTimeout, a as getDefaultHookTimeout, b as getState, s as setState, c as suite, t as test, d as describe, i as it, v as vitest, e as vi } from './vi-2115c609.js';
2
2
  import chai, { assert, should } from 'chai';
3
3
  import { s as spies, a as spyOn, f as fn } from './jest-mock-4a754991.js';
4
4
 
@@ -1,21 +1,22 @@
1
- import fs$8, { promises, existsSync } from 'fs';
2
- import { pathToFileURL } from 'url';
3
- import { c, s as slash$1, i as isAbsolute, r as relative, d as dirname, b as basename, g as getFullName, h as hasFailed, a as getSuites, f as getTests, j as resolve, t as toFilePath, n as noop$1, k as toArray, l as join } from './index-ea5153a0.js';
1
+ import { c, s as slash$1, a as isAbsolute, r as relative, d as dirname, b as basename, g as getFullName, h as hasFailed, f as getSuites, j as getTests, t as toArray, k as resolve, l as deepMerge, m as toFilePath, n as noop$1 } from './index-7c024e16.js';
4
2
  import { createServer, mergeConfig } from 'vite';
5
3
  import path$a from 'path';
6
4
  import process$1 from 'process';
5
+ import fs$8, { promises, existsSync } from 'fs';
7
6
  import require$$0 from 'os';
8
7
  import require$$0$1 from 'util';
9
8
  import require$$0$2 from 'stream';
10
9
  import require$$2 from 'events';
11
- import { d as defaultInclude, a as defaultExclude, b as defaultPort, c as distDir, e as configFiles } from './constants-9c7f06df.js';
10
+ import { d as defaultInclude, a as defaultExclude, b as defaultPort, c as distDir, e as configFiles } from './constants-5968a78c.js';
12
11
  import MagicString from './magic-string.es-94000aea.js';
13
- import { performance as performance$1 } from 'perf_hooks';
14
- import { F as F_POINTER, a as F_DOWN, s as stripAnsi, b as F_LONG_DASH, c as F_DOWN_RIGHT, d as F_DOT, e as F_CHECK, f as F_CROSS, g as F_RIGHT, p as printError, h as stringWidth, i as ansiStyles, j as sliceAnsi, k as cliTruncate } from './diff-3cfdad26.js';
15
- import { o as onetime, s as signalExit } from './index-61c8686f.js';
12
+ import { performance } from 'perf_hooks';
13
+ import { F as F_POINTER, a as F_DOWN, s as stripAnsi, b as F_LONG_DASH, c as F_DOWN_RIGHT, d as F_DOT, e as F_CHECK, f as F_CROSS, g as F_RIGHT, p as printError, h as stringWidth, i as ansiStyles, j as sliceAnsi, k as cliTruncate } from './diff-67678e1f.js';
14
+ import { o as onetime, s as signalExit } from './index-648e7ab2.js';
15
+ import { createRequire } from 'module';
16
+ import { pathToFileURL } from 'url';
16
17
  import { MessageChannel } from 'worker_threads';
17
18
  import { Tinypool } from 'tinypool';
18
- import { c as createBirpc } from './index-7889832e.js';
19
+ import { c as createBirpc } from './index-e909c175.js';
19
20
 
20
21
  /*
21
22
  How it works:
@@ -6965,23 +6966,26 @@ function elegantSpinner() {
6965
6966
  }
6966
6967
 
6967
6968
  class BaseReporter {
6968
- constructor(ctx) {
6969
- this.ctx = ctx;
6969
+ constructor() {
6970
6970
  this.start = 0;
6971
6971
  this.end = 0;
6972
6972
  this.isTTY = process.stdout.isTTY && !process.env.CI;
6973
+ this.ctx = void 0;
6973
6974
  this.isFirstWatchRun = true;
6974
- const mode = ctx.config.watch ? c.blue(" WATCH ") : c.cyan(" RUN ");
6975
+ }
6976
+ onInit(ctx) {
6977
+ this.ctx = ctx;
6978
+ const mode = this.ctx.config.watch ? c.blue(" WATCH ") : c.cyan(" RUN ");
6975
6979
  this.ctx.log(`
6976
6980
  ${c.inverse(c.bold(mode))} ${c.gray(this.ctx.config.root)}
6977
6981
  `);
6978
- this.start = performance$1.now();
6982
+ this.start = performance.now();
6979
6983
  }
6980
6984
  relative(path) {
6981
6985
  return relative(this.ctx.config.root, path);
6982
6986
  }
6983
6987
  async onFinished(files = this.ctx.state.getFiles()) {
6984
- this.end = performance$1.now();
6988
+ this.end = performance.now();
6985
6989
  await this.reportSummary(files);
6986
6990
  }
6987
6991
  onTaskUpdate(pack) {
@@ -7639,11 +7643,10 @@ function renderTree(tasks, options, level = 0) {
7639
7643
  }
7640
7644
  return output.slice(0, MAX_HEIGHT).join("\n");
7641
7645
  }
7642
- const createListRenderer = (_tasks, options = {}) => {
7646
+ const createListRenderer = (_tasks, options) => {
7643
7647
  let tasks = _tasks;
7644
7648
  let timer;
7645
- const stdout = process.stdout;
7646
- const log = createLogUpdate(stdout);
7649
+ const log = createLogUpdate(options.outputStream);
7647
7650
  function update() {
7648
7651
  log(renderTree(tasks, options));
7649
7652
  }
@@ -7665,7 +7668,7 @@ const createListRenderer = (_tasks, options = {}) => {
7665
7668
  timer = void 0;
7666
7669
  }
7667
7670
  log.clear();
7668
- stdout.write(`${renderTree(tasks, options)}
7671
+ options.outputStream.write(`${renderTree(tasks, options)}
7669
7672
  `);
7670
7673
  return this;
7671
7674
  },
@@ -7682,6 +7685,7 @@ class DefaultReporter extends BaseReporter {
7682
7685
  }
7683
7686
  onStart() {
7684
7687
  if (this.isTTY) {
7688
+ this.rendererOptions.outputStream = this.ctx.outputStream;
7685
7689
  const files = this.ctx.state.getFiles(this.watchFilters);
7686
7690
  if (!this.renderer)
7687
7691
  this.renderer = createListRenderer(files, this.rendererOptions).start();
@@ -7735,11 +7739,10 @@ function render(tasks) {
7735
7739
  }
7736
7740
  }).join("");
7737
7741
  }
7738
- const createDotRenderer = (_tasks) => {
7742
+ const createDotRenderer = (_tasks, options) => {
7739
7743
  let tasks = _tasks;
7740
7744
  let timer;
7741
- const stdout = process.stdout;
7742
- const log = createLogUpdate(stdout);
7745
+ const log = createLogUpdate(options.outputStream);
7743
7746
  function update() {
7744
7747
  log(render(tasks));
7745
7748
  }
@@ -7761,7 +7764,7 @@ const createDotRenderer = (_tasks) => {
7761
7764
  timer = void 0;
7762
7765
  }
7763
7766
  log.clear();
7764
- stdout.write(`${render(tasks)}
7767
+ options.outputStream.write(`${render(tasks)}
7765
7768
  `);
7766
7769
  return this;
7767
7770
  },
@@ -7776,7 +7779,7 @@ class DotReporter extends BaseReporter {
7776
7779
  if (this.isTTY) {
7777
7780
  const files = this.ctx.state.getFiles(this.watchFilters);
7778
7781
  if (!this.renderer)
7779
- this.renderer = createDotRenderer(files).start();
7782
+ this.renderer = createDotRenderer(files, { outputStream: this.ctx.outputStream }).start();
7780
7783
  else
7781
7784
  this.renderer.update(files);
7782
7785
  }
@@ -7808,8 +7811,8 @@ class DotReporter extends BaseReporter {
7808
7811
  }
7809
7812
 
7810
7813
  class VerboseReporter extends DefaultReporter {
7811
- constructor(ctx) {
7812
- super(ctx);
7814
+ constructor() {
7815
+ super();
7813
7816
  this.rendererOptions.renderSucceed = true;
7814
7817
  }
7815
7818
  }
@@ -7820,6 +7823,80 @@ const ReportersMap = {
7820
7823
  dot: DotReporter
7821
7824
  };
7822
7825
 
7826
+ var __defProp$1 = Object.defineProperty;
7827
+ var __defProps$1 = Object.defineProperties;
7828
+ var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
7829
+ var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
7830
+ var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
7831
+ var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
7832
+ var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7833
+ var __spreadValues$1 = (a, b) => {
7834
+ for (var prop in b || (b = {}))
7835
+ if (__hasOwnProp$1.call(b, prop))
7836
+ __defNormalProp$1(a, prop, b[prop]);
7837
+ if (__getOwnPropSymbols$1)
7838
+ for (var prop of __getOwnPropSymbols$1(b)) {
7839
+ if (__propIsEnum$1.call(b, prop))
7840
+ __defNormalProp$1(a, prop, b[prop]);
7841
+ }
7842
+ return a;
7843
+ };
7844
+ var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
7845
+ const defaultExcludes = [
7846
+ "coverage/**",
7847
+ "packages/*/test{,s}/**",
7848
+ "**/*.d.ts",
7849
+ "test{,s}/**",
7850
+ "test{,-*}.{js,cjs,mjs,ts,tsx,jsx}",
7851
+ "**/*{.,-}test.{js,cjs,mjs,ts,tsx,jsx}",
7852
+ "**/__tests__/**",
7853
+ "**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc}.config.{js,cjs,mjs,ts}",
7854
+ "**/.{eslint,mocha}rc.{js,cjs}"
7855
+ ];
7856
+ function resolveC8Options(options, root) {
7857
+ const resolved = __spreadValues$1({
7858
+ enabled: false,
7859
+ clean: true,
7860
+ cleanOnRerun: false,
7861
+ reportsDirectory: "./coverage",
7862
+ excludeNodeModules: true,
7863
+ exclude: defaultExcludes,
7864
+ reporter: "text",
7865
+ allowExternal: false
7866
+ }, options);
7867
+ resolved.reporter = toArray(resolved.reporter);
7868
+ resolved.reportsDirectory = resolve(root, resolved.reportsDirectory);
7869
+ resolved.tempDirectory = process.env.NODE_V8_COVERAGE || resolve(resolved.reportsDirectory, "tmp");
7870
+ return resolved;
7871
+ }
7872
+ async function cleanCoverage(options, clean = true) {
7873
+ if (clean && existsSync(options.reportsDirectory))
7874
+ await promises.rmdir(options.reportsDirectory, { recursive: true });
7875
+ if (!existsSync(options.tempDirectory))
7876
+ await promises.mkdir(options.tempDirectory, { recursive: true });
7877
+ }
7878
+ async function prepareCoverage(options) {
7879
+ if (options.enabled)
7880
+ return false;
7881
+ await cleanCoverage(options, options.clean);
7882
+ }
7883
+ const require2 = createRequire(import.meta.url);
7884
+ async function reportCoverage(ctx) {
7885
+ const createReport = require2("c8/lib/report");
7886
+ const report = createReport(ctx.config.coverage);
7887
+ Array.from(ctx.visitedFilesMap.entries()).filter((i) => !i[0].includes("/node_modules/")).forEach(([file, map]) => {
7888
+ if (!existsSync(file))
7889
+ return;
7890
+ const url = pathToFileURL(file).href;
7891
+ report.sourceMapCache[url] = {
7892
+ data: __spreadProps$1(__spreadValues$1({}, map), {
7893
+ sources: map.sources.map((i) => pathToFileURL(i).href) || [url]
7894
+ })
7895
+ };
7896
+ });
7897
+ await report.run();
7898
+ }
7899
+
7823
7900
  class StateManager {
7824
7901
  constructor() {
7825
7902
  this.filesMap = {};
@@ -7855,32 +7932,33 @@ class StateManager {
7855
7932
  }
7856
7933
  }
7857
7934
 
7858
- var __defProp$1 = Object.defineProperty;
7859
- var __defProps$1 = Object.defineProperties;
7860
- var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
7861
- var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
7862
- var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
7863
- var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
7864
- var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7865
- var __spreadValues$1 = (a, b) => {
7935
+ var __defProp = Object.defineProperty;
7936
+ var __defProps = Object.defineProperties;
7937
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
7938
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
7939
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7940
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7941
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7942
+ var __spreadValues = (a, b) => {
7866
7943
  for (var prop in b || (b = {}))
7867
- if (__hasOwnProp$1.call(b, prop))
7868
- __defNormalProp$1(a, prop, b[prop]);
7869
- if (__getOwnPropSymbols$1)
7870
- for (var prop of __getOwnPropSymbols$1(b)) {
7871
- if (__propIsEnum$1.call(b, prop))
7872
- __defNormalProp$1(a, prop, b[prop]);
7944
+ if (__hasOwnProp.call(b, prop))
7945
+ __defNormalProp(a, prop, b[prop]);
7946
+ if (__getOwnPropSymbols)
7947
+ for (var prop of __getOwnPropSymbols(b)) {
7948
+ if (__propIsEnum.call(b, prop))
7949
+ __defNormalProp(a, prop, b[prop]);
7873
7950
  }
7874
7951
  return a;
7875
7952
  };
7876
- var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
7953
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
7877
7954
  function resolveConfig(options, viteConfig) {
7878
7955
  var _a, _b;
7879
7956
  if (options.dom)
7880
7957
  options.environment = "happy-dom";
7881
- const resolved = __spreadProps$1(__spreadValues$1(__spreadValues$1({}, options), viteConfig.test), {
7958
+ const resolved = __spreadProps(__spreadValues({}, deepMerge(options, viteConfig.test)), {
7882
7959
  root: viteConfig.root
7883
7960
  });
7961
+ resolved.coverage = resolveC8Options(resolved.coverage, resolved.root);
7884
7962
  resolved.depsInline = [...((_a = resolved.deps) == null ? void 0 : _a.inline) || []];
7885
7963
  resolved.depsExternal = [...((_b = resolved.deps) == null ? void 0 : _b.external) || []];
7886
7964
  resolved.environment = resolved.environment || "node";
@@ -8021,22 +8099,24 @@ function createChannel(ctx) {
8021
8099
  const workerPort = channel.port1;
8022
8100
  createBirpc({
8023
8101
  functions: {
8024
- processExit(code) {
8102
+ onWorkerExit(code) {
8025
8103
  process.exit(code || 1);
8026
8104
  },
8027
8105
  snapshotSaved(snapshot) {
8028
8106
  ctx.snapshot.add(snapshot);
8029
8107
  },
8030
- getSourceMap(id, force) {
8108
+ async getSourceMap(id, force) {
8031
8109
  if (force) {
8032
8110
  const mod = ctx.server.moduleGraph.getModuleById(id);
8033
8111
  if (mod)
8034
8112
  ctx.server.moduleGraph.invalidateModule(mod);
8035
8113
  }
8036
- return transformRequest(ctx, id).then((r) => r == null ? void 0 : r.map);
8114
+ const r = await transformRequest(ctx, id);
8115
+ return r == null ? void 0 : r.map;
8037
8116
  },
8038
- fetch(id) {
8039
- return transformRequest(ctx, id).then((r) => r == null ? void 0 : r.code);
8117
+ async fetch(id) {
8118
+ const r = await transformRequest(ctx, id);
8119
+ return r == null ? void 0 : r.code;
8040
8120
  },
8041
8121
  onCollected(files) {
8042
8122
  ctx.state.collectFiles(files);
@@ -8046,7 +8126,7 @@ function createChannel(ctx) {
8046
8126
  ctx.state.updateTasks([pack]);
8047
8127
  ctx.report("onTaskUpdate", pack);
8048
8128
  },
8049
- log(msg) {
8129
+ onUserLog(msg) {
8050
8130
  ctx.report("onUserConsoleLog", msg);
8051
8131
  }
8052
8132
  },
@@ -8060,25 +8140,6 @@ function createChannel(ctx) {
8060
8140
  return { workerPort, port };
8061
8141
  }
8062
8142
 
8063
- var __defProp = Object.defineProperty;
8064
- var __defProps = Object.defineProperties;
8065
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
8066
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8067
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8068
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
8069
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8070
- var __spreadValues = (a, b) => {
8071
- for (var prop in b || (b = {}))
8072
- if (__hasOwnProp.call(b, prop))
8073
- __defNormalProp(a, prop, b[prop]);
8074
- if (__getOwnPropSymbols)
8075
- for (var prop of __getOwnPropSymbols(b)) {
8076
- if (__propIsEnum.call(b, prop))
8077
- __defNormalProp(a, prop, b[prop]);
8078
- }
8079
- return a;
8080
- };
8081
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
8082
8143
  const WATCHER_DEBOUNCE = 100;
8083
8144
  class Vitest {
8084
8145
  constructor() {
@@ -8087,6 +8148,8 @@ class Vitest {
8087
8148
  this.state = void 0;
8088
8149
  this.snapshot = void 0;
8089
8150
  this.reporters = void 0;
8151
+ this.outputStream = process.stdout;
8152
+ this.errorStream = process.stderr;
8090
8153
  this.invalidates = /* @__PURE__ */ new Set();
8091
8154
  this.changedTests = /* @__PURE__ */ new Set();
8092
8155
  this.visitedFilesMap = /* @__PURE__ */ new Map();
@@ -8096,7 +8159,7 @@ class Vitest {
8096
8159
  this.unregisterWatcher = noop$1;
8097
8160
  this.console = globalThis.console;
8098
8161
  }
8099
- setServer(options, server) {
8162
+ async setServer(options, server) {
8100
8163
  var _a, _b;
8101
8164
  (_a = this.unregisterWatcher) == null ? void 0 : _a.call(this);
8102
8165
  clearTimeout(this._rerunTimer);
@@ -8113,18 +8176,21 @@ class Vitest {
8113
8176
  const Reporter = ReportersMap[i];
8114
8177
  if (!Reporter)
8115
8178
  throw new Error(`Unknown reporter: ${i}`);
8116
- return new Reporter(this);
8179
+ return new Reporter();
8117
8180
  }
8118
8181
  return i;
8119
8182
  });
8120
8183
  if (!this.reporters.length)
8121
- this.reporters.push(new DefaultReporter(this));
8184
+ this.reporters.push(new DefaultReporter());
8122
8185
  if (this.config.watch)
8123
8186
  this.registerWatcher();
8124
8187
  this.runningPromise = void 0;
8125
8188
  this._onRestartListeners.forEach((fn) => fn());
8189
+ if (resolved.coverage.enabled)
8190
+ await prepareCoverage(resolved.coverage);
8126
8191
  }
8127
8192
  async start(filters) {
8193
+ this.report("onInit", this);
8128
8194
  const files = await this.globTestFiles(filters);
8129
8195
  if (!files.length) {
8130
8196
  if (this.config.passWithNoTests)
@@ -8136,7 +8202,8 @@ class Vitest {
8136
8202
  await this.runFiles(files);
8137
8203
  if (this.config.watch)
8138
8204
  await this.report("onWatcherStart");
8139
- await this.writeC8Sourcemap();
8205
+ if (this.config.coverage.enabled)
8206
+ await reportCoverage(this);
8140
8207
  }
8141
8208
  async runFiles(files) {
8142
8209
  await this.runningPromise;
@@ -8178,9 +8245,14 @@ class Vitest {
8178
8245
  this.snapshot.clear();
8179
8246
  const files = Array.from(this.changedTests);
8180
8247
  this.changedTests.clear();
8248
+ this.console.log("return");
8249
+ if (this.config.coverage.enabled && this.config.coverage.cleanOnRerun)
8250
+ await cleanCoverage(this.config.coverage);
8181
8251
  await this.report("onWatcherRerun", files, triggerId);
8182
8252
  await this.runFiles(files);
8183
8253
  await this.report("onWatcherStart");
8254
+ if (this.config.coverage.enabled)
8255
+ await reportCoverage(this);
8184
8256
  }, WATCHER_DEBOUNCE);
8185
8257
  }
8186
8258
  registerWatcher() {
@@ -8253,28 +8325,6 @@ class Vitest {
8253
8325
  files = files.filter((i) => filters.some((f) => i.includes(f)));
8254
8326
  return files;
8255
8327
  }
8256
- async writeC8Sourcemap() {
8257
- const coverageDir = process.env.NODE_V8_COVERAGE;
8258
- if (!coverageDir)
8259
- return;
8260
- const cache = {};
8261
- const files = Array.from(this.visitedFilesMap.entries()).filter((i) => !i[0].includes("/node_modules/"));
8262
- files.forEach(([file, map]) => {
8263
- if (!existsSync(file))
8264
- return;
8265
- const url = pathToFileURL(file).href;
8266
- cache[url] = {
8267
- data: __spreadProps(__spreadValues({}, map), {
8268
- sources: map.sources.map((i) => pathToFileURL(i).href) || [url]
8269
- })
8270
- };
8271
- });
8272
- await promises.writeFile(join(coverageDir, "vitest-source-map.json"), JSON.stringify({
8273
- "result": [],
8274
- "timestamp": performance.now(),
8275
- "source-map-cache": cache
8276
- }), "utf-8");
8277
- }
8278
8328
  isTargetFile(id) {
8279
8329
  if (micromatch_1.isMatch(id, this.config.exclude))
8280
8330
  return false;
@@ -8300,10 +8350,10 @@ async function createVitest(options, viteOverrides = {}) {
8300
8350
  async configureServer(server2) {
8301
8351
  if (haveStarted)
8302
8352
  await ctx.report("onServerRestart");
8303
- ctx.setServer(options, server2);
8353
+ await ctx.setServer(options, server2);
8304
8354
  haveStarted = true;
8305
8355
  if (options.api)
8306
- server2.middlewares.use((await import('./middleware-85ff8fbf.js')).default(ctx));
8356
+ server2.middlewares.use((await import('./middleware-647438b9.js')).default(ctx));
8307
8357
  }
8308
8358
  },
8309
8359
  MocksPlugin()