vitest 0.0.109 → 0.0.113

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.
@@ -1,14 +1,15 @@
1
- import { g as globalApis } from './constants-e762cbc5.js';
2
- import { i as index } from './index-0961cf69.js';
1
+ import { g as globalApis } from './constants-900abe4a.js';
2
+ import { i as index } from './index-09437c50.js';
3
3
  import 'url';
4
- import './utils-d97bd6d9.js';
5
- import 'tty';
6
- import 'local-pkg';
4
+ import './index-1488b423.js';
7
5
  import 'path';
8
- import './vi-9754296d.js';
9
- import './jest-mock-8498c46d.js';
6
+ import './vi-51946984.js';
7
+ import './jest-mock-a57b745c.js';
10
8
  import 'chai';
11
9
  import 'tinyspy';
10
+ import './index-041e627e.js';
11
+ import 'tty';
12
+ import 'local-pkg';
12
13
  import './_commonjsHelpers-c9e3b764.js';
13
14
 
14
15
  function registerApiGlobally() {
@@ -1,6 +1,5 @@
1
1
  import require$$0 from 'tty';
2
2
  import { isPackageExists } from 'local-pkg';
3
- import path from 'path';
4
3
 
5
4
  var picocolors = {exports: {}};
6
5
 
@@ -65,189 +64,6 @@ picocolors.exports.createColors = createColors;
65
64
 
66
65
  var c = picocolors.exports;
67
66
 
68
- function normalizeWindowsPath(input = "") {
69
- if (!input.includes("\\")) {
70
- return input;
71
- }
72
- return input.replace(/\\/g, "/");
73
- }
74
-
75
- const _UNC_REGEX = /^[/][/]/;
76
- const _UNC_DRIVE_REGEX = /^[/][/]([.]{1,2}[/])?([a-zA-Z]):[/]/;
77
- const _IS_ABSOLUTE_RE = /^\/|^\\|^[a-zA-Z]:[/\\]/;
78
- const sep = "/";
79
- const delimiter = ":";
80
- const normalize = function(path2) {
81
- if (path2.length === 0) {
82
- return ".";
83
- }
84
- path2 = normalizeWindowsPath(path2);
85
- const isUNCPath = path2.match(_UNC_REGEX);
86
- const hasUNCDrive = isUNCPath && path2.match(_UNC_DRIVE_REGEX);
87
- const isPathAbsolute = isAbsolute(path2);
88
- const trailingSeparator = path2[path2.length - 1] === "/";
89
- path2 = normalizeString(path2, !isPathAbsolute);
90
- if (path2.length === 0) {
91
- if (isPathAbsolute) {
92
- return "/";
93
- }
94
- return trailingSeparator ? "./" : ".";
95
- }
96
- if (trailingSeparator) {
97
- path2 += "/";
98
- }
99
- if (isUNCPath) {
100
- if (hasUNCDrive) {
101
- return `//./${path2}`;
102
- }
103
- return `//${path2}`;
104
- }
105
- return isPathAbsolute && !isAbsolute(path2) ? `/${path2}` : path2;
106
- };
107
- const join = function(...args) {
108
- if (args.length === 0) {
109
- return ".";
110
- }
111
- let joined;
112
- for (let i = 0; i < args.length; ++i) {
113
- const arg = args[i];
114
- if (arg.length > 0) {
115
- if (joined === void 0) {
116
- joined = arg;
117
- } else {
118
- joined += `/${arg}`;
119
- }
120
- }
121
- }
122
- if (joined === void 0) {
123
- return ".";
124
- }
125
- return normalize(joined);
126
- };
127
- const resolve = function(...args) {
128
- args = args.map((arg) => normalizeWindowsPath(arg));
129
- let resolvedPath = "";
130
- let resolvedAbsolute = false;
131
- for (let i = args.length - 1; i >= -1 && !resolvedAbsolute; i--) {
132
- const path2 = i >= 0 ? args[i] : process.cwd();
133
- if (path2.length === 0) {
134
- continue;
135
- }
136
- resolvedPath = `${path2}/${resolvedPath}`;
137
- resolvedAbsolute = isAbsolute(path2);
138
- }
139
- resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);
140
- if (resolvedAbsolute && !isAbsolute(resolvedPath)) {
141
- return `/${resolvedPath}`;
142
- }
143
- return resolvedPath.length > 0 ? resolvedPath : ".";
144
- };
145
- function normalizeString(path2, allowAboveRoot) {
146
- let res = "";
147
- let lastSegmentLength = 0;
148
- let lastSlash = -1;
149
- let dots = 0;
150
- let char = null;
151
- for (let i = 0; i <= path2.length; ++i) {
152
- if (i < path2.length) {
153
- char = path2[i];
154
- } else if (char === "/") {
155
- break;
156
- } else {
157
- char = "/";
158
- }
159
- if (char === "/") {
160
- if (lastSlash === i - 1 || dots === 1) ; else if (dots === 2) {
161
- if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
162
- if (res.length > 2) {
163
- const lastSlashIndex = res.lastIndexOf("/");
164
- if (lastSlashIndex === -1) {
165
- res = "";
166
- lastSegmentLength = 0;
167
- } else {
168
- res = res.slice(0, lastSlashIndex);
169
- lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
170
- }
171
- lastSlash = i;
172
- dots = 0;
173
- continue;
174
- } else if (res.length !== 0) {
175
- res = "";
176
- lastSegmentLength = 0;
177
- lastSlash = i;
178
- dots = 0;
179
- continue;
180
- }
181
- }
182
- if (allowAboveRoot) {
183
- res += res.length > 0 ? "/.." : "..";
184
- lastSegmentLength = 2;
185
- }
186
- } else {
187
- if (res.length > 0) {
188
- res += `/${path2.slice(lastSlash + 1, i)}`;
189
- } else {
190
- res = path2.slice(lastSlash + 1, i);
191
- }
192
- lastSegmentLength = i - lastSlash - 1;
193
- }
194
- lastSlash = i;
195
- dots = 0;
196
- } else if (char === "." && dots !== -1) {
197
- ++dots;
198
- } else {
199
- dots = -1;
200
- }
201
- }
202
- return res;
203
- }
204
- const isAbsolute = function(p) {
205
- return _IS_ABSOLUTE_RE.test(p);
206
- };
207
- const toNamespacedPath = function(p) {
208
- return normalizeWindowsPath(p);
209
- };
210
- const extname = function(p) {
211
- return path.posix.extname(normalizeWindowsPath(p));
212
- };
213
- const relative = function(from, to) {
214
- return path.posix.relative(normalizeWindowsPath(from), normalizeWindowsPath(to));
215
- };
216
- const dirname = function(p) {
217
- return path.posix.dirname(normalizeWindowsPath(p));
218
- };
219
- const format = function(p) {
220
- return normalizeWindowsPath(path.posix.format(p));
221
- };
222
- const basename = function(p, ext) {
223
- return path.posix.basename(normalizeWindowsPath(p), ext);
224
- };
225
- const parse = function(p) {
226
- return path.posix.parse(normalizeWindowsPath(p));
227
- };
228
-
229
- const _path = /*#__PURE__*/Object.freeze({
230
- __proto__: null,
231
- sep: sep,
232
- delimiter: delimiter,
233
- normalize: normalize,
234
- join: join,
235
- resolve: resolve,
236
- normalizeString: normalizeString,
237
- isAbsolute: isAbsolute,
238
- toNamespacedPath: toNamespacedPath,
239
- extname: extname,
240
- relative: relative,
241
- dirname: dirname,
242
- format: format,
243
- basename: basename,
244
- parse: parse
245
- });
246
-
247
- const index = {
248
- ..._path
249
- };
250
-
251
67
  function toArray(array) {
252
68
  array = array || [];
253
69
  if (Array.isArray(array))
@@ -299,7 +115,7 @@ function interpretOnlyMode(tasks) {
299
115
  });
