vitest 0.0.88 → 0.0.92

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/index.d.ts CHANGED
@@ -2,7 +2,6 @@ import { Formatter } from 'picocolors/types';
2
2
  import { OptionsReceived } from 'pretty-format';
3
3
  import { MessagePort } from 'worker_threads';
4
4
  export { assert, default as chai, expect, should } from 'chai';
5
- import { spyOn, spy } from 'tinyspy';
6
5
  export { spy, spyOn } from 'tinyspy';
7
6
 
8
7
  declare const EXPECTED_COLOR: Formatter;
@@ -109,6 +108,28 @@ declare type MatchersObject<T extends MatcherState = MatcherState> = {
109
108
  [id: string]: RawMatcherFn<T>;
110
109
  };
111
110
 
111
+ interface AsymmetricMatcherInterface {
112
+ asymmetricMatch(other: unknown): boolean;
113
+ toString(): string;
114
+ getExpectedType?(): string;
115
+ toAsymmetricMatcher?(): string;
116
+ }
117
+ declare abstract class AsymmetricMatcher<T, State extends MatcherState = MatcherState> implements AsymmetricMatcherInterface {
118
+ protected sample: T;
119
+ protected inverse: boolean;
120
+ constructor(sample: T, inverse?: boolean);
121
+ protected getMatcherContext(): State;
122
+ abstract asymmetricMatch(other: unknown): boolean;
123
+ abstract toString(): string;
124
+ getExpectedType?(): string;
125
+ toAsymmetricMatcher?(): string;
126
+ }
127
+ declare class Anything extends AsymmetricMatcher<void> {
128
+ asymmetricMatch(other: unknown): boolean;
129
+ toString(): string;
130
+ toAsymmetricMatcher(): string;
131
+ }
132
+
112
133
  declare type Awaitable<T> = T | PromiseLike<T>;
113
134
  declare type Nullable<T> = T | null | undefined;
114
135
  declare type Arrayable<T> = T | Array<T>;
@@ -220,6 +241,7 @@ interface Reporter {
220
241
  onTaskUpdate?: (pack: TaskResultPack) => Awaitable<void>;
221
242
  onWatcherStart?: () => Awaitable<void>;
222
243
  onWatcherRerun?: (files: string[], trigger: string) => Awaitable<void>;
244
+ onServerRestart?: () => Awaitable<void>;
223
245
  onUserConsoleLog?: (log: UserConsoleLog) => Awaitable<void>;
224
246
  }
225
247
 
@@ -269,6 +291,7 @@ interface SnapshotSummary {
269
291
  updated: number;
270
292
  }
271
293
 
