vitest 0.32.0 → 0.32.1

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/dist/browser.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export { startTests } from '@vitest/runner';
2
- export { s as setupCommonEnv } from './vendor-setup.common.a35ee78b.js';
2
+ export { s as setupCommonEnv } from './vendor-setup.common.f1cf2231.js';
3
3
  export { g as getCoverageProvider, a as startCoverageInsideWorker, s as stopCoverageInsideWorker, t as takeCoverageInsideWorker } from './vendor-coverage.de2180ed.js';
4
4
  import '@vitest/utils';
5
5
  import './vendor-run-once.69ce7172.js';
package/dist/child.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { performance } from 'node:perf_hooks';
1
2
  import v8 from 'node:v8';
2
3
  import { c as createBirpc } from './vendor-index.87ab04c3.js';
3
4
  import { parseRegexp } from '@vitest/utils';
@@ -3,7 +3,7 @@ import p from 'path';
3
3
  import require$$0$1 from 'util';
4
4
  import require$$0$3 from 'child_process';
5
5
  import { p as pathKey, s as signalExit, m as mergeStream$1, g as getStream$1, c as crossSpawn$1 } from './vendor-index.c1e09929.js';
6
- import { o as onetime$1 } from './vendor-cli-api.897427d4.js';
6
+ import { o as onetime$1 } from './vendor-cli-api.17011d0a.js';
7
7
  import require$$0$2 from 'os';
8
8
  import 'node:buffer';
9
9
  import 'node:path';
@@ -1,7 +1,7 @@
1
1
  import { g as globalApis } from './vendor-constants.538d9b49.js';
2
- import { i as index } from './vendor-index.b46c103a.js';
2
+ import { i as index } from './vendor-index.0f133dbe.js';
3
3
  import '@vitest/runner';
4
- import './vendor-vi.55d2bc52.js';
4
+ import './vendor-vi.74cf3ef7.js';
5
5
  import '@vitest/runner/utils';
6
6
  import '@vitest/utils';
7
7
  import './vendor-index.fad2598b.js';
package/dist/cli.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { normalize } from 'pathe';
2
2
  import cac from 'cac';
3
3
  import c from 'picocolors';
4
- import { v as version, s as startVitest, d as divider } from './vendor-cli-api.897427d4.js';
4
+ import { v as version, s as startVitest, d as divider } from './vendor-cli-api.17011d0a.js';
5
5
  import './vendor-index.fad2598b.js';
6
6
  import { t as toArray } from './vendor-index.87ab04c3.js';
7
7
  import './vendor-constants.538d9b49.js';
package/dist/entry.js CHANGED
@@ -2,7 +2,7 @@ import { performance } from 'node:perf_hooks';
2
2
  import { startTests } from '@vitest/runner';
3
3
  import { resolve } from 'pathe';
4
4
  import { c as resetModules } from './vendor-index.fad2598b.js';
5
- import { R as RealDate, d as globalExpect, s as setupChaiConfig, v as vi } from './vendor-vi.55d2bc52.js';
5
+ import { R as RealDate, d as globalExpect, s as setupChaiConfig, v as vi } from './vendor-vi.74cf3ef7.js';
6
6
  import { d as distDir } from './vendor-paths.84fc7a99.js';
7
7
  import { a as startCoverageInsideWorker, t as takeCoverageInsideWorker, s as stopCoverageInsideWorker } from './vendor-coverage.de2180ed.js';
8
8
  import { createRequire } from 'node:module';
@@ -12,8 +12,8 @@ import { setupColors, createColors, getSafeTimers } from '@vitest/utils';
12
12
  import { e as environments } from './vendor-index.75f2b63d.js';
13
13
  import { NodeSnapshotEnvironment } from '@vitest/snapshot/environment';
14
14
  import { r as rpc } from './vendor-rpc.4d3d7a54.js';
