@vitest/runner 0.29.6 → 0.29.8

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 (2) hide show
  1. package/dist/chunk-tasks.js +97 -97
  2. package/package.json +2 -2
@@ -16,103 +16,6 @@ function partitionSuiteChildren(suite) {
16
16
  return tasksGroups;
17
17
  }
18
18
 
19
- function interpretTaskModes(suite, namePattern, onlyMode, parentIsOnly, allowOnly) {
20
- const suiteIsOnly = parentIsOnly || suite.mode === "only";
21
- suite.tasks.forEach((t) => {
22
- const includeTask = suiteIsOnly || t.mode === "only";
23
- if (onlyMode) {
24
- if (t.type === "suite" && (includeTask || someTasksAreOnly(t))) {
25
- if (t.mode === "only") {
26
- checkAllowOnly(t, allowOnly);
27
- t.mode = "run";
28
- }
29
- } else if (t.mode === "run" && !includeTask) {
30
- t.mode = "skip";
31
- } else if (t.mode === "only") {
32
- checkAllowOnly(t, allowOnly);
33
- t.mode = "run";
34
- }
35
- }
36
- if (t.type === "test") {
37
- if (namePattern && !getTaskFullName(t).match(namePattern))
38
- t.mode = "skip";
39
- } else if (t.type === "suite") {
40
- if (t.mode === "skip")
41
- skipAllTasks(t);
42
- else
43
- interpretTaskModes(t, namePattern, onlyMode, includeTask, allowOnly);
44
- }
45
- });
46
- if (suite.mode === "run") {
47
- if (suite.tasks.length && suite.tasks.every((i) => i.mode !== "run"))
48
- suite.mode = "skip";
49
- }
50
- }
51
- function getTaskFullName(task) {
52
- return `${task.suite ? `${getTaskFullName(task.suite)} ` : ""}${task.name}`;
53
- }
54
- function someTasksAreOnly(suite) {
55
- return suite.tasks.some((t) => t.mode === "only" || t.type === "suite" && someTasksAreOnly(t));
56
- }
57
- function skipAllTasks(suite) {
58
- suite.tasks.forEach((t) => {
59
- if (t.mode === "run") {
60
- t.mode = "skip";
61
- if (t.type === "suite")
62
- skipAllTasks(t);
63
- }
64
- });
65
- }
66
- function checkAllowOnly(task, allowOnly) {
67
- if (allowOnly)
68
- return;
69
- const error = new Error("[Vitest] Unexpected .only modifier. Remove it or pass --allowOnly argument to bypass this error");
70
- task.result = {
71
- state: "fail",
72
- error,
73
- errors: [error]
74
- };
75
- }
76
- function generateHash(str) {
77
- let hash = 0;
78
- if (str.length === 0)
79
- return `${hash}`;
80
- for (let i = 0; i < str.length; i++) {
81
- const char = str.charCodeAt(i);
82
- hash = (hash << 5) - hash + char;
83
- hash = hash & hash;
84
- }
85
- return `${hash}`;
86
- }
87
- function calculateSuiteHash(parent) {
88
- parent.tasks.forEach((t, idx) => {
89
- t.id = `${parent.id}_${idx}`;
90
- if (t.type === "suite")
91
- calculateSuiteHash(t);
92
- });
93
- }
94
-
95
- function createChainable(keys, fn) {
96
- function create(context) {
97
- const chain2 = function(...args) {
98
- return fn.apply(context, args);
99
- };
100
- Object.assign(chain2, fn);
101
- chain2.withContext = () => chain2.bind(context);
102
- for (const key of keys) {
103
- Object.defineProperty(chain2, key, {
104
- get() {
105
- return create({ ...context, [key]: true });
106
- }
107
- });
108
- }
109
- return chain2;
110
- }
111
- const chain = create({});
112
- chain.fn = fn;
113
- return chain;
114
- }
115
-
116
19
  const IS_RECORD_SYMBOL = "@@__IMMUTABLE_RECORD__@@";
117
20
  const IS_COLLECTION_SYMBOL = "@@__IMMUTABLE_ITERABLE__@@";
118
21
  const isImmutable = (v) => v && (v[IS_COLLECTION_SYMBOL] || v[IS_RECORD_SYMBOL]);
