vitest 0.12.4 → 0.12.7

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/dist/{chunk-api-setup.ed61899f.js → chunk-api-setup.2f2df7e0.js} +5 -4
  2. package/dist/{chunk-constants.0567483c.js → chunk-constants.3570739f.js} +1 -1
  3. package/dist/{chunk-defaults.ecb46baf.js → chunk-defaults.7d81a6ca.js} +1 -1
  4. package/dist/{chunk-install-pkg.73b84ae1.js → chunk-install-pkg.fd8d1022.js} +1 -1
  5. package/dist/chunk-integrations-globals.36dc71fa.js +26 -0
  6. package/dist/{chunk-magic-string.d5e0e473.js → chunk-magic-string.41232190.js} +0 -4
  7. package/dist/{chunk-runtime-chain.f8567c17.js → chunk-runtime-chain.5021a6b6.js} +43 -9
  8. package/dist/{chunk-runtime-mocker.acd615bd.js → chunk-runtime-mocker.42fa71a8.js} +7 -6
  9. package/dist/{chunk-runtime-rpc.63398738.js → chunk-runtime-rpc.47bae3f9.js} +1 -1
  10. package/dist/{chunk-utils-global.a5a8641f.js → chunk-utils-global.2fab7e5c.js} +23 -9
  11. package/dist/{chunk-utils-timers.f25e8f44.js → chunk-utils-timers.da6ac0a6.js} +3 -2
  12. package/dist/{chunk-vite-node-externalize.cfbecaaf.js → chunk-vite-node-externalize.0aac0c8e.js} +62 -51
  13. package/dist/{chunk-vite-node-utils.1536f168.js → chunk-vite-node-utils.9975fd9e.js} +6 -1
  14. package/dist/cli.js +10 -9
  15. package/dist/config.d.ts +6 -3
  16. package/dist/entry.js +6 -9
  17. package/dist/index.d.ts +247 -249
  18. package/dist/index.js +4 -4
  19. package/dist/node.d.ts +215 -0
  20. package/dist/node.js +10 -9
  21. package/dist/{vendor-entry.d50b0f20.js → vendor-entry.7d6cc1fd.js} +40 -90
  22. package/dist/{vendor-index.40be925a.js → vendor-index.6c69a0a8.js} +0 -0
  23. package/dist/worker.js +6 -5
  24. package/package.json +8 -7
  25. package/dist/chunk-integrations-globals.f3e83abb.js +0 -29
package/dist/node.d.ts CHANGED
@@ -393,6 +393,9 @@ declare type BuiltinReporters = keyof typeof ReportersMap;
393
393
  declare type Awaitable<T> = T | PromiseLike<T>;
394
394
  declare type Arrayable<T> = T | Array<T>;
395
395
  declare type ArgumentsType<T> = T extends (...args: infer U) => any ? U : never;
396
+ interface Constructable {
397
+ new (...args: any[]): any;
398
+ }
396
399
  interface UserConsoleLog {
397
400
  content: string;
398
401
  type: 'stdout' | 'stderr';
@@ -994,6 +997,218 @@ interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters'
994
997
  api?: ApiConfig;
995
998
  }
996
999
 
