vitest 0.0.84 → 0.0.89

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/bin/vitest.mjs CHANGED
@@ -2,10 +2,12 @@
2
2
 
3
3
  import { fileURLToPath } from 'url'
4
4
  import { resolve } from 'path'
5
+ import { checkPeerDependency } from '../dist/utils.js'
5
6
 
6
7
  const argv = process.argv.slice(2)
7
8
 
8
9
  if (argv.includes('--coverage')) {
10
+ checkPeerDependency('c8/bin/c8.js')
9
11
  const filename = fileURLToPath(import.meta.url)
10
12
  const entry = resolve(filename, '../../dist/cli.js')
11
13
  process.argv.splice(2, 0, process.argv[0], entry)
package/dist/cli.js CHANGED
@@ -1,22 +1,23 @@
1
+ import readline from 'readline';
1
2
  import { EventEmitter } from 'events';
2
- import { c } from './error-c651f5ae.js';
3
- import { c as createVitest } from './index-ad1b10e4.js';
4
- import 'fs';
5
- import 'path';
3
+ import { c } from './utils-385e2d09.js';
4
+ import { c as createVitest } from './index-733e7378.js';
5
+ import 'module';
6
6
  import 'tty';
7
- import 'source-map';
8
- import './utils-9dcc4050.js';
7
+ import 'path';
9
8
  import 'vite';
10
9
  import 'process';
10
+ import 'fs';
11
11
  import './constants-adef7ffb.js';
12
12
  import 'url';
13
13
  import 'perf_hooks';
14
+ import './error-309196c9.js';
15
+ import 'source-map';
14
16
  import 'assert';
15
17
  import 'worker_threads';
16
18
  import 'piscina';
17
19
  import 'fast-glob';
18
20
  import 'micromatch';
19
- import 'readline';
20
21
 
21
22
  function toArr(any) {
22
23
  return any == null ? [] : Array.isArray(any) ? any : [any];
@@ -631,7 +632,7 @@ class CAC extends EventEmitter {
631
632
 
632
633
  const cac = (name = "") => new CAC(name);
633
634
 
634
- var version = "0.0.84";
635
+ var version = "0.0.89";
635
636
 
636
637
  const cli = cac("vitest");
637
638
  cli.version(version).option("-r, --root <path>", "root path").option("-c, --config <path>", "path to config file").option("-u, --update", "update snapshot").option("-w, --watch", "watch mode").option("-o, --open", "open Vitest UI").option("--api", "listen to port and serve API").option("--threads", "enabled threads", { default: true }).option("--silent", "silent").option("--global", "inject apis globally").option("--dom", "mock browser api with happy-dom").option("--environment <env>", "runner environment", {
@@ -657,8 +658,9 @@ async function run(cliFilters, options) {
657
658
  const ctx = await createVitest(options);
658
659
  process.__vitest__ = ctx;
659
660
  process.chdir(ctx.config.root);
661
+ registerConsoleShortcuts(ctx);
660
662
  try {
661
- await ctx.run(cliFilters);
663
+ await ctx.start(cliFilters);
662
664
  } catch (e) {
663
665
  process.exitCode = 1;
664
666
  throw e;
@@ -667,3 +669,17 @@ async function run(cliFilters, options) {
667
669
  await ctx.close();
668
670
  }
669
671
  }
672
+ function registerConsoleShortcuts(ctx) {
673
+ if (process.stdin.isTTY) {
674
+ readline.emitKeypressEvents(process.stdin);
675
+ process.stdin.setRawMode(true);
676
+ process.stdin.on("keypress", (str) => {
677
+ if (str === "" || str === "")
678
+ process.exit();
679
+ if (ctx.runningPromise)
680
+ return;
681
+ if (ctx.isFirstRun)
682
+ process.exit();
683
+ });
684
+ }
685
+ }
package/dist/entry.js CHANGED
@@ -5,12 +5,13 @@ import chai, { expect, util } from 'chai';
5
5
  import Subset from 'chai-subset';
6
6
  import path, { basename } from 'path';
7
7
  import { r as rpc, s as send } from './rpc-7de86f29.js';
8
- import { g as getNames, t as toArray, i as interpretOnlyMode, p as partitionSuiteChildren, c as hasTests, h as hasFailed } from './utils-9dcc4050.js';
8
+ import { g as getNames, c as c$1, t as toArray, i as interpretOnlyMode, p as partitionSuiteChildren, d as hasTests, h as hasFailed } from './utils-385e2d09.js';
9
9
  import fs from 'fs';
10
- import { c as c$1, u as unifiedDiff } from './error-c651f5ae.js';
10
+ import { u as unifiedDiff } from './error-309196c9.js';
11
11
  import { performance } from 'perf_hooks';
12
- import { b as setHooks, c as createSuiteHooks, e as clearContext, f as defaultSuite, h as context, j as getHooks, k as getFn } from './suite-0e21bf9b.js';
12
+ import { b as setHooks, c as createSuiteHooks, e as clearContext, f as defaultSuite, h as context, j as getHooks, k as getFn } from './suite-b8c6cb53.js';
13
13
  import { n as nanoid } from './index-9e71c815.js';
14
+ import 'module';
14
15
  import 'tty';
15
16
  import 'source-map';
16
17
 
@@ -2761,7 +2762,7 @@ class SnapshotState {
2761
2762
  this._snapshotData = data;
2762
2763
  this._dirty = dirty;
2763
2764
  this._uncheckedKeys = new Set(Object.keys(this._snapshotData));
2764
- this._counters = new Map();
2765
+ this._counters = /* @__PURE__ */ new Map();
2765
2766
  this._index = 0;
2766
2767
  this.expand = options.expand || false;
2767
2768
  this.added = 0;
@@ -2783,7 +2784,7 @@ class SnapshotState {
2783
2784
  }
2784
2785
  clear() {
2785
2786
  this._snapshotData = this._initialData;
2786
- this._counters = new Map();
2787
+ this._counters = /* @__PURE__ */ new Map();
2787
2788
  this._index = 0;
2788
2789
  this.added = 0;
2789
2790
  this.matched = 0;
@@ -3106,42 +3107,34 @@ function isAsymmetric(obj) {
3106
3107
  return !!obj && isA("Function", obj.asymmetricMatch);
3107
3108
  }
3108
3109
  function asymmetricMatch(a, b) {
3109
- var asymmetricA = isAsymmetric(a), asymmetricB = isAsymmetric(b);
3110
- if (asymmetricA && asymmetricB) {
3110
+ const asymmetricA = isAsymmetric(a);
3111
+ const asymmetricB = isAsymmetric(b);
3112
+ if (asymmetricA && asymmetricB)
3111
3113
  return void 0;
3112
- }
3113
- if (asymmetricA) {
3114
+ if (asymmetricA)
3114
3115
  return a.asymmetricMatch(b);
3115
- }
3116
- if (asymmetricB) {
3116
+ if (asymmetricB)
3117
3117
  return b.asymmetricMatch(a);
3118
- }
3119
3118
  }
3120
3119
  function eq(a, b, aStack, bStack, customTesters, hasKey2) {
3121
- var result = true;
3122
- var asymmetricResult = asymmetricMatch(a, b);
3123
- if (asymmetricResult !== void 0) {
3120
+ let result = true;
3121
+ const asymmetricResult = asymmetricMatch(a, b);
3122
+ if (asymmetricResult !== void 0)
3124
3123
  return asymmetricResult;
3125
- }
3126
- for (var i = 0; i < customTesters.length; i++) {
3127
- var customTesterResult = customTesters[i](a, b);
3128
- if (customTesterResult !== void 0) {
3124
+ for (let i = 0; i < customTesters.length; i++) {
3125
+ const customTesterResult = customTesters[i](a, b);
3126
+ if (customTesterResult !== void 0)
3129
3127
  return customTesterResult;
3130
- }
3131
- }
3132
- if (a instanceof Error && b instanceof Error) {
3133
- return a.message == b.message;
3134
3128
  }
3135
- if (Object.is(a, b)) {
3129
+ if (a instanceof Error && b instanceof Error)
3130
+ return a.message === b.message;
3131
+ if (Object.is(a, b))
3136
3132
  return true;
3137
- }
3138
- if (a === null || b === null) {
3133
+ if (a === null || b === null)
3139
3134
  return a === b;
3140
- }
3141
- var className = Object.prototype.toString.call(a);
3142
- if (className != Object.prototype.toString.call(b)) {
3135
+ const className = Object.prototype.toString.call(a);
3136
+ if (className !== Object.prototype.toString.call(b))
3143
3137
  return false;
3144
- }
3145
3138
  switch (className) {
3146
3139
  case "[object Boolean]":
3147
3140
  case "[object String]":
@@ -3154,51 +3147,45 @@ function eq(a, b, aStack, bStack, customTesters, hasKey2) {
3154
3147
  return Object.is(a.valueOf(), b.valueOf());
3155
3148
  }
3156
3149
  case "[object Date]":
3157
- return +a == +b;
3150
+ return +a === +b;
3158
3151
  case "[object RegExp]":
3159
3152
  return a.source === b.source && a.flags === b.flags;
3160
3153
  }
3161
- if (typeof a !== "object" || typeof b !== "object") {
3154
+ if (typeof a !== "object" || typeof b !== "object")
3162
3155
  return false;
3163
- }
3164
- if (isDomNode(a) && isDomNode(b)) {
3156
+ if (isDomNode(a) && isDomNode(b))
3165
3157
  return a.isEqualNode(b);
3166
- }
3167
- var length = aStack.length;
3158
+ let length = aStack.length;
3168
3159
  while (length--) {
3169
- if (aStack[length] === a) {
3160
+ if (aStack[length] === a)
3170
3161
  return bStack[length] === b;
3171
- } else if (bStack[length] === b) {
3162
+ else if (bStack[length] === b)
3172
3163
  return false;
3173
- }
3174
3164
  }
3175
3165
  aStack.push(a);
3176
3166
  bStack.push(b);
3177
- if (className == "[object Array]" && a.length !== b.length) {
3167
+ if (className === "[object Array]" && a.length !== b.length)
3178
3168
  return false;
3179
- }
3180
- var aKeys = keys(a, hasKey2), key;
3181
- var size = aKeys.length;
3182
- if (keys(b, hasKey2).length !== size) {
3169
+ const aKeys = keys(a, hasKey2);
3170
+ let key;
3171
+ let size = aKeys.length;
3172
+ if (keys(b, hasKey2).length !== size)
3183
3173
  return false;
3184
- }
3185
3174
  while (size--) {
3186
3175
  key = aKeys[size];
3187
3176
  result = hasKey2(b, key) && eq(a[key], b[key], aStack, bStack, customTesters, hasKey2);
3188
- if (!result) {
3177
+ if (!result)
3189
3178
  return false;
3190
- }
3191
3179
  }
3192
3180
  aStack.pop();
3193
3181
  bStack.pop();
3194
3182
  return result;
3195
3183
  }
3196
3184
  function keys(obj, hasKey2) {
3197
- var keys2 = [];
3198
- for (var key in obj) {
3199
- if (hasKey2(obj, key)) {
3185
+ const keys2 = [];
3186
+ for (const key in obj) {
3187
+ if (hasKey2(obj, key))
3200
3188
  keys2.push(key);
3201
- }
3202
3189
  }
3203
3190
  return keys2.concat(Object.getOwnPropertySymbols(obj).filter((symbol) => Object.getOwnPropertyDescriptor(obj, symbol).enumerable));
3204
3191
  }
@@ -3209,7 +3196,7 @@ function hasKey(obj, key) {
3209
3196
  return Object.prototype.hasOwnProperty.call(obj, key);
3210
3197
  }
3211
3198
  function isA(typeName, value) {
3212
- return Object.prototype.toString.apply(value) === "[object " + typeName + "]";
3199
+ return Object.prototype.toString.apply(value) === `[object ${typeName}]`;
3213
3200
  }
3214
3201
  function isDomNode(obj) {
3215
3202
  return obj !== null && typeof obj === "object" && typeof obj.nodeType === "number" && typeof obj.nodeName === "string" && typeof obj.isEqualNode === "function";
@@ -3226,17 +3213,14 @@ function isImmutableUnorderedSet(maybeSet) {
3226
3213
  const IteratorSymbol = Symbol.iterator;
3227
3214
  const hasIterator = (object) => !!(object != null && object[IteratorSymbol]);
3228
3215
  const iterableEquality = (a, b, aStack = [], bStack = []) => {
3229
- if (typeof a !== "object" || typeof b !== "object" || Array.isArray(a) || Array.isArray(b) || !hasIterator(a) || !hasIterator(b)) {
3216
+ if (typeof a !== "object" || typeof b !== "object" || Array.isArray(a) || Array.isArray(b) || !hasIterator(a) || !hasIterator(b))
3230
3217
  return void 0;
3231
- }
3232
- if (a.constructor !== b.constructor) {
3218
+ if (a.constructor !== b.constructor)
3233
3219
  return false;
3234
- }
3235
3220
  let length = aStack.length;
3236
3221
  while (length--) {
3237
- if (aStack[length] === a) {
3222
+ if (aStack[length] === a)
3238
3223
  return bStack[length] === b;
3239
- }
3240
3224
  }
3241
3225
  aStack.push(a);
3242
3226
  bStack.push(b);
@@ -3251,9 +3235,8 @@ const iterableEquality = (a, b, aStack = [], bStack = []) => {
3251
3235
  let has = false;
3252
3236
  for (const bValue of b) {
3253
3237
  const isEqual = equals(aValue, bValue, [iterableEqualityWithStack]);
3254
- if (isEqual === true) {
3238
+ if (isEqual === true)
3255
3239
  has = true;
3256
- }
3257
3240
  }
3258
3241
  if (has === false) {
3259
3242
  allFound = false;
@@ -3279,9 +3262,8 @@ const iterableEquality = (a, b, aStack = [], bStack = []) => {
3279
3262
  iterableEqualityWithStack
3280
3263
  ]);
3281
3264
  }
3282
- if (matchedValue === true) {
3265
+ if (matchedValue === true)
3283
3266
  has = true;
3284
- }
3285
3267
  }
3286
3268
  if (has === false) {
3287
3269
  allFound = false;
@@ -3297,35 +3279,30 @@ const iterableEquality = (a, b, aStack = [], bStack = []) => {
3297
3279
  const bIterator = b[IteratorSymbol]();
3298
3280
  for (const aValue of a) {
3299
3281
  const nextB = bIterator.next();
3300
- if (nextB.done || !equals(aValue, nextB.value, [iterableEqualityWithStack])) {
3282
+ if (nextB.done || !equals(aValue, nextB.value, [iterableEqualityWithStack]))
3301
3283
  return false;
3302
- }
3303
3284
  }
3304
- if (!bIterator.next().done) {
3285
+ if (!bIterator.next().done)
3305
3286
  return false;
3306
- }
3307
3287
  aStack.pop();
3308
3288
  bStack.pop();
3309
3289
  return true;
3310
3290
  };
3311
3291
  const hasPropertyInObject = (object, key) => {
3312
3292
  const shouldTerminate = !object || typeof object !== "object" || object === Object.prototype;
3313
- if (shouldTerminate) {
3293
+ if (shouldTerminate)
3314
3294
  return false;
3315
- }
3316
3295
  return Object.prototype.hasOwnProperty.call(object, key) || hasPropertyInObject(Object.getPrototypeOf(object), key);
3317
3296
  };
3318
3297
  const isObjectWithKeys = (a) => isObject(a) && !(a instanceof Error) && !(a instanceof Array) && !(a instanceof Date);
3319
3298
  const subsetEquality = (object, subset) => {
3320
- const subsetEqualityWithContext = (seenReferences = new WeakMap()) => (object2, subset2) => {
3321
- if (!isObjectWithKeys(subset2)) {
3299
+ const subsetEqualityWithContext = (seenReferences = /* @__PURE__ */ new WeakMap()) => (object2, subset2) => {
3300
+ if (!isObjectWithKeys(subset2))
3322
3301
  return void 0;
3323
- }
3324
3302
  return Object.keys(subset2).every((key) => {
3325
3303
  if (isObjectWithKeys(subset2[key])) {
3326
- if (seenReferences.has(subset2[key])) {
3304
+ if (seenReferences.has(subset2[key]))
3327
3305
  return equals(object2[key], subset2[key], [iterableEquality]);
3328
- }
3329
3306
  seenReferences.set(subset2[key], true);
3330
3307
  }
3331
3308
  const result = object2 != null && hasPropertyInObject(object2, key) && equals(object2[key], subset2[key], [
@@ -3509,13 +3486,16 @@ function JestChaiExpect() {
3509
3486
  return assertion._obj;
3510
3487
  };
3511
3488
  def(["toHaveBeenCalledTimes", "toBeCalledTimes"], function(number) {
3512
- return this.assert(getSpy(this).callCount === number, "expected spy to be called #{exp} times", "expected spy to not be called #{exp} times", number);
3489
+ const spy = getSpy(this);
3490
+ return this.assert(spy.callCount === number, "expected spy to be called #{exp} times", "expected spy to not be called #{exp} times", number, spy.callCount);
3513
3491
  });
3514
3492
  def("toHaveBeenCalledOnce", function() {
3515
- return this.assert(getSpy(this).callCount === 1, "expected spy to be called once", "expected spy to not be called once", 1);
3493
+ const spy = getSpy(this);
3494
+ return this.assert(spy.callCount === 1, "expected spy to be called once", "expected spy to not be called once", 1, spy.callCount);
3516
3495
  });
3517
3496
  def(["toHaveBeenCalled", "toBeCalled"], function() {
3518
- return this.assert(getSpy(this).called, "expected spy to be called at least once", "expected spy to not be called at all", true);
3497
+ const spy = getSpy(this);
3498
+ return this.assert(spy.called, "expected spy to be called at least once", "expected spy to not be called at all", true, spy.called);
3519
3499
  });
3520
3500
  def(["toHaveBeenCalledWith", "toBeCalledWith"], function(...args) {
3521
3501
  const spy = getSpy(this);
@@ -3603,7 +3583,7 @@ async function setupGlobalEnv(config) {
3603
3583
  setupConsoleLogSpy();
3604
3584
  await setupChai();
3605
3585
  if (config.global)
3606
- (await import('./global-e172af93.js')).registerApiGlobally();
3586
+ (await import('./global-f3eab75a.js')).registerApiGlobally();
3607
3587
  }
3608
3588
  function setupConsoleLogSpy() {
3609
3589
  const stdout = new Writable({
@@ -3731,7 +3711,11 @@ async function collectTests(paths, config) {
3731
3711
  }
3732
3712
 
3733
3713
  async function callSuiteHook(suite, name, args) {
3714
+ if (name === "beforeEach" && suite.suite)
3715
+ await callSuiteHook(suite.suite, name, args);
3734
3716
  await Promise.all(getHooks(suite)[name].map((fn) => fn(...args)));
3717
+ if (name === "afterEach" && suite.suite)
3718
+ await callSuiteHook(suite.suite, name, args);
3735
3719
  }
3736
3720
  function updateTask(task) {
3737
3721
  return rpc("onTaskUpdate", [task.id, task.result]);
@@ -1,71 +1,7 @@
1
1
  import { existsSync, promises } from 'fs';
2
2
  import { relative } from 'path';
3
- import require$$0 from 'tty';
3
+ import { n as notNullish, c } from './utils-385e2d09.js';
4
4
  import { SourceMapConsumer } from 'source-map';
5
- import { n as notNullish } from './utils-9dcc4050.js';
6
-
7
- var picocolors = {exports: {}};
8
-
9
- let tty = require$$0;
10
-
11
- let isColorSupported =
12
- !("NO_COLOR" in process.env || process.argv.includes("--no-color")) &&
13
- ("FORCE_COLOR" in process.env ||
14
- process.argv.includes("--color") ||
15
- process.platform === "win32" ||
16
- (tty.isatty(1) && process.env.TERM !== "dumb") ||
17
- "CI" in process.env);
18
-
19
- let formatter =
20
- (open, close, replace = open) =>
21
- input => {
22
- let string = "" + input;
23
- let index = string.indexOf(close, open.length);
24
- return ~index
25
- ? open + replaceClose(string, close, replace, index) + close
26
- : open + string + close
27
- };
28
-
29
- let replaceClose = (string, close, replace, index) => {
30
- let start = string.substring(0, index) + replace;
31
- let end = string.substring(index + close.length);
32
- let nextIndex = end.indexOf(close);
33
- return ~nextIndex ? start + replaceClose(end, close, replace, nextIndex) : start + end
34
- };
35
-
36
- let createColors = (enabled = isColorSupported) => ({
37
- isColorSupported: enabled,
38
- reset: enabled ? s => `\x1b[0m${s}\x1b[0m` : String,
39
- bold: enabled ? formatter("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m") : String,
40
- dim: enabled ? formatter("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m") : String,
41
- italic: enabled ? formatter("\x1b[3m", "\x1b[23m") : String,
42
- underline: enabled ? formatter("\x1b[4m", "\x1b[24m") : String,
43
- inverse: enabled ? formatter("\x1b[7m", "\x1b[27m") : String,
44
- hidden: enabled ? formatter("\x1b[8m", "\x1b[28m") : String,
45
- strikethrough: enabled ? formatter("\x1b[9m", "\x1b[29m") : String,
46
- black: enabled ? formatter("\x1b[30m", "\x1b[39m") : String,
47
- red: enabled ? formatter("\x1b[31m", "\x1b[39m") : String,
48
- green: enabled ? formatter("\x1b[32m", "\x1b[39m") : String,
49
- yellow: enabled ? formatter("\x1b[33m", "\x1b[39m") : String,
50
- blue: enabled ? formatter("\x1b[34m", "\x1b[39m") : String,
51
- magenta: enabled ? formatter("\x1b[35m", "\x1b[39m") : String,
52
- cyan: enabled ? formatter("\x1b[36m", "\x1b[39m") : String,
53
- white: enabled ? formatter("\x1b[37m", "\x1b[39m") : String,
54
- gray: enabled ? formatter("\x1b[90m", "\x1b[39m") : String,
55
- bgBlack: enabled ? formatter("\x1b[40m", "\x1b[49m") : String,
56
- bgRed: enabled ? formatter("\x1b[41m", "\x1b[49m") : String,
57
- bgGreen: enabled ? formatter("\x1b[42m", "\x1b[49m") : String,
58
- bgYellow: enabled ? formatter("\x1b[43m", "\x1b[49m") : String,
59
- bgBlue: enabled ? formatter("\x1b[44m", "\x1b[49m") : String,
60
- bgMagenta: enabled ? formatter("\x1b[45m", "\x1b[49m") : String,
61
- bgCyan: enabled ? formatter("\x1b[46m", "\x1b[49m") : String,
62
- bgWhite: enabled ? formatter("\x1b[47m", "\x1b[49m") : String,
63
- });
64
-
65
- picocolors.exports = createColors();
66
- picocolors.exports.createColors = createColors;
67
-
68
- var c = picocolors.exports;
69
5
 
70
6
  function Diff() {}
71
7
  Diff.prototype = {
@@ -1254,8 +1190,7 @@ const F_CHECK = "\u221A";
1254
1190
  const F_CROSS = "\xD7";
1255
1191
  const F_LONG_DASH = "\u23AF";
1256
1192
 
1257
- async function printError(error) {
1258
- const ctx = process.__vitest__;
1193
+ async function printError(error, ctx) {
1259
1194
  let e = error;
1260
1195
  if (typeof error === "string") {
1261
1196
  e = {
@@ -1358,6 +1293,8 @@ function posToNumber(source, pos) {
1358
1293
  const lines = source.split(splitRE);
1359
1294
  const { line, column } = pos;
1360
1295
  let start = 0;
1296
+ if (line > lines.length)
1297
+ return source.length;
1361
1298
  for (let i = 0; i < line - 1; i++)
1362
1299
  start += lines[i].length + 1;
1363
1300
  return start + column;
@@ -1474,4 +1411,4 @@ function notBlank(line) {
1474
1411
  return typeof line !== "undefined" && line !== null;
1475
1412
  }
1476
1413
 
1477
- export { F_POINTER as F, ansiStyles as a, stripAnsi as b, c, sliceAnsi as d, F_DOWN as e, F_LONG_DASH as f, F_DOWN_RIGHT as g, F_DOT as h, F_CHECK as i, F_CROSS as j, cliTruncate as k, F_RIGHT as l, printError as p, stringWidth as s, unifiedDiff as u };
1414
+ export { F_POINTER as F, ansiStyles as a, stripAnsi as b, sliceAnsi as c, F_DOWN as d, F_LONG_DASH as e, F_DOWN_RIGHT as f, F_DOT as g, F_CHECK as h, F_CROSS as i, cliTruncate as j, F_RIGHT as k, printError as p, stringWidth as s, unifiedDiff as u };
@@ -1,8 +1,8 @@
1
1
  import { g as globalApis } from './constants-adef7ffb.js';
2
- import { i as index } from './index-906ac3f9.js';
2
+ import { i as index } from './index-722fb5a5.js';
3
3
  import 'path';
4
4
  import 'url';
5
- import './suite-0e21bf9b.js';
5
+ import './suite-b8c6cb53.js';
6
6
  import './index-9e71c815.js';
7
7
  import 'chai';
8
8
  import 'tinyspy';
@@ -0,0 +1,122 @@
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-b8c6cb53.js';
2
+ import chai, { util, assert, should, expect } from 'chai';
3
+ import * as tinyspy from 'tinyspy';
4
+ import { spy, spyOn as spyOn$1 } from 'tinyspy';
5
+
6
+ const beforeAll = (fn, timeout) => getCurrentSuite().on("beforeAll", withTimeout(fn, timeout ?? getDefaultHookTimeout()));
7
+ const afterAll = (fn, timeout) => getCurrentSuite().on("afterAll", withTimeout(fn, timeout ?? getDefaultHookTimeout()));
8
+ const beforeEach = (fn, timeout) => getCurrentSuite().on("beforeEach", withTimeout(fn, timeout ?? getDefaultHookTimeout()));
9
+ const afterEach = (fn, timeout) => getCurrentSuite().on("afterEach", withTimeout(fn, timeout ?? getDefaultHookTimeout()));
10
+
11
+ function spyOn(obj, method, accessType) {
12
+ const dictionary = {
13
+ get: "getter",
14
+ set: "setter"
15
+ };
16
+ const objMethod = accessType ? { [dictionary[accessType]]: method } : method;
17
+ const stub = tinyspy.spyOn(obj, objMethod);
18
+ return enhanceSpy(stub);
19
+ }
20
+ function enhanceSpy(spy) {
21
+ const stub = spy;
22
+ let implementation;
23
+ const instances = [];
24
+ const mockContext = {
25
+ get calls() {
26
+ return stub.calls;
27
+ },
28
+ get instances() {
29
+ return instances;
30
+ },
31
+ get invocationCallOrder() {
32
+ return [];
33
+ },
34
+ get results() {
35
+ return stub.results.map(([callType, value]) => {
36
+ const type = callType === "error" ? "throw" : "return";
37
+ return { type, value };
38
+ });
39
+ }
40
+ };
41
+ let onceImplementations = [];
42
+ let name = "";
43
+ Object.defineProperty(stub, "name", {
44
+ get: () => name
45
+ });
46
+ stub.getMockName = () => name || "vi.fn()";
47
+ stub.mockName = (n) => {
48
+ name = n;
49
+ return stub;
50
+ };
51
+ stub.mockClear = () => {
52
+ stub.reset();
53
+ return stub;
54
+ };
55
+ stub.mockReset = () => {
56
+ stub.reset();
57
+ return stub;
58
+ };
59
+ stub.mockRestore = () => {
60
+ implementation = void 0;
61
+ onceImplementations = [];
62
+ stub.reset();
63
+ stub.restore();
64
+ return stub;
65
+ };
66
+ stub.getMockImplementation = () => implementation;
67
+ stub.mockImplementation = (fn2) => {
68
+ implementation = fn2;
69
+ return stub;
70
+ };
71
+ stub.mockImplementationOnce = (fn2) => {
72
+ onceImplementations.push(fn2);
73
+ return stub;
74
+ };
75
+ stub.mockReturnThis = () => stub.mockImplementation(function() {
76
+ return this;
77
+ });
78
+ stub.mockReturnValue = (val) => stub.mockImplementation(() => val);
79
+ stub.mockReturnValueOnce = (val) => stub.mockImplementationOnce(() => val);
80
+ stub.mockResolvedValue = (val) => stub.mockImplementation(() => Promise.resolve(val));
81
+ stub.mockResolvedValueOnce = (val) => stub.mockImplementationOnce(() => Promise.resolve(val));
82
+ stub.mockRejectedValue = (val) => stub.mockImplementation(() => Promise.reject(val));
83
+ stub.mockRejectedValueOnce = (val) => stub.mockImplementation(() => Promise.reject(val));
84
+ util.addProperty(stub, "mock", () => mockContext);
85
+ stub.willCall(function(...args) {
86
+ instances.push(this);
87
+ const impl = onceImplementations.shift() || implementation || stub.getOriginal() || (() => {
88
+ });
89
+ return impl.apply(this, args);
90
+ });
91
+ return stub;
92
+ }
93
+ function fn(implementation) {
94
+ return enhanceSpy(tinyspy.spyOn({ fn: implementation || (() => {
95
+ }) }, "fn"));
96
+ }
97
+
98
+ const vitest = {
99
+ spyOn,
100
+ fn
101
+ };
102
+
103
+ var index = /*#__PURE__*/Object.freeze({
104
+ __proto__: null,
105
+ suite: suite,
106
+ test: test,
107
+ describe: describe,
108
+ it: it,
109
+ beforeAll: beforeAll,
110
+ afterAll: afterAll,
111
+ beforeEach: beforeEach,
112
+ afterEach: afterEach,
113
+ assert: assert,
114
+ should: should,
115
+ expect: expect,
116
+ chai: chai,
117
+ spy: spy,
118
+ spyOn: spyOn$1,
119
+ vitest: vitest
120
+ });
121
+
122
+ export { afterAll as a, beforeAll as b, beforeEach as c, afterEach as d, index as i, vitest as v };