vitest 0.12.2 → 0.12.5

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 (25) hide show
  1. package/LICENSE.md +72 -0
  2. package/dist/{chunk-api-setup.ed61899f.js → chunk-api-setup.62de6413.js} +4 -4
  3. package/dist/{chunk-constants.0567483c.js → chunk-constants.153353ee.js} +1 -1
  4. package/dist/{chunk-defaults.ecb46baf.js → chunk-defaults.374342ed.js} +1 -1
  5. package/dist/{chunk-install-pkg.73b84ae1.js → chunk-install-pkg.eb979c48.js} +11 -9
  6. package/dist/chunk-integrations-globals.4fea033a.js +25 -0
  7. package/dist/{chunk-runtime-chain.221b8dcb.js → chunk-runtime-chain.eb563278.js} +12 -9
  8. package/dist/{chunk-runtime-mocker.acd615bd.js → chunk-runtime-mocker.efd6b7ac.js} +3 -3
  9. package/dist/{chunk-runtime-rpc.63398738.js → chunk-runtime-rpc.ef131645.js} +1 -1
  10. package/dist/{chunk-utils-global.a5a8641f.js → chunk-utils-global.03413604.js} +29 -9
  11. package/dist/{chunk-utils-timers.f25e8f44.js → chunk-utils-timers.a0f0fe66.js} +1 -1
  12. package/dist/{chunk-vite-node-externalize.2c1fbe22.js → chunk-vite-node-externalize.8560ca65.js} +67 -52
  13. package/dist/{chunk-vite-node-utils.1536f168.js → chunk-vite-node-utils.1064f66b.js} +1067 -3
  14. package/dist/cli.js +7 -8
  15. package/dist/entry.js +6 -10
  16. package/dist/index.d.ts +9 -2
  17. package/dist/index.js +4 -5
  18. package/dist/node.d.ts +9 -2
  19. package/dist/node.js +10 -11
  20. package/dist/{vendor-entry.3adaf0b2.js → vendor-entry.5b810598.js} +21 -13
  21. package/dist/{vendor-index.40be925a.js → vendor-index.4e550a2c.js} +5 -5
  22. package/dist/worker.js +5 -5
  23. package/package.json +3 -3
  24. package/dist/chunk-integrations-globals.60fc66ef.js +0 -29
  25. package/dist/vendor-_commonjsHelpers.addc3445.js +0 -3
package/dist/cli.js CHANGED
@@ -1,14 +1,13 @@
1
1
  import { EventEmitter } from 'events';
2
- import { p as picocolors } from './chunk-utils-global.a5a8641f.js';
3
- import { v as version, s as startVitest, d as divider } from './chunk-vite-node-externalize.2c1fbe22.js';
2
+ import { p as picocolors } from './chunk-utils-global.03413604.js';
3
+ import { v as version, s as startVitest, d as divider } from './chunk-vite-node-externalize.8560ca65.js';
4
4
  import 'tty';
5
5
  import 'local-pkg';
6
6
  import 'path';
7
7
  import 'buffer';
8
8
  import 'child_process';
9
9
  import 'process';
10
- import './vendor-index.40be925a.js';
11
- import './vendor-_commonjsHelpers.addc3445.js';
10
+ import './vendor-index.4e550a2c.js';
12
11
  import 'fs';
13
12
  import 'assert';
14
13
  import 'stream';
@@ -16,16 +15,16 @@ import 'util';
16
15
  import 'url';
17
16
  import 'os';
18
17
  import 'vite';
19
- import './chunk-constants.0567483c.js';
18
+ import './chunk-constants.153353ee.js';
20
19
  import 'readline';
21
- import './chunk-vite-node-utils.1536f168.js';
20
+ import './chunk-vite-node-utils.1064f66b.js';
22
21
  import 'module';
23
22
  import 'vm';
24
- import './chunk-defaults.ecb46baf.js';
23
+ import './chunk-defaults.374342ed.js';
25
24
  import 'worker_threads';
26
25
  import 'tinypool';
27
26
  import 'perf_hooks';
28
- import './chunk-utils-timers.f25e8f44.js';
27
+ import './chunk-utils-timers.a0f0fe66.js';
29
28
  import './chunk-magic-string.d5e0e473.js';
30
29
  import './vendor-index.405e58ef.js';
31
30
 
package/dist/entry.js CHANGED
@@ -1,20 +1,16 @@
1
- export { r as run } from './vendor-entry.3adaf0b2.js';
1
+ export { r as run } from './vendor-entry.5b810598.js';
2
2
  import 'fs';