1000
+ declare type VitestInlineConfig = InlineConfig;
1001
+ declare module 'vite' {
1002
+ interface UserConfig {
1003
+ /**
1004
+ * Options for Vitest
1005
+ */
1006
+ test?: VitestInlineConfig;
1007
+ }
1008
+ }
1009
+
1010
+ declare type Formatter = (input: string | number | null | undefined) => string;
1011
+
1012
+ interface MatcherHintOptions {
1013
+ comment?: string;
1014
+ expectedColor?: Formatter;
1015
+ isDirectExpectCall?: boolean;
1016
+ isNot?: boolean;
1017
+ promise?: string;
1018
+ receivedColor?: Formatter;
1019
+ secondArgument?: string;
1020
+ secondArgumentColor?: Formatter;
1021
+ }
1022
+ interface DiffOptions {
1023
+ aAnnotation?: string;
1024
+ aColor?: Formatter;
1025
+ aIndicator?: string;
1026
+ bAnnotation?: string;
1027
+ bColor?: Formatter;
1028
+ bIndicator?: string;
1029
+ changeColor?: Formatter;
1030
+ changeLineTrailingSpaceColor?: Formatter;
1031
+ commonColor?: Formatter;
1032
+ commonIndicator?: string;
1033
+ commonLineTrailingSpaceColor?: Formatter;
1034
+ contextLines?: number;
1035
+ emptyFirstOrLastLinePlaceholder?: string;
1036
+ expand?: boolean;
1037
+ includeChangeCounts?: boolean;
1038
+ omitAnnotationLines?: boolean;
1039
+ patchColor?: Formatter;
1040
+ compareKeys?: any;
1041
+ }
1042
+
1043
+ declare const EXPECTED_COLOR: Formatter;
1044
+ declare const RECEIVED_COLOR: Formatter;
1045
+ declare const INVERTED_COLOR: Formatter;
1046
+ declare const BOLD_WEIGHT: Formatter;
1047
+ declare const DIM_COLOR: Formatter;
1048
+ declare function matcherHint(matcherName: string, received?: string, expected?: string, options?: MatcherHintOptions): string;
1049
+ declare function stringify(object: unknown, maxDepth?: number, options?: PrettyFormatOptions): string;
1050
+ declare const printReceived: (object: unknown) => string;
1051
+ declare const printExpected: (value: unknown) => string;
1052
+ declare function diff(a: any, b: any, options?: DiffOptions): string;
1053
+
1054
+ declare const jestMatcherUtils_EXPECTED_COLOR: typeof EXPECTED_COLOR;
1055
+ declare const jestMatcherUtils_RECEIVED_COLOR: typeof RECEIVED_COLOR;
1056
+ declare const jestMatcherUtils_INVERTED_COLOR: typeof INVERTED_COLOR;
1057
+ declare const jestMatcherUtils_BOLD_WEIGHT: typeof BOLD_WEIGHT;
1058
+ declare const jestMatcherUtils_DIM_COLOR: typeof DIM_COLOR;
1059
+ declare const jestMatcherUtils_matcherHint: typeof matcherHint;
1060
+ declare const jestMatcherUtils_stringify: typeof stringify;
1061
+ declare const jestMatcherUtils_printReceived: typeof printReceived;
1062
+ declare const jestMatcherUtils_printExpected: typeof printExpected;
1063
+ declare const jestMatcherUtils_diff: typeof diff;
1064
+ declare namespace jestMatcherUtils {
1065
+ export {
1066
+ jestMatcherUtils_EXPECTED_COLOR as EXPECTED_COLOR,
1067
+ jestMatcherUtils_RECEIVED_COLOR as RECEIVED_COLOR,
1068
+ jestMatcherUtils_INVERTED_COLOR as INVERTED_COLOR,
1069
+ jestMatcherUtils_BOLD_WEIGHT as BOLD_WEIGHT,
1070
+ jestMatcherUtils_DIM_COLOR as DIM_COLOR,
1071
+ jestMatcherUtils_matcherHint as matcherHint,
1072
+ jestMatcherUtils_stringify as stringify,
1073
+ jestMatcherUtils_printReceived as printReceived,
1074
+ jestMatcherUtils_printExpected as printExpected,
1075
+ jestMatcherUtils_diff as diff,
1076
+ };
1077
+ }
1078
+
1079
+ declare type Tester = (a: any, b: any) => boolean | undefined;
1080
+ interface MatcherState {
1081
+ assertionCalls: number;
1082
+ currentTestName?: string;
1083
+ dontThrow?: () => void;
1084
+ error?: Error;
1085
+ equals: (a: unknown, b: unknown, customTesters?: Array<Tester>, strictCheck?: boolean) => boolean;
1086
+ expand?: boolean;
1087
+ expectedAssertionsNumber?: number | null;
1088
+ expectedAssertionsNumberErrorGen?: (() => Error) | null;
1089
+ isExpectingAssertions?: boolean;
1090
+ isExpectingAssertionsError?: Error | null;
1091
+ isNot: boolean;
1092
+ promise: string;
1093
+ suppressedErrors: Array<Error>;
1094
+ testPath?: string;
1095
+ utils: typeof jestMatcherUtils & {
1096
+ iterableEquality: Tester;
1097
+ subsetEquality: Tester;
1098
+ };
1099
+ }
1100
+ interface SyncExpectationResult {
1101
+ pass: boolean;
1102
+ message: () => string;
1103
+ actual?: any;
1104
+ expected?: any;
1105
+ }
1106
+ declare type AsyncExpectationResult = Promise<SyncExpectationResult>;
1107
+ declare type ExpectationResult = SyncExpectationResult | AsyncExpectationResult;
1108
+ interface RawMatcherFn<T extends MatcherState = MatcherState> {
1109
+ (this: T, received: any, expected: any, options?: any): ExpectationResult;
1110
+ }
1111
+ declare type MatchersObject<T extends MatcherState = MatcherState> = Record<string, RawMatcherFn<T>>;
1112
+
1113
+ declare type Promisify<O> = {
1114
+ [K in keyof O]: O[K] extends (...args: infer A) => infer R ? O extends R ? Promisify<O[K]> : (...args: A) => Promise<R> : O[K];
1115
+ };
1116
+ declare global {
1117
+ namespace jest {
1118
+ interface Matchers<R, T = {}> {
1119
+ }
1120
+ }
1121
+ namespace Vi {
1122
+ interface ExpectStatic extends Chai.ExpectStatic, AsymmetricMatchersContaining {
1123
+ <T>(actual: T, message?: string): Vi.Assertion<T>;
1124
+ extend(expects: MatchersObject): void;
1125
+ assertions(expected: number): void;
1126
+ hasAssertions(): void;
1127
+ anything(): any;
1128
+ any(constructor: unknown): any;
1129
+ addSnapshotSerializer(plugin: Plugin): void;
1130
+ getState(): MatcherState;
1131
+ setState(state: Partial<MatcherState>): void;
1132
+ not: AsymmetricMatchersContaining;
1133
+ }
1134
+ interface AsymmetricMatchersContaining {
1135
+ stringContaining(expected: string): any;
1136
+ objectContaining(expected: any): any;
1137
+ arrayContaining<T = unknown>(expected: Array<T>): any;
1138
+ stringMatching(expected: string | RegExp): any;
1139
+ }
1140
+ interface JestAssertion<T = any> extends jest.Matchers<void, T> {
1141
+ toMatchSnapshot<U extends {
1142
+ [P in keyof T]: any;
1143
+ }>(snapshot: Partial<U>, message?: string): void;
1144
+ toMatchSnapshot(message?: string): void;
1145
+ matchSnapshot<U extends {
1146
+ [P in keyof T]: any;
1147
+ }>(snapshot: Partial<U>, message?: string): void;
1148
+ matchSnapshot(message?: string): void;
1149
+ toMatchInlineSnapshot<U extends {
1150
+ [P in keyof T]: any;
1151
+ }>(properties: Partial<U>, snapshot?: string, message?: string): void;
1152
+ toMatchInlineSnapshot(snapshot?: string, message?: string): void;
1153
+ toThrowErrorMatchingSnapshot(message?: string): void;
1154
+ toThrowErrorMatchingInlineSnapshot(snapshot?: string, message?: string): void;
1155
+ toEqual<E>(expected: E): void;
1156
+ toStrictEqual<E>(expected: E): void;
1157
+ toBe<E>(expected: E): void;
1158
+ toMatch(expected: string | RegExp): void;
1159
+ toMatchObject<E extends {} | any[]>(expected: E): void;
1160
+ toContain<E>(item: E): void;
1161
+ toContainEqual<E>(item: E): void;
1162
+ toBeTruthy(): void;
1163
+ toBeFalsy(): void;
1164
+ toBeGreaterThan(num: number | bigint): void;
1165
+ toBeGreaterThanOrEqual(num: number | bigint): void;
1166
+ toBeLessThan(num: number | bigint): void;
1167
+ toBeLessThanOrEqual(num: number | bigint): void;
1168
+ toBeNaN(): void;
1169
+ toBeUndefined(): void;
1170
+ toBeNull(): void;
1171
+ toBeDefined(): void;
1172
+ toBeTypeOf(expected: 'bigint' | 'boolean' | 'function' | 'number' | 'object' | 'string' | 'symbol' | 'undefined'): void;
1173
+ toBeInstanceOf<E>(expected: E): void;
1174
+ toBeCalledTimes(times: number): void;
1175
+ toHaveLength(length: number): void;
1176
+ toHaveProperty<E>(property: string | string[], value?: E): void;
1177
+ toBeCloseTo(number: number, numDigits?: number): void;
1178
+ toHaveBeenCalledTimes(times: number): void;
1179
+ toHaveBeenCalledOnce(): void;
1180
+ toHaveBeenCalled(): void;
1181
+ toBeCalled(): void;
1182
+ toHaveBeenCalledWith<E extends any[]>(...args: E): void;
1183
+ toBeCalledWith<E extends any[]>(...args: E): void;
1184
+ toHaveBeenNthCalledWith<E extends any[]>(n: number, ...args: E): void;
1185
+ nthCalledWith<E extends any[]>(nthCall: number, ...args: E): void;
1186
+ toHaveBeenLastCalledWith<E extends any[]>(...args: E): void;
1187
+ lastCalledWith<E extends any[]>(...args: E): void;
1188
+ toThrow(expected?: string | Constructable | RegExp | Error): void;
1189
+ toThrowError(expected?: string | Constructable | RegExp | Error): void;
1190
+ toReturn(): void;
1191
+ toHaveReturned(): void;
1192
+ toReturnTimes(times: number): void;
1193
+ toHaveReturnedTimes(times: number): void;
1194
+ toReturnWith<E>(value: E): void;
1195
+ toHaveReturnedWith<E>(value: E): void;
1196
+ toHaveLastReturnedWith<E>(value: E): void;
1197
+ lastReturnedWith<E>(value: E): void;
1198
+ toHaveNthReturnedWith<E>(nthCall: number, value: E): void;
1199
+ nthReturnedWith<E>(nthCall: number, value: E): void;
1200
+ toSatisfy<E>(matcher: (value: E) => boolean, message?: string): void;
1201
+ }
1202
+ type VitestAssertion<A, T> = {
1203
+ [K in keyof A]: A[K] extends Chai.Assertion ? Assertion<T> : A[K] extends (...args: any[]) => any ? A[K] : VitestAssertion<A[K], T>;
1204
+ } & ((type: string, message?: string) => Assertion);
1205
+ interface Assertion<T = any> extends VitestAssertion<Chai.Assertion, T>, JestAssertion<T> {
1206
+ resolves: Promisify<Assertion<T>>;
1207
+ rejects: Promisify<Assertion<T>>;
1208
+ }
1209
+ }
1210
+ }
1211
+
997
1212
  declare type MockMap = Map<string, Record<string, string | null | (() => unknown)>>;