15
- import { i as index } from './vendor-index.b46c103a.js';
16
- import { s as setupCommonEnv } from './vendor-setup.common.a35ee78b.js';
15
+ import { i as index } from './vendor-index.0f133dbe.js';
16
+ import { s as setupCommonEnv } from './vendor-setup.common.f1cf2231.js';
17
17
  import { g as getWorkerState } from './vendor-global.6795f91f.js';
18
18
  import 'std-env';
19
19
  import '@vitest/runner/utils';
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  export { afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, suite, test } from '@vitest/runner';
2
- export { e as bench, c as createExpect, d as expect, s as setupChaiConfig, v as vi, f as vitest } from './vendor-vi.55d2bc52.js';
2
+ export { e as bench, c as createExpect, d as expect, s as setupChaiConfig, v as vi, f as vitest } from './vendor-vi.74cf3ef7.js';
3
3
  export { i as isFirstRun, a as runOnce } from './vendor-run-once.69ce7172.js';
4
- import { d as dist } from './vendor-index.b46c103a.js';
5
- export { b as assertType, g as getRunningMode, a as isWatchMode } from './vendor-index.b46c103a.js';
4
+ import { d as dist } from './vendor-index.0f133dbe.js';
5
+ export { b as assertType, g as getRunningMode, a as isWatchMode } from './vendor-index.0f133dbe.js';
6
6
  import * as chai from 'chai';
7
7
  export { chai };
8
8
  export { assert, should } from 'chai';
package/dist/node.d.ts CHANGED
@@ -19,6 +19,8 @@ declare function createVitest(mode: VitestRunMode, options: UserConfig, viteOver
19
19
 
20
20
  declare function VitestPlugin(options?: UserConfig, ctx?: Vitest): Promise<Plugin[]>;
21
21
 
22
+ declare function registerConsoleShortcuts(ctx: Vitest): void;
23
+
22
24
  type Key = string | symbol;
23
25
  declare class VitestMocker {
24
26
  executor: VitestExecutor;
@@ -74,4 +76,4 @@ declare class BaseSequencer implements TestSequencer {
74
76
  sort(files: WorkspaceSpec[]): Promise<WorkspaceSpec[]>;
75
77
  }
76
78
 
77
- export { BaseSequencer, ExecuteOptions, TestSequencer, Vitest, VitestExecutor, VitestPlugin, WorkspaceSpec, createVitest };
79
+ export { BaseSequencer, ExecuteOptions, TestSequencer, Vitest, VitestExecutor, VitestPlugin, WorkspaceSpec, createVitest, registerConsoleShortcuts };
package/dist/node.js CHANGED
@@ -1,4 +1,4 @@
1
- export { B as BaseSequencer, V as VitestPlugin, c as createVitest, s as startVitest } from './vendor-cli-api.897427d4.js';
1
+ export { B as BaseSequencer, V as VitestPlugin, c as createVitest, r as registerConsoleShortcuts, s as startVitest } from './vendor-cli-api.17011d0a.js';
2
2
  export { V as VitestExecutor } from './vendor-execute.001ae440.js';
3
3
  import 'pathe';
4
4
  import './vendor-constants.538d9b49.js';
package/dist/runners.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { setState, GLOBAL_EXPECT, getState } from '@vitest/expect';
2
- import { g as getSnapshotClient, c as createExpect, v as vi, a as getBenchOptions, b as getBenchFn } from './vendor-vi.55d2bc52.js';
2
+ import { g as getSnapshotClient, c as createExpect, v as vi, a as getBenchOptions, b as getBenchFn } from './vendor-vi.74cf3ef7.js';
3
3
  import './vendor-index.fad2598b.js';
4
4
  import { r as rpc } from './vendor-rpc.4d3d7a54.js';
5
5
  import { g as getFullName } from './vendor-tasks.f9d75aed.js';
@@ -60,7 +60,7 @@ function _mergeNamespaces(n, m) {
60
60
  return Object.freeze(n);
61
61
  }
62
62
 
63
- var version$1 = "0.32.0";
63
+ var version$1 = "0.32.1";
64
64
 
65
65
  const __dirname$1 = url.fileURLToPath(new URL(".", import.meta.url));
66
66
  async function ensurePackageInstalled(dependency, root, errorMessage) {
@@ -81,7 +81,7 @@ async function ensurePackageInstalled(dependency, root, errorMessage) {
81
81
  message: c.reset(`Do you want to install ${c.green(dependency)}?`)
82
82
  });
83
83
  if (install) {
84
- await (await import('./chunk-install-pkg.ce602c20.js')).installPackage(dependency, { dev: true });
84
+ await (await import('./chunk-install-pkg.65daeadb.js')).installPackage(dependency, { dev: true });
85
85
  process.stderr.write(c.yellow(`
86
86
  Package ${dependency} installed, re-run the command to start.
87
87
  `));
@@ -11173,7 +11173,7 @@ createLogUpdate(process$1.stdout);
11173
11173
 
11174
11174
  createLogUpdate(process$1.stderr);
11175
11175
 
11176
- var version = "0.32.0";
11176
+ var version = "0.32.1";
11177
11177
 
11178
11178
  const comma = ','.charCodeAt(0);
11179
11179
  const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
@@ -12385,7 +12385,7 @@ As a temporary workaround you can try to inline the package by updating your con
12385
12385
  deps: {
12386
12386
  inline: [
12387
12387
  ${c.yellow(c.bold(`"${name}"`))}
12388
- }
12388
+ ]
12389
12389
  }
12390
12390
  }
12391
12391
  }
