vitest 0.12.5 → 0.12.8

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 (27) hide show
  1. package/LICENSE.md +0 -72
  2. package/dist/{chunk-api-setup.62de6413.js → chunk-api-setup.9ccd19b5.js} +5 -4
  3. package/dist/{chunk-constants.153353ee.js → chunk-constants.3570739f.js} +1 -1
  4. package/dist/{chunk-defaults.374342ed.js → chunk-defaults.7d81a6ca.js} +1 -1
  5. package/dist/{chunk-install-pkg.eb979c48.js → chunk-install-pkg.fd8d1022.js} +9 -11
  6. package/dist/chunk-integrations-globals.23cc66c3.js +26 -0
  7. package/dist/{chunk-magic-string.d5e0e473.js → chunk-magic-string.41232190.js} +0 -4
  8. package/dist/{chunk-runtime-chain.eb563278.js → chunk-runtime-chain.5021a6b6.js} +44 -10
  9. package/dist/{chunk-runtime-mocker.efd6b7ac.js → chunk-runtime-mocker.d26f8110.js} +8 -7
  10. package/dist/{chunk-runtime-rpc.ef131645.js → chunk-runtime-rpc.47bae3f9.js} +1 -1
  11. package/dist/{chunk-utils-global.03413604.js → chunk-utils-global.2fab7e5c.js} +3 -9
  12. package/dist/{chunk-utils-timers.a0f0fe66.js → chunk-utils-timers.da6ac0a6.js} +3 -2
  13. package/dist/{chunk-vite-node-externalize.8560ca65.js → chunk-vite-node-externalize.fc385bba.js} +67 -58
  14. package/dist/{chunk-vite-node-utils.1064f66b.js → chunk-vite-node-utils.46e2a803.js} +8 -1064
  15. package/dist/cli.js +11 -9
  16. package/dist/config.d.ts +6 -3
  17. package/dist/entry.js +7 -6
  18. package/dist/index.d.ts +247 -249
  19. package/dist/index.js +5 -4
  20. package/dist/node.d.ts +215 -0
  21. package/dist/node.js +13 -11
  22. package/dist/vendor-_commonjsHelpers.addc3445.js +3 -0
  23. package/dist/{vendor-entry.5b810598.js → vendor-entry.ca05c118.js} +28 -83
  24. package/dist/{vendor-index.4e550a2c.js → vendor-index.6c69a0a8.js} +5 -5
  25. package/dist/worker.js +6 -5
  26. package/package.json +8 -7
  27. package/dist/chunk-integrations-globals.4fea033a.js +0 -25
@@ -2,27 +2,30 @@ import { Buffer } from 'buffer';
2
2
  import path$a from 'path';
3
3
  import childProcess from 'child_process';
4
4
  import process$1 from 'process';
5
- import { s as signalExit, m as mergeStream, g as getStream, c as crossSpawn, o as onetime$1 } from './vendor-index.4e550a2c.js';
5
+ import { s as signalExit, m as mergeStream, g as getStream, c as crossSpawn, o as onetime$1 } from './vendor-index.6c69a0a8.js';
6
6
  import url, { fileURLToPath, pathToFileURL } from 'url';
7
7
  import require$$0, { constants as constants$5, cpus, hostname } from 'os';
8
- import { c as commonjsGlobal, j as join, h as basename, d as dirname, k as resolve, p as picocolors, s as slash$2, l as isAbsolute, m as relative, o as getTests, q as getFullName, u as hasFailed, v as hasFailedSnapshot, w as getSuites, t as toArray, x as normalize, n as noop$1, y as deepMerge, z as toNamespacedPath, g as getCallLastIndex, f as notNullish, A as ensurePackageInstalled, B as stdout } from './chunk-utils-global.03413604.js';
8
+ import { j as join, f as basename, d as dirname, h as resolve, p as picocolors, s as slash$2, k as isAbsolute, l as relative, m as isNode, o as getTests, q as getFullName, u as hasFailed, v as hasFailedSnapshot, w as getSuites, t as toArray, x as normalize, n as noop$1, y as deepMerge, z as toNamespacedPath, g as getCallLastIndex, e as notNullish, A as ensurePackageInstalled, B as stdout } from './chunk-utils-global.2fab7e5c.js';
9
9
  import { createServer, mergeConfig } from 'vite';