998
1213
 
999
1214
  declare class SnapshotManager {
package/dist/node.js CHANGED
@@ -1,10 +1,10 @@
1
- export { V as VitestPlugin, c as createVitest, s as startVitest } from './chunk-vite-node-externalize.cfbecaaf.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.0aac0c8e.js';
2
+ export { V as VitestRunner } from './chunk-runtime-mocker.42fa71a8.js';
3
3
  import 'buffer';
4
4
  import 'path';
5
5
  import 'child_process';
6
6
  import 'process';
7
- import './vendor-index.40be925a.js';
7
+ import './vendor-index.6c69a0a8.js';
8
8
  import './vendor-_commonjsHelpers.addc3445.js';
9
9
  import 'fs';
10
10
  import 'assert';
@@ -13,19 +13,20 @@ import 'stream';
13
13
  import 'util';
14
14
  import 'url';
15
15
  import 'os';
16
- import './chunk-utils-global.a5a8641f.js';
16
+ import './chunk-utils-global.2fab7e5c.js';
17
17
  import 'tty';
18
18
  import 'local-pkg';
19
19
  import 'vite';
20
- import './chunk-constants.0567483c.js';
20
+ import './chunk-constants.3570739f.js';
21
21
  import 'readline';
22
- import './chunk-vite-node-utils.1536f168.js';
22
+ import './chunk-vite-node-utils.9975fd9e.js';
23
23
  import 'module';
24
24
  import 'vm';
25
- import './chunk-defaults.ecb46baf.js';
25
+ import 'debug';
26
+ import './chunk-defaults.7d81a6ca.js';
26
27
  import 'worker_threads';
27
28
  import 'tinypool';
28
29
  import 'perf_hooks';
29
- import './chunk-utils-timers.f25e8f44.js';
30
- import './chunk-magic-string.d5e0e473.js';
30
+ import './chunk-utils-timers.da6ac0a6.js';
31
+ import './chunk-magic-string.41232190.js';
31
32
  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 { m as isNode, a as getWorkerState, t as toArray, H as clone, F as getType, l as relative, I as partitionSuiteChildren, J as hasTests, u as hasFailed, q as getFullName, r as resetModules } from './chunk-utils-global.2fab7e5c.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.f8567c17.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.5021a6b6.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.47bae3f9.js';
7
+ import { d as clearTimeout, c as setTimeout, s as stringify } from './chunk-utils-timers.da6ac0a6.js';
8
+ import { t as takeCoverage } from './chunk-defaults.7d81a6ca.js';
12
9
  import { format } from 'util';
13
10
 
14
11
  var index = /*#__PURE__*/Object.freeze({
@@ -287,15 +284,16 @@ function getWindowKeys(global, win) {
287
284
  function populateGlobal(global, win, options = {}) {
288
285
  const { bindFunctions = false } = options;
289
286
  const keys = getWindowKeys(global, win);
287
+ const originals = new Map(allowRewrite.map(([key]) => [key, global[key]]));
290
288
  const overrideObject = /* @__PURE__ */ new Map();
291
289
  for (const key of keys) {
292
- const shouldBind = bindFunctions && typeof win[key] === "function";
290
+ const bindedFunction = bindFunctions && typeof win[key] === "function" && win[key].bind(win);
293
291
  Object.defineProperty(global, key, {
294
292
  get() {
295
293
  if (overrideObject.has(key))
296
294
  return overrideObject.get(key);
297
- if (shouldBind)
298
- return win[key].bind(win);
295
+ if (bindedFunction)
296
+ return bindedFunction;
299
297
  return win[key];
300
298
  },
301
299
  set(v) {
@@ -304,76 +302,16 @@ function populateGlobal(global, win, options = {}) {
304
302
  configurable: true
305
303
  });
306
304
  }
307
- const globalKeys = /* @__PURE__ */ new Set(["window", "self", "top", "parent"]);
308
- const globalProxy = new Proxy(win.window, {
309
- get(target, p, receiver) {
310
- if (overrideObject.has(p))
311
- return overrideObject.get(p);
312
- return Reflect.get(target, p, receiver);
313
- },
314
- set(target, p, value, receiver) {
315
- try {
316
- Object.defineProperty(global, p, {
317
- get: () => overrideObject.get(p),
318
- set: (value2) => overrideObject.set(p, value2),
319
- configurable: true
320
- });
321
- overrideObject.set(p, value);
322
- Reflect.set(target, p, value, receiver);
323
- } catch {
324
- }
325
- return true;
326
- },
327
- deleteProperty(target, p) {
328
- Reflect.deleteProperty(global, p);
329
- overrideObject.delete(p);
330
- return Reflect.deleteProperty(target, p);
331
- },
332
- defineProperty(target, p, attributes) {
333
- if (attributes.writable && "value" in attributes) ; else if (attributes.get) {
334
- overrideObject.delete(p);
335
- Reflect.defineProperty(global, p, attributes);
336
- }
337
- return Reflect.defineProperty(target, p, attributes);
338
- }
339
- });
340
- globalKeys.forEach((key) => {
341
- if (!win[key])
342
- return;
343
- Object.defineProperty(global, key, {
344
- get() {
345
- return globalProxy;
346
- },
347
- configurable: true
348
- });
349
- });
350
- const globalThisProxy = new Proxy(global.globalThis, {
351
- set(target, key, value, receiver) {
352
- overrideObject.set(key, value);
353
- return Reflect.set(target, key, value, receiver);
354
- },
355
- deleteProperty(target, key) {
356
- overrideObject.delete(key);
357
- return Reflect.deleteProperty(target, key);
358
- },
359
- defineProperty(target, p, attributes) {
360
- if (attributes.writable && "value" in attributes) ; else if (attributes.get && !globalKeys.has(p)) {
361
- globalKeys.forEach((key) => {
362
- if (win[key])
363
- Object.defineProperty(win[key], p, attributes);
364
- });
365
- }
366
- return Reflect.defineProperty(target, p, attributes);
367
- }
368
- });
369
- global.globalThis = globalThisProxy;
305
+ global.window = global;
306
+ global.self = global;
307
+ global.top = global;
370
308
  if (global.global)
371
- global.global = globalThisProxy;
309
+ global.global = global;
372
310
  skipKeys.forEach((k) => keys.add(k));
373
311
  return {
374
312
  keys,
375
313
  skipKeys,
376
- allowRewrite
314
+ originals
377
315
  };
378
316
  }
379
317
 
@@ -448,8 +386,7 @@ var jsdom = {
448
386
  contentType,
449
387
  userAgent
450
388
  }, restOptions));
451
- const { keys, allowRewrite } = populateGlobal(global, dom.window);
452
- const originals = new Map(allowRewrite.map(([key]) => [key, global[key]]));
389
+ const { keys, originals } = populateGlobal(global, dom.window, { bindFunctions: true });
453
390
  return {
454
391
  teardown(global2) {
455
392
  keys.forEach((key) => delete global2[key]);
@@ -464,8 +401,7 @@ var happy = {
464
401
  async setup(global) {
465
402
  const { Window, GlobalWindow } = await importModule("happy-dom");
466
403
  const win = new (GlobalWindow || Window)();
467
- const { keys, allowRewrite } = populateGlobal(global, win, { bindFunctions: true });
468
- const originals = new Map(allowRewrite.map(([key]) => [key, global[key]]));
404
+ const { keys, originals } = populateGlobal(global, win, { bindFunctions: true });
469
405
  return {
470
406
  teardown(global2) {
471
407
  win.happyDOM.cancelAsync();
@@ -493,19 +429,22 @@ async function setupGlobalEnv(config) {
493
429
  if (globalSetup)
494
430
  return;
495
431
  globalSetup = true;
496
- setupConsoleLogSpy();
432
+ if (isNode)
433
+ await setupConsoleLogSpy();
497
434
  if (config.globals)
498
- (await import('./chunk-integrations-globals.f3e83abb.js')).registerApiGlobally();
435
+ (await import('./chunk-integrations-globals.36dc71fa.js')).registerApiGlobally();
499
436
  }
500
437
  function setupDefines(defines) {
501
438
  for (const key in defines)
502
439
  globalThis[key] = defines[key];
503
440
  }
504
- function setupConsoleLogSpy() {
441
+ async function setupConsoleLogSpy() {
505
442
  const stdoutBuffer = /* @__PURE__ */ new Map();
506
443
  const stderrBuffer = /* @__PURE__ */ new Map();
507
444
  const timers = /* @__PURE__ */ new Map();
508
445
  const unknownTestId = "__vitest__unknown_test__";
446
+ const { Writable } = await import('stream');
447
+ const { Console } = await import('console');
509
448
  function schedule(taskId) {
510
449
  const timer = timers.get(taskId);
511
450
  const { stdoutTime, stderrTime } = timer;
@@ -677,14 +616,17 @@ function processError(err) {
677
616
  err.expected = stringify(err.expected);
678
617
  if (typeof err.actual !== "string")
679
618
  err.actual = stringify(err.actual);
680
- if (typeof err.message === "string")
681
- err.message = normalizeErrorMessage(err.message);
682
- if (typeof err.cause === "object" && err.cause.message === "string")
683
- err.cause.message = normalizeErrorMessage(err.cause.message);
619
+ try {
620
+ if (typeof err.message === "string")
621
+ err.message = normalizeErrorMessage(err.message);
622
+ if (typeof err.cause === "object" && err.cause.message === "string")
623
+ err.cause.message = normalizeErrorMessage(err.cause.message);
624
+ } catch {
625
+ }
684
626
  try {
685
627
  return serializeError(err);
686
628
  } catch (e) {
687
- return serializeError(new Error(`Failed to fully serialize error: ${e == null ? void 0 : e.message}.
629
+ return serializeError(new Error(`Failed to fully serialize error: ${e == null ? void 0 : e.message}
688
630
  Inner error message: ${err == null ? void 0 : err.message}`));
689
631
  }
690
632
  }
@@ -722,8 +664,16 @@ function replaceAsymmetricMatcher(actual, expected) {
722
664
  }
723
665
 
724
666
  const now$1 = Date.now;
725
- function hash(str, length = 10) {
726
- return createHash("md5").update(str).digest("hex").slice(0, length);
667
+ function hash(str) {
668
+ let hash2 = 0;
669
+ if (str.length === 0)
670
+ return `${hash2}`;
671
+ for (let i = 0; i < str.length; i++) {
672
+ const char = str.charCodeAt(i);
673
+ hash2 = (hash2 << 5) - hash2 + char;
674
+ hash2 = hash2 & hash2;
675
+ }
676
+ return `${hash2}`;
727
677
  }
728
678
  async function collectTests(paths, config) {
729
679
  const files = [];
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 { h as resolve, a as getWorkerState } from './chunk-utils-global.2fab7e5c.js';
2
+ import { c as createBirpc, M as ModuleCacheMap } from './chunk-vite-node-utils.9975fd9e.js';
3
+ import { d as distDir } from './chunk-constants.3570739f.js';
4
+ import { e as executeInViteNode } from './chunk-runtime-mocker.42fa71a8.js';
5
+ import { r as rpc } from './chunk-runtime-rpc.47bae3f9.js';
6
6
  import 'tty';
7
7
  import 'local-pkg';
8
8
  import 'path';
@@ -12,6 +12,7 @@ import 'vm';
12
12
  import 'fs';
13
13
  import 'assert';
14
14
  import 'util';
15
+ import 'debug';
15
16
  import 'vite';
16
17
 
17
18
  let _viteNode;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vitest",
3
3
  "type": "module",
4
- "version": "0.12.4",
4
+ "version": "0.12.7",
5
5
  "description": "A blazing fast unit test framework powered by Vite",
6
6
  "keywords": [
7
7
  "vite",
@@ -78,6 +78,7 @@
78
78
  "@types/chai": "^4.3.1",
79
79
  "@types/chai-subset": "^1.3.3",
80
80
  "chai": "^4.3.6",
81
+ "debug": "^4.3.4",
81
82
  "local-pkg": "^0.4.1",
82
83
  "tinypool": "^0.1.3",
83
84
  "tinyspy": "^0.3.2",
@@ -90,10 +91,10 @@
90
91
  "@types/jsdom": "^16.2.14",
91
92
  "@types/micromatch": "^4.0.2",
92
93
  "@types/natural-compare": "^1.4.1",
93
- "@types/node": "^17.0.31",
94
+ "@types/node": "^17.0.33",
94
95
  "@types/prompts": "^2.4.0",
95
96
  "@types/sinonjs__fake-timers": "^8.1.2",
96
- "@vitest/ui": "0.12.4",
97
+ "@vitest/ui": "0.12.7",
97
98
  "birpc": "^0.2.2",
98
99
  "c8": "^7.11.2",
99
100
  "cac": "^6.7.12",
@@ -104,10 +105,10 @@
104
105
  "fast-glob": "^3.2.11",
105
106
  "find-up": "^6.3.0",
106
107
  "flatted": "^3.2.5",
107
- "happy-dom": "^3.1.1",
108
+ "happy-dom": "^3.2.0",
108
109
  "jsdom": "^19.0.0",
109
110
  "log-update": "^5.0.1",
110
- "magic-string": "^0.26.1",
111
+ "magic-string": "^0.26.2",
111
112
  "micromatch": "^4.0.5",
112
113
  "mlly": "^0.5.2",
113
114
  "natural-compare": "^1.4.0",
@@ -116,11 +117,11 @@
116
117
  "pkg-types": "^0.3.2",
117
118
  "pretty-format": "^27.5.1",
118
119
  "prompts": "^2.4.2",
119
- "rollup": "^2.72.1",
120
+ "rollup": "^2.73.0",
120
121
  "source-map-js": "^1.0.2",
121
122
  "strip-ansi": "^7.0.1",
122
123
  "typescript": "^4.6.4",
123
- "vite-node": "0.12.4",
124
+ "vite-node": "0.12.7",
124
125
  "ws": "^8.6.0"
125
126
  },
126
127
  "engines": {
@@ -1,29 +0,0 @@
1
- import { g as globalApis } from './chunk-constants.0567483c.js';
2
- import { i as index } from './vendor-entry.d50b0f20.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.f8567c17.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 };