@@ -12398,13 +12398,18 @@ function printModuleWarningForSourceCode(logger, path) {
12398
12398
  ));
12399
12399
  }
12400
12400
  function displayDiff(diff, console) {
12401
- console.error(`
12401
+ if (diff)
12402
+ console.error(`
12402
12403
  ${diff}
12403
12404
  `);
12404
12405
  }
12405
12406
  function printErrorMessage(error, logger) {
12406
12407
  const errorName = error.name || error.nameStr || "Unknown Error";
12407
- logger.error(c.red(`${c.bold(errorName)}: ${error.message}`));
12408
+ if (error.message.length > 5e3) {
12409
+ logger.error(`${c.red(c.bold(errorName))}: ${error.message}`);
12410
+ } else {
12411
+ logger.error(c.red(`${c.bold(errorName)}: ${error.message}`));
12412
+ }
12408
12413
  }
12409
12414
  function printStack(ctx, stack, highlight, errorProperties, onStack) {
12410
12415
  const logger = ctx.logger;
@@ -12605,9 +12610,6 @@ function isIdentifier(node) {
12605
12610
  return node.type === "Identifier";
12606
12611
  }
12607
12612
  function transformImportSpecifiers(node) {
12608
- const specifiers = node.specifiers;
12609
- if (specifiers.length === 1 && specifiers[0].type === "ImportNamespaceSpecifier")
12610
- return specifiers[0].local.name;
12611
12613
  const dynamicImports = node.specifiers.map((specifier) => {
12612
12614
  if (specifier.type === "ImportDefaultSpecifier")
12613
12615
  return `default: ${specifier.local.name}`;
@@ -12649,10 +12651,23 @@ ${err.message}`);
12649
12651
  let hoistedVitestImports = "";
12650
12652
  const transformImportDeclaration = (node) => {
12651
12653
  const source = node.source.value;
12654
+ const namespace = node.specifiers.find((specifier) => specifier.type === "ImportNamespaceSpecifier");
12655
+ let code2 = "";
12656
+ if (namespace)
12657
+ code2 += `const ${namespace.local.name} = await import('${source}')
12658
+ `;
12652
12659
  const specifiers = transformImportSpecifiers(node);
12653
- const code2 = specifiers ? `const ${specifiers} = await import('${source}')
12654
- ` : `await import('${source}')
12660
+ if (specifiers) {
12661
+ if (namespace)
12662
+ code2 += `const ${specifiers} = ${namespace.local.name}
12663
+ `;
12664
+ else
12665
+ code2 += `const ${specifiers} = await import('${source}')
12666
+ `;
12667
+ } else if (!namespace) {
12668
+ code2 += `await import('${source}')
12655
12669
  `;
12670
+ }
12656
12671
  return code2;
12657
12672
  };
12658
12673
  function hoistImport(node) {
@@ -13094,6 +13109,37 @@ function resolveOptimizerConfig(testOptionc, viteOptions, testConfig) {
13094
13109
  }
13095
13110
  return newConfig;
13096
13111
  }
13112
+ function deleteDefineConfig(viteConfig) {
13113
+ const defines = {};
13114
+ if (viteConfig.define) {
13115
+ delete viteConfig.define["import.meta.vitest"];
13116
+ delete viteConfig.define["process.env"];
13117
+ delete viteConfig.define.process;
13118
+ delete viteConfig.define.global;
13119
+ }
13120
+ for (const key in viteConfig.define) {
13121
+ const val = viteConfig.define[key];
13122
+ let replacement;
13123
+ try {
13124
+ replacement = typeof val === "string" ? JSON.parse(val) : val;
13125
+ } catch {
13126
+ continue;
13127
+ }
13128
+ if (key.startsWith("import.meta.env.")) {
13129
+ const envKey = key.slice("import.meta.env.".length);
13130
+ process.env[envKey] = replacement;
13131
+ delete viteConfig.define[key];
13132
+ } else if (key.startsWith("process.env.")) {
13133
+ const envKey = key.slice("process.env.".length);
13134
+ process.env[envKey] = replacement;
13135
+ delete viteConfig.define[key];
13136
+ } else if (!key.includes(".")) {
13137
+ defines[key] = replacement;
13138
+ delete viteConfig.define[key];
13139
+ }
13140
+ }
13141
+ return defines;
13142
+ }
13097
13143
 
13098
13144
  function VitestResolver(ctx) {
13099
13145
  return {
@@ -13119,32 +13165,9 @@ function WorkspaceVitestPlugin(project, options) {
13119
13165
  options() {
13120
13166
  this.meta.watchMode = false;
13121
13167
  },
13122
- // TODO: refactor so we don't have the same code here and in plugins/index.ts
13123
13168
  config(viteConfig) {
13124
13169
  var _a, _b, _c, _d, _e, _f, _g, _h;
13125
- if (viteConfig.define) {
13126
- delete viteConfig.define["import.meta.vitest"];
13127
- delete viteConfig.define["process.env"];
13128
- }
13129
- const env = {};
13130
- for (const key in viteConfig.define) {
13131
- const val = viteConfig.define[key];
13132
- let replacement;
13133
- try {
13134
- replacement = typeof val === "string" ? JSON.parse(val) : val;
13135
- } catch {
13136
- continue;
13137
- }
13138
- if (key.startsWith("import.meta.env.")) {
13139
- const envKey = key.slice("import.meta.env.".length);
13140
- env[envKey] = replacement;
13141
- delete viteConfig.define[key];
13142
- } else if (key.startsWith("process.env.")) {
13143
- const envKey = key.slice("process.env.".length);
13144
- env[envKey] = replacement;
13145
- delete viteConfig.define[key];
13146
- }
13147
- }
13170
+ const env = deleteDefineConfig(viteConfig);
13148
13171
  const testConfig = viteConfig.test || {};
13149
13172
  const root = testConfig.root || viteConfig.root || options.root;
13150
13173
  let name = testConfig.name;
@@ -14099,32 +14122,7 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
14099
14122
  removeUndefinedValues(viteConfig.test ?? {})
14100
14123
  );
14101
14124
  testConfig.api = resolveApiServerConfig(testConfig);
14102
- if (viteConfig.define) {
14103
- delete viteConfig.define["import.meta.vitest"];
14104
- delete viteConfig.define["process.env"];
14105
- }
14106
- const defines = {};
14107
- for (const key in viteConfig.define) {
14108
- const val = viteConfig.define[key];
14109
- let replacement;
14110
- try {
14111
- replacement = typeof val === "string" ? JSON.parse(val) : val;
14112
- } catch {
14113
- continue;
14114
- }
14115
- if (key.startsWith("import.meta.env.")) {
14116
- const envKey = key.slice("import.meta.env.".length);
14117
- process.env[envKey] = replacement;
14118
- delete viteConfig.define[key];
14119
- } else if (key.startsWith("process.env.")) {
14120
- const envKey = key.slice("process.env.".length);
14121
- process.env[envKey] = replacement;
14122
- delete viteConfig.define[key];
14123
- } else if (!key.includes(".")) {
14124
- defines[key] = replacement;
14125
- delete viteConfig.define[key];
14126
- }
14127
- }
14125
+ const defines = deleteDefineConfig(viteConfig);
14128
14126
  options.defines = defines;
14129
14127
  let open;
14130
14128
  if (testConfig.ui && testConfig.open)
@@ -20687,4 +20685,4 @@ async function startVitest(mode, cliFilters = [], options = {}, viteOverrides) {
20687
20685
  return ctx;
20688
20686
  }
20689
20687
 
20690
- export { BaseSequencer as B, VitestPlugin as V, createVitest as c, divider as d, onetime$1 as o, startVitest as s, version$1 as v };
20688
+ export { BaseSequencer as B, VitestPlugin as V, createVitest as c, divider as d, onetime$1 as o, registerConsoleShortcuts as r, startVitest as s, version$1 as v };
@@ -1,5 +1,5 @@
1
1
  import { afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, suite, test } from '@vitest/runner';
2
- import { e as bench, c as createExpect, d as globalExpect, s as setupChaiConfig, v as vi, f as vitest } from './vendor-vi.55d2bc52.js';
2
+ import { e as bench, c as createExpect, d as globalExpect, s as setupChaiConfig, v as vi, f as vitest } from './vendor-vi.74cf3ef7.js';
3
3
  import { i as isFirstRun, a as runOnce } from './vendor-run-once.69ce7172.js';
4
4
  import * as chai from 'chai';
5
5
  import { assert, should } from 'chai';
@@ -10,7 +10,7 @@ async function setupCommonEnv(config) {
10
10
  globalSetup = true;
11
11
  setSafeTimers();
12
12
  if (config.globals)
13
- (await import('./chunk-integrations-globals.277730ba.js')).registerApiGlobally();
13
+ (await import('./chunk-integrations-globals.a56dee90.js')).registerApiGlobally();
14
14
  }
15
15
  function setupDefines(defines) {
16
16
  for (const key in defines)
@@ -388,6 +388,9 @@ function createExpect(test) {
388
388
  });
389
389
  return assert2;
390
390
  };
391
+ expect.unreachable = (message) => {
392
+ chai$1.assert.fail(`expected${message ? ` "${message}" ` : " "}not to be reached`);
393
+ };
391
394
  function assertions(expected) {
392
395
  const errorGen = () => new Error(`expected number of assertions to be ${expected}, but got ${expect.getState().assertionCalls}`);
393
396
  if (Error.captureStackTrace)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vitest",
3
3
  "type": "module",
4
- "version": "0.32.0",
4
+ "version": "0.32.1",
5
5
  "description": "A blazing fast unit test framework powered by Vite",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -148,12 +148,12 @@
148
148
  "tinypool": "^0.5.0",
149
149
  "vite": "^3.0.0 || ^4.0.0",
150
150
  "why-is-node-running": "^2.2.2",
151
- "@vitest/utils": "0.32.0",
152
- "@vitest/spy": "0.32.0",
153
- "@vitest/runner": "0.32.0",
154
- "@vitest/snapshot": "0.32.0",
155
- "vite-node": "0.32.0",
156
- "@vitest/expect": "0.32.0"
151
+ "@vitest/expect": "0.32.1",
152
+ "@vitest/snapshot": "0.32.1",
153
+ "@vitest/runner": "0.32.1",
154
+ "vite-node": "0.32.1",
155
+ "@vitest/spy": "0.32.1",
156
+ "@vitest/utils": "0.32.1"
157
157
  },
158
158
  "devDependencies": {
159
159
  "@ampproject/remapping": "^2.2.1",