10
10
  import fs$8, { promises, existsSync, readFileSync } from 'fs';
11
- import { d as distDir, a as defaultPort, c as configFiles } from './chunk-constants.153353ee.js';
11
+ import { d as distDir, a as defaultPort, c as configFiles } from './chunk-constants.3570739f.js';
12
12
  import readline from 'readline';
13
- import require$$1 from 'util';
14
- import require$$0$1 from 'stream';
13
+ import require$$0$1 from 'util';
14
+ import require$$0$2 from 'stream';
15
15
  import require$$2 from 'events';
16
- import { i as isNodeBuiltin, a as isValidNodeImport, s as slash$1, c as createDebug, t as toFilePath, w as withInlineSourcemap, b as createBirpc, V as ViteNodeRunner } from './chunk-vite-node-utils.1064f66b.js';
17
- import { c as configDefaults, r as resolveC8Options, a as cleanCoverage, b as reportCoverage } from './chunk-defaults.374342ed.js';
16
+ import { c as commonjsGlobal } from './vendor-_commonjsHelpers.addc3445.js';
17
+ import { i as isNodeBuiltin, a as isValidNodeImport, s as slash$1, t as toFilePath, w as withInlineSourcemap, c as createBirpc, V as ViteNodeRunner } from './chunk-vite-node-utils.46e2a803.js';
18
+ import createDebug from 'debug';
19
+ import { c as configDefaults, r as resolveC8Options, a as cleanCoverage, b as reportCoverage } from './chunk-defaults.7d81a6ca.js';
18
20
  import { MessageChannel } from 'worker_threads';
19
21
  import { Tinypool } from 'tinypool';
20
22
  import { performance } from 'perf_hooks';
21
- import { e as stripAnsi, h as stringWidth, i as ansiStyles, j as sliceAnsi, k as setInterval, o as clearInterval, q as cliTruncate, c as setTimeout$1, b as parseStacktrace, r as interpretSourcePos, s as stringify$5, u as unifiedDiff, a as posToNumber, l as lineSplitRE, d as clearTimeout$1 } from './chunk-utils-timers.a0f0fe66.js';
22
- import MagicString from './chunk-magic-string.d5e0e473.js';
23
+ import { e as stripAnsi, h as stringWidth, i as ansiStyles, j as sliceAnsi, k as setInterval, o as clearInterval, q as cliTruncate, c as setTimeout$1, b as parseStacktrace, r as interpretSourcePos, s as stringify$5, u as unifiedDiff, a as posToNumber, l as lineSplitRE, d as clearTimeout$1 } from './chunk-utils-timers.da6ac0a6.js';
24
+ import { resolveModule } from 'local-pkg';
25
+ import MagicString from './chunk-magic-string.41232190.js';
23
26
  import { p as prompts } from './vendor-index.405e58ef.js';
24
27
 
25
- var version = "0.12.5";
28
+ var version = "0.12.8";
26
29
 
27
30
  function stripFinalNewline(input) {
28
31
  const LF = typeof input === 'string' ? '\n' : '\n'.charCodeAt();
@@ -2127,7 +2130,7 @@ var toRegexRange_1 = toRegexRange$1;
2127
2130
  * Licensed under the MIT License.
2128
2131
  */
2129
2132
 
2130
- const util$1 = require$$1;
2133
+ const util$1 = require$$0$1;
2131
2134
  const toRegexRange = toRegexRange_1;
2132
2135
 
2133
2136
  const isObject$1 = val => val !== null && typeof val === 'object' && !Array.isArray(val);
@@ -5164,7 +5167,7 @@ var picomatch_1 = picomatch$1;
5164
5167
  module.exports = picomatch_1;
5165
5168
  } (picomatch$2));
5166
5169
 
5167
- const util = require$$1;
5170
+ const util = require$$0$1;
5168
5171
  const braces = braces_1;