294
+ declare type BuiltinEnvironment = 'node' | 'jsdom' | 'happy-dom';
272
295
  interface InlineConfig {
273
296
  /**
274
297
  * Include globs for test files
@@ -314,7 +337,7 @@ interface InlineConfig {
314
337
  *
315
338
  * @default 'node'
316
339
  */
317
- environment?: 'node' | 'jsdom' | 'happy-dom';
340
+ environment?: BuiltinEnvironment;
318
341
  /**
319
342
  * Update snapshot files
320
343
  *
@@ -540,10 +563,70 @@ declare const afterAll: (fn: SuiteHooks['afterAll'][0], timeout?: number | undef
540
563
  declare const beforeEach: (fn: SuiteHooks['beforeEach'][0], timeout?: number | undefined) => void;
541
564
  declare const afterEach: (fn: SuiteHooks['afterEach'][0], timeout?: number | undefined) => void;
542
565
 
543
- declare const vitest: {
566
+ interface MockResultReturn<T> {
567
+ type: 'return';
568
+ value: T;
569
+ }
570
+ interface MockResultIncomplete {
571
+ type: 'incomplete';
572
+ value: undefined;
573
+ }
574
+ interface MockResultThrow {
575
+ type: 'throw';
576
+ value: any;
577
+ }
578
+ declare type MockResult<T> = MockResultReturn<T> | MockResultThrow | MockResultIncomplete;
579
+ interface JestMockCompatContext<T, Y> {
580
+ calls: Y[];
581
+ instances: T[];
582
+ invocationCallOrder: number[];
583
+ results: MockResult<T>[];
584
+ }
585
+ interface JestMockCompat<TArgs extends any[] = any[], TReturns = any> {
586
+ getMockName(): string;
587
+ mockName(n: string): this;
588
+ mock: JestMockCompatContext<TArgs, TReturns>;
589
+ mockClear(): this;
590
+ mockReset(): this;
591
+ mockRestore(): void;
592
+ getMockImplementation(): ((...args: TArgs) => TReturns) | undefined;
593
+ mockImplementation(fn: ((...args: TArgs) => TReturns) | (() => Promise<TReturns>)): this;
594
+ mockImplementationOnce(fn: ((...args: TArgs) => TReturns) | (() => Promise<TReturns>)): this;
595
+ mockReturnThis(): this;
596
+ mockReturnValue(obj: TReturns): this;
597
+ mockReturnValueOnce(obj: TReturns): this;
598
+ mockResolvedValue(obj: Awaited<TReturns>): this;
599
+ mockResolvedValueOnce(obj: Awaited<TReturns>): this;
600
+ mockRejectedValue(obj: any): this;
601
+ mockRejectedValueOnce(obj: any): this;
602
+ }
603
+ interface JestMockCompatFn<TArgs extends any[] = any, TReturns = any> extends JestMockCompat<TArgs, TReturns> {
604
+ (...args: TArgs): TReturns;
605
+ }
606
+ declare function spyOn<T, K extends keyof T>(obj: T, method: K, accessType?: 'get' | 'set'): T[K] extends (...args: infer TArgs) => infer TReturnValue ? JestMockCompat<TArgs, TReturnValue> : JestMockCompat;
607
+ declare type Awaited<T> = T extends Promise<infer R> ? R : never;
608
+ declare function fn<TArgs extends any[] = any[], R = any>(): JestMockCompatFn<TArgs, R>;
609
+ declare function fn<TArgs extends any[] = any[], R = any>(implementation: (...args: TArgs) => R): JestMockCompatFn<TArgs, R>;
610
+
611
+ declare class VitestUtils {
544
612
  spyOn: typeof spyOn;
545
- fn: typeof spy;
546
- };
613
+ fn: typeof fn;
614
+ mock: (path: string) => string;
615
+ private _timers;
616
+ constructor();
617
+ useFakeTimers(): void;
618
+ useRealTimers(): void;
619
+ runOnlyPendingTimers(): void;
620
+ runAllTimers(): void;
621
+ advanceTimersByTime(ms: number): void;
622
+ advanceTimersToNextTimer(): void;
623
+ runAllTicks(): void;
624
+ setSystemTime(time?: number | Date): void;
625
+ getRealSystemTime(): number;
626
+ getTimerCount(): number;
627
+ }
628
+ declare const vitest: VitestUtils;
629
+ declare const vi: VitestUtils;
547
630
 
548
631
  declare module 'vite' {
549
632
  interface UserConfig {
@@ -557,8 +640,11 @@ declare global {
557
640
  namespace Chai {
558
641
  interface ExpectStatic {
559
642
  extend(expects: MatchersObject): void;
643
+ stringContaining(expected: string): void;
644
+ anything(): Anything;
560
645
  }
561
646
  interface Assertion {
647
+ chaiEqual(expected: any): void;
562
648
  toMatchSnapshot(message?: string): Assertion;
563
649
  toMatchInlineSnapshot(snapshot?: string, message?: string): Assertion;
564
650
  matchSnapshot(message?: string): Assertion;
@@ -610,4 +696,4 @@ declare global {
610
696
  }
611
697
  }
612
698
 
613
- export { ArgumentsType, Arrayable, Awaitable, ComputeMode, DoneCallback, Environment, EnvironmentReturn, File, HookListener, InlineConfig, ModuleCache, Nullable, Reporter, ResolvedConfig, RpcCall, RpcMap, RpcPayload, RpcSend, RunMode, RuntimeContext, SnapshotData, SnapshotMatchOptions, SnapshotResult, SnapshotStateOptions, SnapshotSummary, SnapshotUpdateState, Suite, SuiteCollector, SuiteHooks, Task, TaskBase, TaskResult, TaskResultPack, TaskState, Test, TestCollector, TestFactory, TestFunction, UncheckedSnapshot, UserConfig, UserConsoleLog, WorkerContext, afterAll, afterEach, beforeAll, beforeEach, describe, it, suite, test, vitest };
699
+ export { ArgumentsType, Arrayable, Awaitable, BuiltinEnvironment, ComputeMode, DoneCallback, Environment, EnvironmentReturn, File, HookListener, InlineConfig, ModuleCache, Nullable, Reporter, ResolvedConfig, RpcCall, RpcMap, RpcPayload, RpcSend, RunMode, RuntimeContext, SnapshotData, SnapshotMatchOptions, SnapshotResult, SnapshotStateOptions, SnapshotSummary, SnapshotUpdateState, Suite, SuiteCollector, SuiteHooks, Task, TaskBase, TaskResult, TaskResultPack, TaskState, Test, TestCollector, TestFactory, TestFunction, UncheckedSnapshot, UserConfig, UserConsoleLog, WorkerContext, afterAll, afterEach, beforeAll, beforeEach, describe, it, suite, test, vi, vitest };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- export { d as describe, i as it, s as suite, t as test } from './suite-0e21bf9b.js';
2
- export { a as afterAll, d as afterEach, b as beforeAll, c as beforeEach, v as vitest } from './index-906ac3f9.js';
1
+ export { d as describe, i as it, s as suite, t as test } from './suite-b8c6cb53.js';
2
+ export { a as afterAll, d as afterEach, b as beforeAll, c as beforeEach, e as vi, v as vitest } from './index-708135df.js';
3
3
  export { assert, default as chai, expect, should } from 'chai';
4
4
  export { spy, spyOn } from 'tinyspy';
5
5
  import './index-9e71c815.js';
@@ -0,0 +1,79 @@
1
+ import { A as API_PATH } from './constants-9cfa4d7b.js';
2
+ import 'path';
3
+ import 'url';
4
+
5
+ /*! (c) 2020 Andrea Giammarchi */
6
+
7
+ const {parse: $parse, stringify: $stringify} = JSON;
8
+
9
+ const Primitive = String; // it could be Number
10
+ const primitive = 'string'; // it could be 'number'
11
+ const object = 'object';
12
+
13
+ const noop = (_, value) => value;
14
+
15
+ const set = (known, input, value) => {
16
+ const index = Primitive(input.push(value) - 1);
17
+ known.set(value, index);
18
+ return index;
19
+ };
20
+
21
+ const stringify = (value, replacer, space) => {
22
+ const $ = replacer && typeof replacer === object ?
23
+ (k, v) => (k === '' || -1 < replacer.indexOf(k) ? v : void 0) :
24
+ (replacer || noop);
25
+ const known = new Map;
26
+ const input = [];
27
+ const output = [];
28
+ let i = +set(known, input, $.call({'': value}, '', value));
29
+ let firstRun = !i;
30
+ while (i < input.length) {
31
+ firstRun = true;
32
+ output[i] = $stringify(input[i++], replace, space);
33
+ }
34
+ return '[' + output.join(',') + ']';
35
+ function replace(key, value) {
36
+ if (firstRun) {
37
+ firstRun = !firstRun;
38
+ return value;
39
+ }
40
+ const after = $.call(this, key, value);
41
+ switch (typeof after) {
42
+ case object:
43
+ if (after === null) return after;
44
+ case primitive:
45
+ return known.get(after) || set(known, input, after);
46
+ }
47
+ return after;
48
+ }
49
+ };
50
+
51
+ function sendFlatted(res, data) {
52
+ res.setHeader("Content-Type", "application/json");
53
+ res.write(stringify(data));
54
+ res.statusCode = 200;
55
+ res.end();
56
+ }
57
+ function middlewareAPI() {
58
+ return (req, res, next) => {
59
+ var _a;
60
+ if (!((_a = req.url) == null ? void 0 : _a.startsWith(API_PATH)))
61
+ return next();
62
+ const url = req.url.slice(API_PATH.length);
63
+ const ctx = process.__vitest__;
64
+ if (url === "/") {
65
+ return sendFlatted(res, {
66
+ files: ctx.state.filesMap
67
+ });
68
+ }
69
+ if (url === "/files") {
70
+ return sendFlatted(res, {
71
+ files: Object.keys(ctx.state.filesMap)
72
+ });
73
+ }
74
+ res.statusCode = 404;
75
+ res.end();
76
+ };
77
+ }
78
+
79
+ export { middlewareAPI as default, sendFlatted };
package/dist/node.js CHANGED
@@ -1,19 +1,20 @@
1
- export { c as createVitest } from './index-af5d5277.js';
1
+ export { c as createVitest } from './index-40ecbcb4.js';
2
2
  import 'path';
3
3
  import 'vite';
4
4
  import 'process';
5
5
  import 'fs';
6
- import './constants-adef7ffb.js';
6
+ import 'fast-glob';
7
+ import 'util';
8
+ import './constants-9cfa4d7b.js';
7
9
  import 'url';
8
- import './utils-9dcc4050.js';
9
- import 'perf_hooks';
10
- import './error-c5d734a1.js';
10
+ import './utils-860e5f7e.js';
11
11
  import 'tty';
12
+ import 'local-pkg';
13
+ import 'perf_hooks';
14
+ import './error-4b0c4b4b.js';
12
15
  import 'source-map';
16
+ import './index-5cc247ff.js';
13
17
  import 'assert';
14
18
  import 'events';
15
19
  import 'worker_threads';
16
20
  import 'piscina';
17
- import 'fast-glob';
18
- import 'micromatch';
19
- import 'readline';
@@ -48,8 +48,8 @@ function normalizeTest(fn, timeout) {
48
48
  return withTimeout(ensureAsyncTest(fn), timeout);
49
49
  }
50
50
 
51
- const fnMap = new WeakMap();
52
- const hooksMap = new WeakMap();
51
+ const fnMap = /* @__PURE__ */ new WeakMap();
52
+ const hooksMap = /* @__PURE__ */ new WeakMap();
53
53
  function setFn(key, fn) {
54
54
  fnMap.set(key, fn);
55
55
  }
@@ -0,0 +1,160 @@
1
+ import require$$0 from 'tty';
2
+ import { isPackageExists } from 'local-pkg';
3
+
4
+ var picocolors = {exports: {}};
5
+
6
+ let tty = require$$0;
7
+
8
+ let isColorSupported =
9
+ !("NO_COLOR" in process.env || process.argv.includes("--no-color")) &&
10
+ ("FORCE_COLOR" in process.env ||
11
+ process.argv.includes("--color") ||
12
+ process.platform === "win32" ||
13
+ (tty.isatty(1) && process.env.TERM !== "dumb") ||
14
+ "CI" in process.env);
15
+
16
+ let formatter =
17
+ (open, close, replace = open) =>
18
+ input => {
19
+ let string = "" + input;
20
+ let index = string.indexOf(close, open.length);
21
+ return ~index
22
+ ? open + replaceClose(string, close, replace, index) + close
23
+ : open + string + close
24
+ };
25
+
26
+ let replaceClose = (string, close, replace, index) => {
27
+ let start = string.substring(0, index) + replace;
28
+ let end = string.substring(index + close.length);
29
+ let nextIndex = end.indexOf(close);
30
+ return ~nextIndex ? start + replaceClose(end, close, replace, nextIndex) : start + end
31
+ };
32
+
33
+ let createColors = (enabled = isColorSupported) => ({
34
+ isColorSupported: enabled,
35
+ reset: enabled ? s => `\x1b[0m${s}\x1b[0m` : String,
36
+ bold: enabled ? formatter("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m") : String,
37
+ dim: enabled ? formatter("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m") : String,
38
+ italic: enabled ? formatter("\x1b[3m", "\x1b[23m") : String,
39
+ underline: enabled ? formatter("\x1b[4m", "\x1b[24m") : String,
40
+ inverse: enabled ? formatter("\x1b[7m", "\x1b[27m") : String,
41
+ hidden: enabled ? formatter("\x1b[8m", "\x1b[28m") : String,
42
+ strikethrough: enabled ? formatter("\x1b[9m", "\x1b[29m") : String,
43
+ black: enabled ? formatter("\x1b[30m", "\x1b[39m") : String,
44
+ red: enabled ? formatter("\x1b[31m", "\x1b[39m") : String,
45
+ green: enabled ? formatter("\x1b[32m", "\x1b[39m") : String,
46
+ yellow: enabled ? formatter("\x1b[33m", "\x1b[39m") : String,
47
+ blue: enabled ? formatter("\x1b[34m", "\x1b[39m") : String,
48
+ magenta: enabled ? formatter("\x1b[35m", "\x1b[39m") : String,
49
+ cyan: enabled ? formatter("\x1b[36m", "\x1b[39m") : String,
50
+ white: enabled ? formatter("\x1b[37m", "\x1b[39m") : String,
51
+ gray: enabled ? formatter("\x1b[90m", "\x1b[39m") : String,
52
+ bgBlack: enabled ? formatter("\x1b[40m", "\x1b[49m") : String,
53
+ bgRed: enabled ? formatter("\x1b[41m", "\x1b[49m") : String,
54
+ bgGreen: enabled ? formatter("\x1b[42m", "\x1b[49m") : String,
55
+ bgYellow: enabled ? formatter("\x1b[43m", "\x1b[49m") : String,
56
+ bgBlue: enabled ? formatter("\x1b[44m", "\x1b[49m") : String,
57
+ bgMagenta: enabled ? formatter("\x1b[45m", "\x1b[49m") : String,
58
+ bgCyan: enabled ? formatter("\x1b[46m", "\x1b[49m") : String,
59
+ bgWhite: enabled ? formatter("\x1b[47m", "\x1b[49m") : String,
60
+ });
61
+
62
+ picocolors.exports = createColors();
63
+ picocolors.exports.createColors = createColors;
64
+
65
+ var c = picocolors.exports;
66
+
67
+ function toArray(array) {
68
+ array = array || [];
69
+ if (Array.isArray(array))
70
+ return array;
71
+ return [array];
72
+ }
73
+ function notNullish(v) {
74
+ return v != null;
75
+ }
76
+ function slash(str) {
77
+ return str.replace(/\\/g, "/");
78
+ }
79
+ function partitionSuiteChildren(suite) {
80
+ let tasksGroup = [];
81
+ const tasksGroups = [];
82
+ for (const c2 of suite.tasks) {
83
+ if (tasksGroup.length === 0 || c2.computeMode === tasksGroup[0].computeMode) {
84
+ tasksGroup.push(c2);
85
+ } else {
86
+ tasksGroups.push(tasksGroup);
87
+ tasksGroup = [c2];
88
+ }
89
+ }
90
+ if (tasksGroup.length > 0)
91
+ tasksGroups.push(tasksGroup);
92
+ return tasksGroups;
93
+ }
94
+ function interpretOnlyMode(tasks) {
95
+ if (tasks.some((t) => t.mode === "only")) {
96
+ tasks.forEach((t) => {
97
+ if (t.mode === "run")
98
+ t.mode = "skip";
99
+ else if (t.mode === "only")
100
+ t.mode = "run";
101
+ });
102
+ }
103
+ tasks.forEach((t) => {
104
+ if (t.type === "suite") {
105
+ if (t.mode === "skip")
106
+ t.tasks.forEach((c2) => c2.mode === "run" && (c2.mode = "skip"));
107
+ else
108
+ interpretOnlyMode(t.tasks);
109
+ }
110
+ });
111
+ }
112
+ function getTests(suite) {
113
+ return toArray(suite).flatMap((s) => s.tasks.flatMap((c2) => c2.type === "test" ? [c2] : getTests(c2)));
114
+ }
115
+ function getTasks(tasks) {
116
+ return toArray(tasks).flatMap((s) => s.type === "test" ? [s] : [s, ...getTasks(s.tasks)]);
117
+ }
118
+ function getSuites(suite) {
119
+ return toArray(suite).flatMap((s) => s.type === "suite" ? [s, ...getSuites(s.tasks)] : []);
120
+ }
121
+ function hasTests(suite) {
122
+ return toArray(suite).some((s) => s.tasks.some((c2) => c2.type === "test" || hasTests(c2)));
123
+ }
124
+ function hasFailed(suite) {
125
+ return toArray(suite).some((s) => {
126
+ var _a;
127
+ return ((_a = s.result) == null ? void 0 : _a.state) === "fail" || s.type === "suite" && hasFailed(s.tasks);
128
+ });
129
+ }
130
+ function getNames(task) {
131
+ const names = [task.name];
132
+ let current = task;
133
+ while ((current == null ? void 0 : current.suite) || (current == null ? void 0 : current.file)) {
134
+ current = current.suite || current.file;
135
+ if (current == null ? void 0 : current.name)
136
+ names.unshift(current.name);
137
+ }
138
+ return names;
139
+ }
140
+ async function ensurePackageInstalled(dependency, promptInstall = !process.env.CI) {
141
+ if (isPackageExists(dependency))
142
+ return true;
143
+ console.log(c.red(`${c.inverse(c.red(" MISSING DEP "))} Can not find dependency '${dependency}'
144
+ `));
145
+ if (!promptInstall)
146
+ return false;
147
+ const prompts = await import('./index-fa899e66.js').then(function (n) { return n.i; });
148
+ const { install } = await prompts.prompt({
149
+ type: "confirm",
150
+ name: "install",
151
+ message: `Do you want to install ${c.green(dependency)}?`
152
+ });
153
+ if (install) {
154
+ await (await import('./index-e7a421bb.js')).installPackage(dependency);
155
+ return true;
156
+ }
157
+ return false;
158
+ }
159
+
160
+ export { getTests as a, getSuites as b, c, hasTests as d, ensurePackageInstalled as e, getTasks as f, getNames as g, hasFailed as h, interpretOnlyMode as i, notNullish as n, partitionSuiteChildren as p, slash as s, toArray as t };
package/dist/utils.js ADDED
@@ -0,0 +1,3 @@
1
+ export { e as ensurePackageInstalled, g as getNames, b as getSuites, f as getTasks, a as getTests, h as hasFailed, d as hasTests, i as interpretOnlyMode, n as notNullish, p as partitionSuiteChildren, s as slash, t as toArray } from './utils-860e5f7e.js';
2
+ import 'local-pkg';
3
+ import 'tty';
package/dist/worker.js CHANGED
@@ -1,14 +1,16 @@
1
1
  import path, { resolve as resolve$3, dirname as dirname$3 } from 'path';
2
2
  import { n as nanoid } from './index-9e71c815.js';
3
- import { c as distDir } from './constants-adef7ffb.js';
3
+ import { c as distDir } from './constants-9cfa4d7b.js';
4
4
  import { builtinModules, createRequire } from 'module';
5
5
  import { pathToFileURL, fileURLToPath, URL as URL$1 } from 'url';
6
6
  import vm from 'vm';
7
- import { s as slash } from './utils-9dcc4050.js';
7
+ import { s as slash } from './utils-860e5f7e.js';
8
8
  import fs, { realpathSync, statSync, Stats, promises } from 'fs';
9
9
  import assert from 'assert';
10
10
  import { format as format$3, inspect } from 'util';
11
11
  import { s as send } from './rpc-7de86f29.js';
12
+ import 'tty';
13
+ import 'local-pkg';
12
14
 
13
15
  function normalizeWindowsPath$2(input = "") {
14
16
  if (!input.includes("\\")) {
@@ -8192,7 +8194,7 @@ function getProtocol(id) {
8192
8194
  return proto ? proto.groups.proto : null;
8193
8195
  }
8194
8196
  const ESM_RE = /([\s;]|^)(import[\w,{}\s*]*from|import\s*['"*{]|export\b\s*(?:[*{]|default|type|function|const|var|let|async function)|import\.meta\b)/m;
8195
- const BUILTIN_EXTENSIONS = new Set([".mjs", ".cjs", ".node", ".wasm"]);
8197
+ const BUILTIN_EXTENSIONS = /* @__PURE__ */ new Set([".mjs", ".cjs", ".node", ".wasm"]);
8196
8198
  function hasESMSyntax(code) {
8197
8199
  return ESM_RE.test(code);
8198
8200
  }
@@ -8270,7 +8272,7 @@ async function interpretedImport(path, interpretDefault) {
8270
8272
  }
8271
8273
  async function executeInViteNode(options) {
8272
8274
  const { moduleCache, root, files, fetch } = options;
8273
- const externalCache = new Map();
8275
+ const externalCache = /* @__PURE__ */ new Map();
8274
8276
  builtinModules.forEach((m) => externalCache.set(m, true));
8275
8277
  const result = [];
8276
8278
  for (const file of files)
@@ -8391,11 +8393,10 @@ async function shouldExternalize(id, config) {
8391
8393
  return id.includes("/node_modules/") && await isValidNodeImport(id);
8392
8394
  }
8393
8395
  function toFilePath(id, root) {
8394
- id = slash(id);
8395
- let absolute = id.startsWith("/@fs/") ? id.slice(4) : id.startsWith(dirname$3(root)) ? id : id.startsWith("/") ? slash(resolve$3(root, id.slice(1))) : id;
8396
+ let absolute = slash(id).startsWith("/@fs/") ? id.slice(4) : id.startsWith(dirname$3(root)) ? id : id.startsWith("/") ? slash(resolve$3(root, id.slice(1))) : id;
8396
8397
  if (absolute.startsWith("//"))
8397
8398
  absolute = absolute.slice(1);
8398
- return isWindows && absolute.startsWith("/") ? pathToFileURL(absolute.slice(1)).href : absolute;
8399
+ return isWindows && absolute.startsWith("/") ? fileURLToPath(pathToFileURL(absolute.slice(1)).href) : absolute;
8399
8400
  }
8400
8401
  function matchExternalizePattern(id, patterns) {
8401
8402
  for (const ex of patterns) {
@@ -8410,14 +8411,14 @@ function matchExternalizePattern(id, patterns) {
8410
8411
  return false;
8411
8412
  }
8412
8413
  function patchWindowsImportPath(path) {
8413
- if (path.match(/^\w:\//))
8414
- return `/${path}`;
8414
+ if (path.match(/^\w:\\/))
8415
+ return `file:///${slash(path)}`;
8415
8416
  else
8416
8417
  return path;
8417
8418
  }
8418
8419
 
8419
8420
  let _viteNode;
8420
- const moduleCache = new Map();
8421
+ const moduleCache = /* @__PURE__ */ new Map();
8421
8422
  async function startViteNode(ctx) {
8422
8423
  if (_viteNode)
8423
8424
  return _viteNode;
@@ -8449,7 +8450,7 @@ async function startViteNode(ctx) {
8449
8450
  function init(ctx) {
8450
8451
  process.stdout.write("\0");
8451
8452
  const { config, port } = ctx;
8452
- const rpcPromiseMap = new Map();
8453
+ const rpcPromiseMap = /* @__PURE__ */ new Map();
8453
8454
  process.__vitest_worker__ = {
8454
8455
  moduleCache,
8455
8456
  config,
package/global.d.ts CHANGED
@@ -5,9 +5,8 @@ declare global {
5
5
  const it: typeof import('vitest')['it']
6
6
  const expect: typeof import('vitest')['expect']
7
7
  const assert: typeof import('vitest')['assert']
8
- const spy: typeof import('vitest')['spy']
9
- const spyOn: typeof import('vitest')['spyOn']
10
8
  const vitest: typeof import('vitest')['vitest']
9
+ const vi: typeof import('vitest')['vitest']
11
10
  const beforeAll: typeof import('vitest')['beforeAll']
12
11
  const afterAll: typeof import('vitest')['afterAll']
13
12
  const beforeEach: typeof import('vitest')['beforeEach']
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vitest",
3
- "version": "0.0.88",
3
+ "version": "0.0.92",
4
4
  "description": "A blazing fast unit test framework powered by Vite",
5
5
  "keywords": [
6
6
  "vite",
@@ -51,19 +51,21 @@
51
51
  "chai": "^4.3.4",
52
52
  "chai-subset": "^1.6.0",
53
53
  "fast-glob": "^3.2.7",
54
- "flatted": "^3.2.4",
55
54
  "local-pkg": "^0.4.0",
56
- "micromatch": "^4.0.4",
57
55
  "piscina": "^3.2.0",
58
56
  "source-map": "^0.7.3",
59
- "tinyspy": "^0.0.13"
57
+ "tinyspy": "^0.1.0"
60
58
  },
61
59
  "devDependencies": {
60
+ "flatted": "^3.2.4",
61
+ "micromatch": "^4.0.4",
62
+ "@antfu/install-pkg": "^0.1.0",
62
63
  "@types/diff": "^5.0.1",
63
64
  "@types/jsdom": "^16.2.13",
64
65
  "@types/micromatch": "^4.0.2",
65
66
  "@types/natural-compare": "^1.4.1",
66
- "@types/node": "^16.11.12",
67
+ "@types/node": "^17.0.0",
68
+ "@types/prompts": "^2.0.14",
67
69
  "c8": "^7.10.0",
68
70
  "cac": "^6.7.12",
69
71
  "cli-truncate": "^3.1.0",
@@ -79,8 +81,10 @@
79
81
  "picocolors": "^1.0.0",
80
82
  "pkg-types": "^0.3.2",
81
83
  "pretty-format": "^27.4.2",
84
+ "prompts": "^2.4.2",
82
85
  "rollup": "^2.61.1",
83
- "strip-ansi": "^7.0.1"
86
+ "strip-ansi": "^7.0.1",
87
+ "typescript": "^4.5.4"
84
88
  },
85
89
  "peerDependencies": {
86
90
  "c8": "*",
@@ -106,5 +110,6 @@
106
110
  "build": "rimraf dist && rollup -c",
107
111
  "dev": "rollup -c --watch src",
108
112
  "typecheck": "tsc --noEmit"
109
- }
113
+ },
114
+ "readme": "# vitest\n\n[![NPM version](https://img.shields.io/npm/v/vitest?color=a1b858&label=)](https://www.npmjs.com/package/vitest)\n\nA blazing fast unit test framework powered by Vite.\n\n> **This project is currently in closed beta exclusively for Sponsors.**<br>\n> Become a Sponsor of [@patak-dev](https://github.com/sponsors/patak-dev) or [@antfu](https://github.com/sponsors/antfu) to access the source code and issues tracker.\n> Learn more at [vitest.dev](https://vitest.dev)\n"
110
115
  }
@@ -1,34 +0,0 @@
1
- import { g as getCurrentSuite, w as withTimeout, a as getDefaultHookTimeout, s as suite, t as test, d as describe, i as it } from './suite-0e21bf9b.js';
2
- import chai, { assert, should, expect } from 'chai';
3
- import { spyOn, spy } from 'tinyspy';
4
-
5
- const beforeAll = (fn, timeout) => getCurrentSuite().on("beforeAll", withTimeout(fn, timeout ?? getDefaultHookTimeout()));
6
- const afterAll = (fn, timeout) => getCurrentSuite().on("afterAll", withTimeout(fn, timeout ?? getDefaultHookTimeout()));
7
- const beforeEach = (fn, timeout) => getCurrentSuite().on("beforeEach", withTimeout(fn, timeout ?? getDefaultHookTimeout()));
8
- const afterEach = (fn, timeout) => getCurrentSuite().on("afterEach", withTimeout(fn, timeout ?? getDefaultHookTimeout()));
9
-
10
- const vitest = {
11
- spyOn,
12
- fn: spy
13
- };
14
-
15
- var index = /*#__PURE__*/Object.freeze({
16
- __proto__: null,
17
- suite: suite,
18
- test: test,
19
- describe: describe,
20
- it: it,
21
- beforeAll: beforeAll,
22
- afterAll: afterAll,
23
- beforeEach: beforeEach,
24
- afterEach: afterEach,
25
- assert: assert,
26
- should: should,
27
- expect: expect,
28
- chai: chai,
29
- spy: spy,
30
- spyOn: spyOn,
31
- vitest: vitest
32
- });
33
-
34
- export { afterAll as a, beforeAll as b, beforeEach as c, afterEach as d, index as i, vitest as v };