300
116
  }
301
117
  function getTests(suite) {
302
- return toArray(suite).flatMap((s) => s.tasks.flatMap((c2) => c2.type === "test" ? [c2] : getTests(c2)));
118
+ return toArray(suite).flatMap((s) => s.type === "test" ? [s] : s.tasks.flatMap((c2) => c2.type === "test" ? [c2] : getTests(c2)));
303
119
  }
304
120
  function getTasks(tasks) {
305
121
  return toArray(tasks).flatMap((s) => s.type === "test" ? [s] : [s, ...getTasks(s.tasks)]);
@@ -326,6 +142,9 @@ function getNames(task) {
326
142
  }
327
143
  return names;
328
144
  }
145
+ function getFullName(task) {
146
+ return getNames(task).join(c.dim(" > "));
147
+ }
329
148
  async function ensurePackageInstalled(dependency, promptInstall = !process.env.CI && process.stdout.isTTY) {
330
149
  if (isPackageExists(dependency))
331
150
  return true;
@@ -346,4 +165,4 @@ async function ensurePackageInstalled(dependency, promptInstall = !process.env.C
346
165
  return false;
347
166
  }
348
167
 
349
- export { getTests as a, basename as b, c, dirname as d, ensurePackageInstalled as e, getSuites as f, getNames as g, resolve as h, isAbsolute as i, hasFailed as j, notNullish as k, index as l, mergeSlashes as m, noop as n, interpretOnlyMode as o, partitionSuiteChildren as p, hasTests as q, relative as r, slash as s, toArray as t, getTasks as u };
168
+ export { getSuites as a, getTests as b, c, notNullish as d, ensurePackageInstalled as e, getNames as f, getFullName as g, hasFailed as h, interpretOnlyMode as i, hasTests as j, getTasks as k, mergeSlashes as m, noop as n, partitionSuiteChildren as p, slash as s, toArray as t };
@@ -1,12 +1,19 @@
1
- import { g as getCurrentSuite, w as withTimeout, a as getDefaultHookTimeout, s as suite, t as test, d as describe, i as it, v as vitest, b as vi } from './vi-9754296d.js';
2
- import chai, { assert, should, expect } from 'chai';
3
- import { s as spies, a as spyOn, f as fn } from './jest-mock-8498c46d.js';
1
+ import { g as getCurrentSuite, w as withTimeout, a as getDefaultHookTimeout, b as getState, s as setState, c as suite, t as test, d as describe, i as it, v as vitest, e as vi } from './vi-51946984.js';
2
+ import chai, { assert, should } from 'chai';
3
+ import { s as spies, a as spyOn, f as fn } from './jest-mock-a57b745c.js';
4
4
 
5
5
  const beforeAll = (fn, timeout) => getCurrentSuite().on("beforeAll", withTimeout(fn, timeout ?? getDefaultHookTimeout()));
6
6
  const afterAll = (fn, timeout) => getCurrentSuite().on("afterAll", withTimeout(fn, timeout ?? getDefaultHookTimeout()));
7
7
  const beforeEach = (fn, timeout) => getCurrentSuite().on("beforeEach", withTimeout(fn, timeout ?? getDefaultHookTimeout()));
8
8
  const afterEach = (fn, timeout) => getCurrentSuite().on("afterEach", withTimeout(fn, timeout ?? getDefaultHookTimeout()));
9
9
 
10
+ const expect = (value, message) => {
11
+ const { assertionCalls } = getState();
12
+ setState({ assertionCalls: assertionCalls + 1 });
13
+ return chai.expect(value, message);
14
+ };
15
+ Object.assign(expect, chai.expect);
16
+
10
17
  var index = /*#__PURE__*/Object.freeze({
11
18
  __proto__: null,
12
19
  suite: suite,
@@ -19,8 +26,8 @@ var index = /*#__PURE__*/Object.freeze({
19
26
  afterEach: afterEach,
20
27
  assert: assert,
21
28
  should: should,
22
- expect: expect,
23
29
  chai: chai,
30
+ expect: expect,
24
31
  spies: spies,
25
32
  spyOn: spyOn,
26
33
  fn: fn,
@@ -28,4 +35,4 @@ var index = /*#__PURE__*/Object.freeze({
28
35
  vi: vi
29
36
  });
30
37
 
31
- export { afterAll as a, beforeAll as b, beforeEach as c, afterEach as d, index as i };
38
+ export { afterAll as a, beforeAll as b, beforeEach as c, afterEach as d, expect as e, index as i };
@@ -0,0 +1,186 @@
1
+ import path from 'path';
2
+
3
+ function normalizeWindowsPath(input = "") {
4
+ if (!input.includes("\\")) {
5
+ return input;
6
+ }
7
+ return input.replace(/\\/g, "/");
8
+ }
9
+
10
+ const _UNC_REGEX = /^[/][/]/;
11
+ const _UNC_DRIVE_REGEX = /^[/][/]([.]{1,2}[/])?([a-zA-Z]):[/]/;
12
+ const _IS_ABSOLUTE_RE = /^\/|^\\|^[a-zA-Z]:[/\\]/;
13
+ const sep = "/";
14
+ const delimiter = ":";
15
+ const normalize = function(path2) {
16
+ if (path2.length === 0) {
17
+ return ".";
18
+ }
19
+ path2 = normalizeWindowsPath(path2);
20
+ const isUNCPath = path2.match(_UNC_REGEX);
21
+ const hasUNCDrive = isUNCPath && path2.match(_UNC_DRIVE_REGEX);
22
+ const isPathAbsolute = isAbsolute(path2);
23
+ const trailingSeparator = path2[path2.length - 1] === "/";
24
+ path2 = normalizeString(path2, !isPathAbsolute);
25
+ if (path2.length === 0) {
26
+ if (isPathAbsolute) {
27
+ return "/";
28
+ }
29
+ return trailingSeparator ? "./" : ".";
30
+ }
31
+ if (trailingSeparator) {
32
+ path2 += "/";
33
+ }
34
+ if (isUNCPath) {
35
+ if (hasUNCDrive) {
36
+ return `//./${path2}`;
37
+ }
38
+ return `//${path2}`;
39
+ }
40
+ return isPathAbsolute && !isAbsolute(path2) ? `/${path2}` : path2;
41
+ };
42
+ const join = function(...args) {
43
+ if (args.length === 0) {
44
+ return ".";
45
+ }
46
+ let joined;
47
+ for (let i = 0; i < args.length; ++i) {
48
+ const arg = args[i];
49
+ if (arg.length > 0) {
50
+ if (joined === void 0) {
51
+ joined = arg;
52
+ } else {
53
+ joined += `/${arg}`;
54
+ }
55
+ }
56
+ }
57
+ if (joined === void 0) {
58
+ return ".";
59
+ }
60
+ return normalize(joined);
61
+ };
62
+ const resolve = function(...args) {
63
+ args = args.map((arg) => normalizeWindowsPath(arg));
64
+ let resolvedPath = "";
65
+ let resolvedAbsolute = false;
66
+ for (let i = args.length - 1; i >= -1 && !resolvedAbsolute; i--) {
67
+ const path2 = i >= 0 ? args[i] : process.cwd();
68
+ if (path2.length === 0) {
69
+ continue;
70
+ }
71
+ resolvedPath = `${path2}/${resolvedPath}`;
72
+ resolvedAbsolute = isAbsolute(path2);
73
+ }
74
+ resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);
75
+ if (resolvedAbsolute && !isAbsolute(resolvedPath)) {
76
+ return `/${resolvedPath}`;
77
+ }
78
+ return resolvedPath.length > 0 ? resolvedPath : ".";
79
+ };
80
+ function normalizeString(path2, allowAboveRoot) {
81
+ let res = "";
82
+ let lastSegmentLength = 0;
83
+ let lastSlash = -1;
84
+ let dots = 0;
85
+ let char = null;
86
+ for (let i = 0; i <= path2.length; ++i) {
87
+ if (i < path2.length) {
88
+ char = path2[i];
89
+ } else if (char === "/") {
90
+ break;
91
+ } else {
92
+ char = "/";
93
+ }
94
+ if (char === "/") {
95
+ if (lastSlash === i - 1 || dots === 1) ; else if (dots === 2) {
96
+ if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
97
+ if (res.length > 2) {
98
+ const lastSlashIndex = res.lastIndexOf("/");
99
+ if (lastSlashIndex === -1) {
100
+ res = "";
101
+ lastSegmentLength = 0;
102
+ } else {
103
+ res = res.slice(0, lastSlashIndex);
104
+ lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
105
+ }
106
+ lastSlash = i;
107
+ dots = 0;
108
+ continue;
109
+ } else if (res.length !== 0) {
110
+ res = "";
111
+ lastSegmentLength = 0;
112
+ lastSlash = i;
113
+ dots = 0;
114
+ continue;
115
+ }
116
+ }
117
+ if (allowAboveRoot) {
118
+ res += res.length > 0 ? "/.." : "..";
119
+ lastSegmentLength = 2;
120
+ }
121
+ } else {
122
+ if (res.length > 0) {
123
+ res += `/${path2.slice(lastSlash + 1, i)}`;
124
+ } else {
125
+ res = path2.slice(lastSlash + 1, i);
126
+ }
127
+ lastSegmentLength = i - lastSlash - 1;
128
+ }
129
+ lastSlash = i;
130
+ dots = 0;
131
+ } else if (char === "." && dots !== -1) {
132
+ ++dots;
133
+ } else {
134
+ dots = -1;
135
+ }
136
+ }
137
+ return res;
138
+ }
139
+ const isAbsolute = function(p) {
140
+ return _IS_ABSOLUTE_RE.test(p);
141
+ };
142
+ const toNamespacedPath = function(p) {
143
+ return normalizeWindowsPath(p);
144
+ };
145
+ const extname = function(p) {
146
+ return path.posix.extname(normalizeWindowsPath(p));
147
+ };
148
+ const relative = function(from, to) {
149
+ return path.posix.relative(normalizeWindowsPath(from), normalizeWindowsPath(to));
150
+ };
151
+ const dirname = function(p) {
152
+ return path.posix.dirname(normalizeWindowsPath(p));
153
+ };
154
+ const format = function(p) {
155
+ return normalizeWindowsPath(path.posix.format(p));
156
+ };
157
+ const basename = function(p, ext) {
158
+ return path.posix.basename(normalizeWindowsPath(p), ext);
159
+ };
160
+ const parse = function(p) {
161
+ return path.posix.parse(normalizeWindowsPath(p));
162
+ };
163
+
164
+ const _path = /*#__PURE__*/Object.freeze({
165
+ __proto__: null,
166
+ sep: sep,
167
+ delimiter: delimiter,
168
+ normalize: normalize,
169
+ join: join,
170
+ resolve: resolve,
171
+ normalizeString: normalizeString,
172
+ isAbsolute: isAbsolute,
173
+ toNamespacedPath: toNamespacedPath,
174
+ extname: extname,
175
+ relative: relative,
176
+ dirname: dirname,
177
+ format: format,
178
+ basename: basename,
179
+ parse: parse
180
+ });
181
+
182
+ const index = {
183
+ ..._path
184
+ };
185
+
186
+ export { resolve as a, basename as b, index as c, dirname as d, isAbsolute as i, relative as r };