5169
5172
  const picomatch = picomatch$2.exports;
5170
5173
  const utils$b = utils$f;
@@ -5808,7 +5811,7 @@ var stream$4 = {};
5808
5811
  * Copyright (c) 2014-2020 Teambition
5809
5812
  * Licensed under the MIT license.
5810
5813
  */
5811
- const Stream = require$$0$1;
5814
+ const Stream = require$$0$2;
5812
5815
  const PassThrough = Stream.PassThrough;
5813
5816
  const slice = Array.prototype.slice;
5814
5817
 
@@ -7092,7 +7095,7 @@ function callSuccessCallback(callback, entries) {
7092
7095
  var stream$1 = {};
7093
7096
 
7094
7097
  Object.defineProperty(stream$1, "__esModule", { value: true });
7095
- const stream_1$5 = require$$0$1;
7098
+ const stream_1$5 = require$$0$2;
7096
7099
  const async_1$2 = async$2;
7097
7100
  class StreamProvider {
7098
7101
  constructor(_root, _settings) {
@@ -7300,7 +7303,7 @@ class Reader {
7300
7303
  reader.default = Reader;
7301
7304
 
7302
7305
  Object.defineProperty(stream$2, "__esModule", { value: true });
7303
- const stream_1$3 = require$$0$1;
7306
+ const stream_1$3 = require$$0$2;
7304
7307
  const fsStat$1 = out$3;
7305
7308
  const fsWalk$1 = out$2;
7306
7309
  const reader_1$1 = reader;
@@ -7698,7 +7701,7 @@ async$6.default = ProviderAsync;
7698
7701
  var stream = {};
7699
7702
 
7700
7703
  Object.defineProperty(stream, "__esModule", { value: true });
7701
- const stream_1$1 = require$$0$1;
7704
+ const stream_1$1 = require$$0$2;
7702
7705
  const stream_2 = stream$2;
7703
7706
  const provider_1$1 = provider;
7704
7707
  class ProviderStream extends provider_1$1.default {
@@ -8316,7 +8319,8 @@ const hookSpinnerMap = /* @__PURE__ */ new WeakMap();
8316
8319
  const pointer = picocolors.exports.yellow(F_POINTER);
8317
8320
  const skipped = picocolors.exports.dim(picocolors.exports.gray(F_DOWN));
8318
8321
  function getCols(delta = 0) {
8319
- let length = process.stdout.columns;
8322
+ var _a;
8323
+ let length = (_a = process.stdout) == null ? void 0 : _a.columns;
8320
8324
  if (!length || isNaN(length))
8321
8325
  length = 30;
8322
8326
  return Math.max(length + delta, 0);
@@ -8447,6 +8451,7 @@ function elegantSpinner() {
8447
8451
  };
8448
8452
  }
8449
8453
 
8454
+ var _a;
8450
8455
  const BADGE_PADDING = " ";
8451
8456
  const HELP_HINT = `${picocolors.exports.dim("press ")}${picocolors.exports.bold("h")}${picocolors.exports.dim(" to show help")}`;
8452
8457
  const HELP_UPDATE_SNAP = picocolors.exports.dim("press ") + picocolors.exports.bold(picocolors.exports.yellow("u")) + picocolors.exports.dim(" to update snapshot");
@@ -8460,19 +8465,19 @@ class BaseReporter {
8460
8465
  constructor() {
8461
8466
  this.start = 0;
8462
8467
  this.end = 0;
8463
- this.isTTY = process.stdout.isTTY && !process.env.CI;
8468
+ this.isTTY = isNode && ((_a = process.stdout) == null ? void 0 : _a.isTTY) && !process.env.CI;
8464
8469
  this.ctx = void 0;
8465
8470
  this.registerUnhandledRejection();
8466
8471
  }
8467
8472
  onInit(ctx) {
8468
- var _a, _b;
8473
+ var _a2, _b;
8469
8474
  this.ctx = ctx;
8470
8475
  this.ctx.log();
8471
8476
  const versionTest = this.ctx.config.watch ? picocolors.exports.blue(`v${version}`) : picocolors.exports.cyan(`v${version}`);
8472
8477
  const mode = this.ctx.config.watch ? picocolors.exports.blue(" DEV ") : picocolors.exports.cyan(" RUN ");
8473
8478
  this.ctx.log(`${picocolors.exports.inverse(picocolors.exports.bold(mode))} ${versionTest} ${picocolors.exports.gray(this.ctx.config.root)}`);
8474
8479
  if (this.ctx.config.ui)
8475
- this.ctx.log(picocolors.exports.dim(picocolors.exports.green(` UI started at http://${((_a = this.ctx.config.api) == null ? void 0 : _a.host) || "localhost"}:${picocolors.exports.bold(`${this.ctx.server.config.server.port}`)}`)));
8480
+ this.ctx.log(picocolors.exports.dim(picocolors.exports.green(` UI started at http://${((_a2 = this.ctx.config.api) == null ? void 0 : _a2.host) || "localhost"}:${picocolors.exports.bold(`${this.ctx.server.config.server.port}`)}`)));
8476
8481
  else if (this.ctx.config.api)
8477
8482
  this.ctx.log(picocolors.exports.dim(picocolors.exports.green(` API started at http://${((_b = this.ctx.config.api) == null ? void 0 : _b.host) || "localhost"}:${picocolors.exports.bold(`${this.ctx.config.api.port}`)}`)));
8478
8483
  this.ctx.log();
@@ -8498,16 +8503,16 @@ Please, resolve all the errors to make sure your tests are not affected.`));
8498
8503
  }
8499
8504
  }
8500
8505
  onTaskUpdate(packs) {
8501
- var _a, _b, _c;
8506
+ var _a2, _b, _c;
8502
8507
  if (this.isTTY)
8503
8508
  return;
8504
8509
  for (const pack of packs) {
8505
8510
  const task = this.ctx.state.idMap.get(pack[0]);
8506
- if (task && "filepath" in task && ((_a = task.result) == null ? void 0 : _a.state) && ((_b = task.result) == null ? void 0 : _b.state) !== "run") {
8511
+ if (task && "filepath" in task && ((_a2 = task.result) == null ? void 0 : _a2.state) && ((_b = task.result) == null ? void 0 : _b.state) !== "run") {
8507
8512
  const tests = getTests(task);
8508
8513
  const failed = tests.filter((t) => {
8509
- var _a2;
8510
- return ((_a2 = t.result) == null ? void 0 : _a2.state) === "fail";
8514
+ var _a3;
8515
+ return ((_a3 = t.result) == null ? void 0 : _a3.state) === "fail";
8511
8516
  });
8512
8517
  const skipped = tests.filter((t) => t.mode === "skip" || t.mode === "todo");
8513
8518
  let state = picocolors.exports.dim(`${tests.length} test${tests.length > 1 ? "s" : ""}`);
@@ -8563,10 +8568,10 @@ ${picocolors.exports.inverse(picocolors.exports.bold(picocolors.exports.blue(" R
8563
8568
  `);
8564
8569
  }
8565
8570
  shouldLog(log) {
8566
- var _a, _b;
8571
+ var _a2, _b;
8567
8572
  if (this.ctx.config.silent)
8568
8573
  return false;
8569
- const shouldIgnore = (_b = (_a = this.ctx.config).onConsoleLog) == null ? void 0 : _b.call(_a, log.content, log.type);
8574
+ const shouldIgnore = (_b = (_a2 = this.ctx.config).onConsoleLog) == null ? void 0 : _b.call(_a2, log.content, log.type);
8570
8575
  if (shouldIgnore === false)
8571
8576
  return shouldIgnore;
8572
8577
  return true;
@@ -8578,12 +8583,12 @@ ${picocolors.exports.inverse(picocolors.exports.bold(picocolors.exports.blue(" R
8578
8583
  const suites = getSuites(files);
8579
8584
  const tests = getTests(files);
8580
8585
  const failedSuites = suites.filter((i) => {
8581
- var _a;
8582
- return (_a = i.result) == null ? void 0 : _a.error;
8586
+ var _a2;
8587
+ return (_a2 = i.result) == null ? void 0 : _a2.error;
8583
8588
  });
8584
8589
  const failedTests = tests.filter((i) => {
8585
- var _a;
8586
- return ((_a = i.result) == null ? void 0 : _a.state) === "fail";
8590
+ var _a2;
8591
+ return ((_a2 = i.result) == null ? void 0 : _a2.state) === "fail";
8587
8592
  });
8588
8593
  const failedTotal = failedSuites.length + failedTests.length;
8589
8594
  let current = 1;
@@ -8601,8 +8606,8 @@ ${picocolors.exports.inverse(picocolors.exports.bold(picocolors.exports.blue(" R
8601
8606
  }
8602
8607
  const executionTime = this.end - this.start;
8603
8608
  const threadTime = files.reduce((acc, test) => {
8604
- var _a;
8605
- return acc + Math.max(0, ((_a = test.result) == null ? void 0 : _a.duration) || 0) + Math.max(0, test.collectDuration || 0);
8609
+ var _a2;
8610
+ return acc + Math.max(0, ((_a2 = test.result) == null ? void 0 : _a2.duration) || 0) + Math.max(0, test.collectDuration || 0);
8606
8611
  }, 0);
8607
8612
  const padTitle = (str) => picocolors.exports.dim(`${str.padStart(10)} `);
8608
8613
  const time = (time2) => {
@@ -8625,13 +8630,13 @@ ${picocolors.exports.inverse(picocolors.exports.bold(picocolors.exports.blue(" R
8625
8630
  this.ctx.log();
8626
8631
  }
8627
8632
  async printTaskErrors(tasks, errorDivider) {
8628
- var _a;
8633
+ var _a2;
8629
8634
  const errorsQueue = [];
8630
8635
  for (const task of tasks) {
8631
- const error = (_a = task.result) == null ? void 0 : _a.error;
8636
+ const error = (_a2 = task.result) == null ? void 0 : _a2.error;
8632
8637
  const errorItem = (error == null ? void 0 : error.stackStr) && errorsQueue.find((i) => {
8633
- var _a2;
8634
- return ((_a2 = i[0]) == null ? void 0 : _a2.stackStr) === error.stackStr;
8638
+ var _a3;
8639
+ return ((_a3 = i[0]) == null ? void 0 : _a3.stackStr) === error.stackStr;
8635
8640
  });
8636
8641
  if (errorItem)
8637
8642
  errorItem[1].push(task);
@@ -10024,7 +10029,7 @@ function resolveConfig(options, viteConfig) {
10024
10029
  resolved.maxThreads = parseInt(process.env.VITEST_MAX_THREADS);
10025
10030
  if (process.env.VITEST_MIN_THREADS)
10026
10031
  resolved.minThreads = parseInt(process.env.VITEST_MIN_THREADS);
10027
- resolved.setupFiles = toArray(resolved.setupFiles || []).map((file) => resolve(resolved.root, file));
10032
+ resolved.setupFiles = toArray(resolved.setupFiles || []).map((file) => normalize(resolveModule(file, { paths: [resolved.root] })));
10028
10033
  resolved.api = resolveApiConfig(options);
10029
10034
  if (options.related)
10030
10035
  resolved.related = toArray(options.related).map((file) => resolve(resolved.root, file));
@@ -10079,27 +10084,27 @@ function printErrorType(type, ctx) {
10079
10084
  ctx.error(`
10080
10085
  ${picocolors.exports.red(divider(picocolors.exports.bold(picocolors.exports.inverse(` ${type} `))))}`);
10081
10086
  }
10087
+ const skipErrorProperties = [
10088
+ "message",
10089
+ "name",
10090
+ "nameStr",
10091
+ "stack",
10092
+ "cause",
10093
+ "stacks",
10094
+ "stackStr",
10095
+ "type",
10096
+ "showDiff",
10097
+ "actual",
10098
+ "expected",
10099
+ "constructor",
10100
+ "toString"
10101
+ ];
10082
10102
  function getErrorProperties(e) {
10083
10103
  const errorObject = /* @__PURE__ */ Object.create(null);
10084
10104
  if (e.name === "AssertionError")
10085
10105
  return errorObject;
10086
- const skip = [
10087
- "message",
10088
- "name",
10089
- "nameStr",
10090
- "stack",
10091
- "cause",
10092
- "stacks",
10093
- "stackStr",
10094
- "type",
10095
- "showDiff",
10096
- "actual",
10097
- "expected",
10098
- "constructor",
10099
- "toString"
10100
- ];
10101
10106
  for (const key of Object.getOwnPropertyNames(e)) {
10102
- if (!skip.includes(key))
10107
+ if (!skipErrorProperties.includes(key))
10103
10108
  errorObject[key] = e[key];
10104
10109
  }
10105
10110
  return errorObject;
@@ -10161,12 +10166,13 @@ function printStack(ctx, stack, highlight, errorProperties, onStack) {
10161
10166
  }
10162
10167
  }
10163
10168
  function generateCodeFrame(source, indent = 0, start = 0, end, range = 2) {
10169
+ var _a;
10164
10170
  start = posToNumber(source, start);
10165
10171
  end = end || start;
10166
10172
  const lines = source.split(lineSplitRE);
10167
10173
  let count = 0;
10168
10174
  let res = [];
10169
- const columns = process.stdout.columns || 80;
10175
+ const columns = ((_a = process.stdout) == null ? void 0 : _a.columns) || 80;
10170
10176
  function lineNo(no = "") {
10171
10177
  return picocolors.exports.gray(`${String(no).padStart(3, " ")}| `);
10172
10178
  }
@@ -10468,9 +10474,10 @@ class Vitest {
10468
10474
  this.console.error(...args);
10469
10475
  }
10470
10476
  clearScreen() {
10477
+ var _a;
10471
10478
  if (this.server.config.clearScreen === false)
10472
10479
  return;
10473
- const repeatCount = process.stdout.rows - 2;
10480
+ const repeatCount = (((_a = process.stdout) == null ? void 0 : _a.rows) ?? 0) - 2;
10474
10481
  const blank = repeatCount > 0 ? "\n".repeat(repeatCount) : "";
10475
10482
  this.console.log(blank);
10476
10483
  readline.cursorTo(process.stdout, 0, 0);
@@ -10914,12 +10921,13 @@ async function VitestPlugin(options = {}, ctx = new Vitest()) {
10914
10921
  }
10915
10922
  }
10916
10923
  options.defines = defines;
10917
- return {
10924
+ const open = preOptions.ui && preOptions.open ? preOptions.uiBase ?? "/__vitest__/" : void 0;
10925
+ const config = {
10918
10926
  resolve: {
10919
10927
  mainFields: []
10920
10928
  },
10921
10929
  server: __spreadProps(__spreadValues({}, preOptions.api), {
10922
- open: preOptions.ui && preOptions.open ? preOptions.uiBase ?? "/__vitest__/" : void 0,
10930
+ open,
10923
10931
  preTransformRequests: false
10924
10932
  }),
10925
10933
  cacheDir: void 0,
@@ -10928,6 +10936,7 @@ async function VitestPlugin(options = {}, ctx = new Vitest()) {
10928
10936
  entries: []
10929
10937
  }
10930
10938
  };
10939
+ return config;
10931
10940
  },
10932
10941
  async configResolved(viteConfig) {
10933
10942
  var _b, _c, _d, _e;
@@ -10949,7 +10958,7 @@ async function VitestPlugin(options = {}, ctx = new Vitest()) {
10949
10958
  await ctx.setServer(options, server);
10950
10959
  haveStarted = true;
10951
10960
  if (options.api && options.watch)
10952
- (await import('./chunk-api-setup.62de6413.js')).setup(ctx);
10961
+ (await import('./chunk-api-setup.9ccd19b5.js')).setup(ctx);
10953
10962
  if (!options.watch)
10954
10963
  await server.watcher.close();
10955
10964
  }