3
- import './chunk-utils-global.a5a8641f.js';
3
+ import './chunk-utils-global.03413604.js';
4
4
  import 'tty';
5
5
  import 'local-pkg';
6
6
  import 'path';
7
- import 'console';
8
- import 'stream';
9
- import './chunk-runtime-chain.221b8dcb.js';
7
+ import './chunk-runtime-chain.eb563278.js';
10
8
  import 'chai';
11
- import './vendor-_commonjsHelpers.addc3445.js';
12
- import './chunk-runtime-rpc.63398738.js';
13
- import './chunk-utils-timers.f25e8f44.js';
9
+ import './chunk-runtime-rpc.ef131645.js';
10
+ import './chunk-utils-timers.a0f0fe66.js';
14
11
  import './chunk-integrations-spy.bee66426.js';
15
12
  import 'tinyspy';
16
13
  import 'util';
17
- import './chunk-defaults.ecb46baf.js';
14
+ import './chunk-defaults.374342ed.js';
18
15
  import 'module';
19
16
  import 'url';
20
- import 'crypto';
package/dist/index.d.ts CHANGED
@@ -445,14 +445,14 @@ declare class Vitest {
445
445
  private _onRestartListeners;
446
446
  constructor();
447
447
  setServer(options: UserConfig, server: ViteDevServer): Promise<void>;
448
- getConfig(): ResolvedConfig;
448
+ getSerializableConfig(): ResolvedConfig;
449
449
  start(filters?: string[]): Promise<void>;
450
450
  private getTestDependencies;
451
451
  filterTestsBySource(tests: string[]): Promise<string[]>;
452
452
  runFiles(files: string[]): Promise<void>;
453
453
  rerunFiles(files?: string[], trigger?: string): Promise<void>;
454
454
  changeNamePattern(pattern: string, files?: string[], trigger?: string): Promise<void>;
455
- returnFailed(): Promise<void>;
455
+ rerunFailed(): Promise<void>;
456
456
  updateSnapshot(files?: string[]): Promise<void>;
457
457
  log(...args: any[]): void;
458
458
  error(...args: any[]): void;
@@ -491,6 +491,7 @@ declare abstract class BaseReporter implements Reporter {
491
491
  onWatcherStart(): Promise<void>;
492
492
  onWatcherRerun(files: string[], trigger?: string): Promise<void>;
493
493
  onUserConsoleLog(log: UserConsoleLog): void;
494
+ shouldLog(log: UserConsoleLog): boolean;
494
495
  onServerRestart(): void;
495
496
  reportSummary(files: File[]): Promise<void>;
496
497
  private printTaskErrors;
@@ -1240,6 +1241,12 @@ interface InlineConfig {
1240
1241
  * Options for @sinon/fake-timers
1241
1242
  */
1242
1243
  fakeTimers?: FakeTimerInstallOpts;
1244
+ /**
1245
+ * Custom handler for console.log in tests.
1246
+ *
1247
+ * Return `false` to ignore the log.
1248
+ */
1249
+ onConsoleLog?: (log: string, type: 'stdout' | 'stderr') => false | void;
1243
1250
  }
1244
1251
  interface UserConfig extends InlineConfig {
1245
1252
  /**
package/dist/index.js CHANGED
@@ -1,13 +1,12 @@
1
- export { c as afterAll, f as afterEach, b as beforeAll, e as beforeEach, g as createExpect, d as describe, h as expect, k as getRunningMode, a as isFirstRun, l as isWatchMode, i as it, r as runOnce, s as suite, t as test, j as vi, v as vitest, w as withCallback } from './chunk-runtime-chain.221b8dcb.js';
1
+ export { c as afterAll, f as afterEach, b as beforeAll, e as beforeEach, g as createExpect, d as describe, h as expect, k as getRunningMode, a as isFirstRun, l as isWatchMode, i as it, r as runOnce, s as suite, t as test, j as vi, v as vitest, w as withCallback } from './chunk-runtime-chain.eb563278.js';
2
2
  export { assert, default as chai, should } from 'chai';
3
- import './vendor-_commonjsHelpers.addc3445.js';
4
- import './chunk-runtime-rpc.63398738.js';
5
- import './chunk-utils-global.a5a8641f.js';
3
+ import './chunk-utils-global.03413604.js';
6
4
  import 'tty';
7
5
  import 'local-pkg';
8
6
  import 'path';
7
+ import './chunk-runtime-rpc.ef131645.js';
9
8
  import 'fs';
10
- import './chunk-utils-timers.f25e8f44.js';
9
+ import './chunk-utils-timers.a0f0fe66.js';
11
10
  import './chunk-integrations-spy.bee66426.js';
12
11
  import 'tinyspy';
13
12
  import 'util';
package/dist/node.d.ts CHANGED
@@ -291,6 +291,7 @@ declare abstract class BaseReporter implements Reporter {
291
291
  onWatcherStart(): Promise<void>;
292
292
  onWatcherRerun(files: string[], trigger?: string): Promise<void>;
293
293
  onUserConsoleLog(log: UserConsoleLog): void;
294
+ shouldLog(log: UserConsoleLog): boolean;
294
295
  onServerRestart(): void;
295
296
  reportSummary(files: File[]): Promise<void>;
296
297
  private printTaskErrors;
@@ -942,6 +943,12 @@ interface InlineConfig {
942
943
  * Options for @sinon/fake-timers
943
944
  */
944
945
  fakeTimers?: FakeTimerInstallOpts;
946
+ /**
947
+ * Custom handler for console.log in tests.
948
+ *
949
+ * Return `false` to ignore the log.
950
+ */
951
+ onConsoleLog?: (log: string, type: 'stdout' | 'stderr') => false | void;
945
952
  }
946
953
  interface UserConfig extends InlineConfig {
947
954
  /**
@@ -1048,14 +1055,14 @@ declare class Vitest {
1048
1055
  private _onRestartListeners;
1049
1056
  constructor();
1050
1057
  setServer(options: UserConfig, server: ViteDevServer): Promise<void>;
1051
- getConfig(): ResolvedConfig;
1058
+ getSerializableConfig(): ResolvedConfig;
1052
1059
  start(filters?: string[]): Promise<void>;
1053
1060
  private getTestDependencies;
1054
1061
  filterTestsBySource(tests: string[]): Promise<string[]>;
1055
1062
  runFiles(files: string[]): Promise<void>;
1056
1063
  rerunFiles(files?: string[], trigger?: string): Promise<void>;
1057
1064
  changeNamePattern(pattern: string, files?: string[], trigger?: string): Promise<void>;
1058
- returnFailed(): Promise<void>;
1065
+ rerunFailed(): Promise<void>;
1059
1066
  updateSnapshot(files?: string[]): Promise<void>;
1060
1067
  log(...args: any[]): void;
1061
1068
  error(...args: any[]): void;
package/dist/node.js CHANGED
@@ -1,11 +1,13 @@
1
- export { V as VitestPlugin, c as createVitest, s as startVitest } from './chunk-vite-node-externalize.2c1fbe22.js';
2
- export { V as VitestRunner } from './chunk-runtime-mocker.acd615bd.js';
1
+ export { V as VitestPlugin, c as createVitest, s as startVitest } from './chunk-vite-node-externalize.8560ca65.js';
2
+ export { V as VitestRunner } from './chunk-runtime-mocker.efd6b7ac.js';
3
3
  import 'buffer';
4
4
  import 'path';
5
5
  import 'child_process';
6
6
  import 'process';
7
- import './vendor-index.40be925a.js';
8
- import './vendor-_commonjsHelpers.addc3445.js';
7
+ import './vendor-index.4e550a2c.js';
8
+ import './chunk-utils-global.03413604.js';
9
+ import 'tty';
10
+ import 'local-pkg';
9
11
  import 'fs';
10
12
  import 'assert';
11
13
  import 'events';
@@ -13,19 +15,16 @@ import 'stream';
13
15
  import 'util';
14
16
  import 'url';
15
17
  import 'os';
16
- import './chunk-utils-global.a5a8641f.js';
17
- import 'tty';
18
- import 'local-pkg';
19
18
  import 'vite';
20
- import './chunk-constants.0567483c.js';
19
+ import './chunk-constants.153353ee.js';
21
20
  import 'readline';
22
- import './chunk-vite-node-utils.1536f168.js';
21
+ import './chunk-vite-node-utils.1064f66b.js';
23
22
  import 'module';
24
23
  import 'vm';
25
- import './chunk-defaults.ecb46baf.js';
24
+ import './chunk-defaults.374342ed.js';
26
25
  import 'worker_threads';
27
26
  import 'tinypool';
28
27
  import 'perf_hooks';
29
- import './chunk-utils-timers.f25e8f44.js';
28
+ import './chunk-utils-timers.a0f0fe66.js';
30
29
  import './chunk-magic-string.d5e0e473.js';
31
30
  import './vendor-index.405e58ef.js';
@@ -1,14 +1,11 @@
1
1
  import { promises } from 'fs';
2
- import { a as getWorkerState, t as toArray, G as clone, E as getType, l as relative, H as partitionSuiteChildren, I as hasTests, q as hasFailed, o as getFullName, r as resetModules } from './chunk-utils-global.a5a8641f.js';
3
- import { Console } from 'console';
4
- import { Writable } from 'stream';
2
+ import { I as isNode, a as getWorkerState, t as toArray, J as clone, G as getType, m as relative, K as partitionSuiteChildren, L as hasTests, u as hasFailed, q as getFullName, r as resetModules } from './chunk-utils-global.03413604.js';
5
3
  import { importModule } from 'local-pkg';
6
- import { s as suite, t as test, d as describe, i as it, r as runOnce, a as isFirstRun, b as beforeAll, c as afterAll, e as beforeEach, f as afterEach, w as withCallback, g as createExpect, h as expect, v as vitest, j as vi, k as getRunningMode, l as isWatchMode, m as resetRunOnceCounter, R as RealDate, n as clearCollectorContext, o as defaultSuite, p as setHooks, q as getHooks, u as collectorContext, x as getSnapshotClient, y as setState, z as getFn, A as getState } from './chunk-runtime-chain.221b8dcb.js';
4
+ import { s as suite, t as test, d as describe, i as it, r as runOnce, a as isFirstRun, b as beforeAll, c as afterAll, e as beforeEach, f as afterEach, w as withCallback, g as createExpect, h as expect, v as vitest, j as vi, k as getRunningMode, l as isWatchMode, m as resetRunOnceCounter, R as RealDate, n as clearCollectorContext, o as defaultSuite, p as setHooks, q as getHooks, u as collectorContext, x as getSnapshotClient, y as setState, z as getFn, A as getState } from './chunk-runtime-chain.eb563278.js';
7
5
  import chai, { assert, should, util } from 'chai';
8
- import { r as rpc } from './chunk-runtime-rpc.63398738.js';
9
- import { d as clearTimeout, c as setTimeout, s as stringify } from './chunk-utils-timers.f25e8f44.js';
10
- import { t as takeCoverage } from './chunk-defaults.ecb46baf.js';
11
- import { createHash } from 'crypto';
6
+ import { r as rpc } from './chunk-runtime-rpc.ef131645.js';
7
+ import { d as clearTimeout, c as setTimeout, s as stringify } from './chunk-utils-timers.a0f0fe66.js';
8
+ import { t as takeCoverage } from './chunk-defaults.374342ed.js';
12
9
  import { format } from 'util';
13
10
 
14
11
  var index = /*#__PURE__*/Object.freeze({
@@ -493,19 +490,22 @@ async function setupGlobalEnv(config) {
493
490
  if (globalSetup)
494
491
  return;
495
492
  globalSetup = true;
496
- setupConsoleLogSpy();
493
+ if (isNode)
494
+ await setupConsoleLogSpy();
497
495
  if (config.globals)
498
- (await import('./chunk-integrations-globals.60fc66ef.js')).registerApiGlobally();
496
+ (await import('./chunk-integrations-globals.4fea033a.js')).registerApiGlobally();
499
497
  }
500
498
  function setupDefines(defines) {
501
499
  for (const key in defines)
502
500
  globalThis[key] = defines[key];
503
501
  }
504
- function setupConsoleLogSpy() {
502
+ async function setupConsoleLogSpy() {
505
503
  const stdoutBuffer = /* @__PURE__ */ new Map();
506
504
  const stderrBuffer = /* @__PURE__ */ new Map();
507
505
  const timers = /* @__PURE__ */ new Map();
508
506
  const unknownTestId = "__vitest__unknown_test__";
507
+ const { Writable } = await import('stream');
508
+ const { Console } = await import('console');
509
509
  function schedule(taskId) {
510
510
  const timer = timers.get(taskId);
511
511
  const { stdoutTime, stderrTime } = timer;
@@ -722,8 +722,16 @@ function replaceAsymmetricMatcher(actual, expected) {
722
722
  }
723
723
 
724
724
  const now$1 = Date.now;
725
- function hash(str, length = 10) {
726
- return createHash("md5").update(str).digest("hex").slice(0, length);
725
+ function hash(str) {
726
+ let hash2 = 0;
727
+ if (str.length === 0)
728
+ return `${hash2}`;
729
+ for (let i = 0; i < str.length; i++) {
730
+ const char = str.charCodeAt(i);
731
+ hash2 = (hash2 << 5) - hash2 + char;
732
+ hash2 = hash2 & hash2;
733
+ }
734
+ return `${hash2}`;
727
735
  }
728
736
  async function collectTests(paths, config) {
729
737
  const files = [];
@@ -1,12 +1,12 @@
1
1
  import childProcess from 'child_process';
2
2
  import path$3 from 'path';
3
- import { c as commonjsGlobal } from './vendor-_commonjsHelpers.addc3445.js';
3
+ import { c as commonjsGlobal } from './chunk-utils-global.03413604.js';
4
4
  import fs$1 from 'fs';
5
5
  import assert$1 from 'assert';
6
6
  import require$$2 from 'events';
7
- import require$$0$2 from 'buffer';
7
+ import require$$0$1 from 'buffer';
8
8
  import require$$0 from 'stream';
9
- import require$$0$1 from 'util';
9
+ import require$$1 from 'util';
10
10
 
11
11
  var crossSpawn = {exports: {}};
12
12
 
@@ -961,9 +961,9 @@ var bufferStream$1 = options => {
961
961
  return stream;
962
962
  };
963
963
 
964
- const {constants: BufferConstants} = require$$0$2;
964
+ const {constants: BufferConstants} = require$$0$1;
965
965
  const stream = require$$0;
966
- const {promisify} = require$$0$1;
966
+ const {promisify} = require$$1;
967
967
  const bufferStream = bufferStream$1;
968
968
 
969
969
  const streamPipelinePromisified = promisify(stream.pipeline);
package/dist/worker.js CHANGED
@@ -1,8 +1,8 @@
1
- import { h as resolve, a as getWorkerState } from './chunk-utils-global.a5a8641f.js';
2
- import { c as createBirpc, M as ModuleCacheMap } from './chunk-vite-node-utils.1536f168.js';
3
- import { d as distDir } from './chunk-constants.0567483c.js';
4
- import { e as executeInViteNode } from './chunk-runtime-mocker.acd615bd.js';
5
- import { r as rpc } from './chunk-runtime-rpc.63398738.js';
1
+ import { k as resolve, a as getWorkerState } from './chunk-utils-global.03413604.js';
2
+ import { b as createBirpc, M as ModuleCacheMap } from './chunk-vite-node-utils.1064f66b.js';
3
+ import { d as distDir } from './chunk-constants.153353ee.js';
4
+ import { e as executeInViteNode } from './chunk-runtime-mocker.efd6b7ac.js';
5
+ import { r as rpc } from './chunk-runtime-rpc.ef131645.js';
6
6
  import 'tty';
7
7
  import 'local-pkg';
8
8
  import 'path';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vitest",
3
3
  "type": "module",
4
- "version": "0.12.2",
4
+ "version": "0.12.5",
5
5
  "description": "A blazing fast unit test framework powered by Vite",
6
6
  "keywords": [
7
7
  "vite",
@@ -93,7 +93,7 @@
93
93
  "@types/node": "^17.0.31",
94
94
  "@types/prompts": "^2.4.0",
95
95
  "@types/sinonjs__fake-timers": "^8.1.2",
96
- "@vitest/ui": "0.12.2",
96
+ "@vitest/ui": "0.12.5",
97
97
  "birpc": "^0.2.2",
98
98
  "c8": "^7.11.2",
99
99
  "cac": "^6.7.12",
@@ -120,7 +120,7 @@
120
120
  "source-map-js": "^1.0.2",
121
121
  "strip-ansi": "^7.0.1",
122
122
  "typescript": "^4.6.4",
123
- "vite-node": "0.12.2",
123
+ "vite-node": "0.12.5",
124
124
  "ws": "^8.6.0"
125
125
  },
126
126
  "engines": {
@@ -1,29 +0,0 @@
1
- import { g as globalApis } from './chunk-constants.0567483c.js';
2
- import { i as index } from './vendor-entry.3adaf0b2.js';
3
- import 'url';
4
- import './chunk-utils-global.a5a8641f.js';
5
- import 'tty';
6
- import 'local-pkg';
7
- import 'path';
8
- import 'fs';
9
- import 'console';
10
- import 'stream';
11
- import './chunk-runtime-chain.221b8dcb.js';
12
- import 'chai';
13
- import './vendor-_commonjsHelpers.addc3445.js';
14
- import './chunk-runtime-rpc.63398738.js';
15
- import './chunk-utils-timers.f25e8f44.js';
16
- import './chunk-integrations-spy.bee66426.js';
17
- import 'tinyspy';
18
- import 'util';
19
- import './chunk-defaults.ecb46baf.js';
20
- import 'module';
21
- import 'crypto';
22
-
23
- function registerApiGlobally() {
24
- globalApis.forEach((api) => {
25
- globalThis[api] = index[api];
26
- });
27
- }
28
-
29
- export { registerApiGlobally };
@@ -1,3 +0,0 @@
1
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
2
-
3
- export { commonjsGlobal as c };