@@ -250,6 +153,103 @@ function replaceAsymmetricMatcher(actual, expected, actualReplaced = /* @__PURE_
250
153
  };
251
154
  }
252
155
 
156
+ function interpretTaskModes(suite, namePattern, onlyMode, parentIsOnly, allowOnly) {
157
+ const suiteIsOnly = parentIsOnly || suite.mode === "only";
158
+ suite.tasks.forEach((t) => {
159
+ const includeTask = suiteIsOnly || t.mode === "only";
160
+ if (onlyMode) {
161
+ if (t.type === "suite" && (includeTask || someTasksAreOnly(t))) {
162
+ if (t.mode === "only") {
163
+ checkAllowOnly(t, allowOnly);
164
+ t.mode = "run";
165
+ }
166
+ } else if (t.mode === "run" && !includeTask) {
167
+ t.mode = "skip";
168
+ } else if (t.mode === "only") {
169
+ checkAllowOnly(t, allowOnly);
170
+ t.mode = "run";
171
+ }
172
+ }
173
+ if (t.type === "test") {
174
+ if (namePattern && !getTaskFullName(t).match(namePattern))
175
+ t.mode = "skip";
176
+ } else if (t.type === "suite") {
177
+ if (t.mode === "skip")
178
+ skipAllTasks(t);
179
+ else
180
+ interpretTaskModes(t, namePattern, onlyMode, includeTask, allowOnly);
181
+ }
182
+ });
183
+ if (suite.mode === "run") {
184
+ if (suite.tasks.length && suite.tasks.every((i) => i.mode !== "run"))
185
+ suite.mode = "skip";
186
+ }
187
+ }
188
+ function getTaskFullName(task) {
189
+ return `${task.suite ? `${getTaskFullName(task.suite)} ` : ""}${task.name}`;
190
+ }
191
+ function someTasksAreOnly(suite) {
192
+ return suite.tasks.some((t) => t.mode === "only" || t.type === "suite" && someTasksAreOnly(t));
193
+ }
194
+ function skipAllTasks(suite) {
195
+ suite.tasks.forEach((t) => {
196
+ if (t.mode === "run") {
197
+ t.mode = "skip";
198
+ if (t.type === "suite")
199
+ skipAllTasks(t);
200
+ }
201
+ });
202
+ }
203
+ function checkAllowOnly(task, allowOnly) {
204
+ if (allowOnly)
205
+ return;
206
+ const error = processError(new Error("[Vitest] Unexpected .only modifier. Remove it or pass --allowOnly argument to bypass this error"));
207
+ task.result = {
208
+ state: "fail",
209
+ error,
210
+ errors: [error]
211
+ };
212
+ }
213
+ function generateHash(str) {
214
+ let hash = 0;
215
+ if (str.length === 0)
216
+ return `${hash}`;
217
+ for (let i = 0; i < str.length; i++) {
218
+ const char = str.charCodeAt(i);
219
+ hash = (hash << 5) - hash + char;
220
+ hash = hash & hash;
221
+ }
222
+ return `${hash}`;
223
+ }
224
+ function calculateSuiteHash(parent) {
225
+ parent.tasks.forEach((t, idx) => {
226
+ t.id = `${parent.id}_${idx}`;
227
+ if (t.type === "suite")
228
+ calculateSuiteHash(t);
229
+ });
230
+ }
231
+
232
+ function createChainable(keys, fn) {
233
+ function create(context) {
234
+ const chain2 = function(...args) {
235
+ return fn.apply(context, args);
236
+ };
237
+ Object.assign(chain2, fn);
238
+ chain2.withContext = () => chain2.bind(context);
239
+ for (const key of keys) {
240
+ Object.defineProperty(chain2, key, {
241
+ get() {
242
+ return create({ ...context, [key]: true });
243
+ }
244
+ });
245
+ }
246
+ return chain2;
247
+ }
248
+ const chain = create({});
249
+ chain.fn = fn;
250
+ return chain;
251
+ }
252
+
253
253
  function isAtomTest(s) {
254
254
  return s.type === "test" || s.type === "custom";
255
255
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vitest/runner",
3
3
  "type": "module",
4
- "version": "0.29.6",
4
+ "version": "0.29.8",
5
5
  "description": "Vitest test runner",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -35,7 +35,7 @@
35
35
  "dependencies": {
36
36
  "p-limit": "^4.0.0",
37
37
  "pathe": "^1.1.0",
38
- "@vitest/utils": "0.29.6"
38
+ "@vitest/utils": "0.29.8"
39
39
  },
40
40
  "scripts": {
41
41
  "build": "rimraf dist && rollup -c",