vitest 0.30.1 → 0.31.0

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/LICENSE.md CHANGED
@@ -29,215 +29,6 @@ The published Vitest artifact additionally contains code with the following lice
29
29
  Apache-2.0, BSD-3-Clause, ISC, MIT
30
30
 
31
31
  # Bundled dependencies:
32
- ## @ampproject/remapping
33
- License: Apache-2.0
34
- By: Justin Ridgewell
35
- Repository: git+https://github.com/ampproject/remapping.git
36
-
37
- > Apache License
38
- > Version 2.0, January 2004
39
- > http://www.apache.org/licenses/
40
- >
41
- > TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
42
- >
43
- > 1. Definitions.
44
- >
45
- > "License" shall mean the terms and conditions for use, reproduction,
46
- > and distribution as defined by Sections 1 through 9 of this document.
47
- >
48
- > "Licensor" shall mean the copyright owner or entity authorized by
49
- > the copyright owner that is granting the License.
50
- >
51
- > "Legal Entity" shall mean the union of the acting entity and all
52
- > other entities that control, are controlled by, or are under common
53
- > control with that entity. For the purposes of this definition,
54
- > "control" means (i) the power, direct or indirect, to cause the
55
- > direction or management of such entity, whether by contract or
56
- > otherwise, or (ii) ownership of fifty percent (50%) or more of the
57
- > outstanding shares, or (iii) beneficial ownership of such entity.
58
- >
59
- > "You" (or "Your") shall mean an individual or Legal Entity
60
- > exercising permissions granted by this License.
61
- >
62
- > "Source" form shall mean the preferred form for making modifications,
63
- > including but not limited to software source code, documentation
64
- > source, and configuration files.
65
- >
66
- > "Object" form shall mean any form resulting from mechanical
67
- > transformation or translation of a Source form, including but
68
- > not limited to compiled object code, generated documentation,
69
- > and conversions to other media types.
70
- >
71
- > "Work" shall mean the work of authorship, whether in Source or
72
- > Object form, made available under the License, as indicated by a
73
- > copyright notice that is included in or attached to the work
74
- > (an example is provided in the Appendix below).
75
- >
76
- > "Derivative Works" shall mean any work, whether in Source or Object
77
- > form, that is based on (or derived from) the Work and for which the
78
- > editorial revisions, annotations, elaborations, or other modifications
79
- > represent, as a whole, an original work of authorship. For the purposes
80
- > of this License, Derivative Works shall not include works that remain
81
- > separable from, or merely link (or bind by name) to the interfaces of,
82
- > the Work and Derivative Works thereof.
83
- >
84
- > "Contribution" shall mean any work of authorship, including
85
- > the original version of the Work and any modifications or additions
86
- > to that Work or Derivative Works thereof, that is intentionally
87
- > submitted to Licensor for inclusion in the Work by the copyright owner
88
- > or by an individual or Legal Entity authorized to submit on behalf of
89
- > the copyright owner. For the purposes of this definition, "submitted"
90
- > means any form of electronic, verbal, or written communication sent
91
- > to the Licensor or its representatives, including but not limited to
92
- > communication on electronic mailing lists, source code control systems,
93
- > and issue tracking systems that are managed by, or on behalf of, the
94
- > Licensor for the purpose of discussing and improving the Work, but
95
- > excluding communication that is conspicuously marked or otherwise
96
- > designated in writing by the copyright owner as "Not a Contribution."
97
- >
98
- > "Contributor" shall mean Licensor and any individual or Legal Entity
99
- > on behalf of whom a Contribution has been received by Licensor and
100
- > subsequently incorporated within the Work.
101
- >
102
- > 2. Grant of Copyright License. Subject to the terms and conditions of
103
- > this License, each Contributor hereby grants to You a perpetual,
104
- > worldwide, non-exclusive, no-charge, royalty-free, irrevocable
105
- > copyright license to reproduce, prepare Derivative Works of,
106
- > publicly display, publicly perform, sublicense, and distribute the
107
- > Work and such Derivative Works in Source or Object form.
108
- >
109
- > 3. Grant of Patent License. Subject to the terms and conditions of
110
- > this License, each Contributor hereby grants to You a perpetual,
111
- > worldwide, non-exclusive, no-charge, royalty-free, irrevocable
112
- > (except as stated in this section) patent license to make, have made,
113
- > use, offer to sell, sell, import, and otherwise transfer the Work,
114
- > where such license applies only to those patent claims licensable
115
- > by such Contributor that are necessarily infringed by their
116
- > Contribution(s) alone or by combination of their Contribution(s)
117
- > with the Work to which such Contribution(s) was submitted. If You
118
- > institute patent litigation against any entity (including a
119
- > cross-claim or counterclaim in a lawsuit) alleging that the Work
120
- > or a Contribution incorporated within the Work constitutes direct
121
- > or contributory patent infringement, then any patent licenses
122
- > granted to You under this License for that Work shall terminate
123
- > as of the date such litigation is filed.
124
- >
125
- > 4. Redistribution. You may reproduce and distribute copies of the
126
- > Work or Derivative Works thereof in any medium, with or without
127
- > modifications, and in Source or Object form, provided that You
128
- > meet the following conditions:
129
- >
130
- > (a) You must give any other recipients of the Work or
131
- > Derivative Works a copy of this License; and
132
- >
133
- > (b) You must cause any modified files to carry prominent notices
134
- > stating that You changed the files; and
135
- >
136
- > (c) You must retain, in the Source form of any Derivative Works
137
- > that You distribute, all copyright, patent, trademark, and
138
- > attribution notices from the Source form of the Work,
139
- > excluding those notices that do not pertain to any part of
140
- > the Derivative Works; and
141
- >
142
- > (d) If the Work includes a "NOTICE" text file as part of its
143
- > distribution, then any Derivative Works that You distribute must
144
- > include a readable copy of the attribution notices contained
145
- > within such NOTICE file, excluding those notices that do not
146
- > pertain to any part of the Derivative Works, in at least one
147
- > of the following places: within a NOTICE text file distributed
148
- > as part of the Derivative Works; within the Source form or
149
- > documentation, if provided along with the Derivative Works; or,
150
- > within a display generated by the Derivative Works, if and
151
- > wherever such third-party notices normally appear. The contents
152
- > of the NOTICE file are for informational purposes only and
153
- > do not modify the License. You may add Your own attribution
154
- > notices within Derivative Works that You distribute, alongside
155
- > or as an addendum to the NOTICE text from the Work, provided
156
- > that such additional attribution notices cannot be construed
157
- > as modifying the License.
158
- >
159
- > You may add Your own copyright statement to Your modifications and
160
- > may provide additional or different license terms and conditions
161
- > for use, reproduction, or distribution of Your modifications, or
162
- > for any such Derivative Works as a whole, provided Your use,
163
- > reproduction, and distribution of the Work otherwise complies with
164
- > the conditions stated in this License.
165
- >
166
- > 5. Submission of Contributions. Unless You explicitly state otherwise,
167
- > any Contribution intentionally submitted for inclusion in the Work
168
- > by You to the Licensor shall be under the terms and conditions of
169
- > this License, without any additional terms or conditions.
170
- > Notwithstanding the above, nothing herein shall supersede or modify
171
- > the terms of any separate license agreement you may have executed
172
- > with Licensor regarding such Contributions.
173
- >
174
- > 6. Trademarks. This License does not grant permission to use the trade
175
- > names, trademarks, service marks, or product names of the Licensor,
176
- > except as required for reasonable and customary use in describing the
177
- > origin of the Work and reproducing the content of the NOTICE file.
178
- >
179
- > 7. Disclaimer of Warranty. Unless required by applicable law or
180
- > agreed to in writing, Licensor provides the Work (and each
181
- > Contributor provides its Contributions) on an "AS IS" BASIS,
182
- > WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
183
- > implied, including, without limitation, any warranties or conditions
184
- > of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
185
- > PARTICULAR PURPOSE. You are solely responsible for determining the
186
- > appropriateness of using or redistributing the Work and assume any
187
- > risks associated with Your exercise of permissions under this License.
188
- >
189
- > 8. Limitation of Liability. In no event and under no legal theory,
190
- > whether in tort (including negligence), contract, or otherwise,
191
- > unless required by applicable law (such as deliberate and grossly
192
- > negligent acts) or agreed to in writing, shall any Contributor be
193
- > liable to You for damages, including any direct, indirect, special,
194
- > incidental, or consequential damages of any character arising as a
195
- > result of this License or out of the use or inability to use the
196
- > Work (including but not limited to damages for loss of goodwill,
197
- > work stoppage, computer failure or malfunction, or any and all
198
- > other commercial damages or losses), even if such Contributor
199
- > has been advised of the possibility of such damages.
200
- >
201
- > 9. Accepting Warranty or Additional Liability. While redistributing
202
- > the Work or Derivative Works thereof, You may choose to offer,
203
- > and charge a fee for, acceptance of support, warranty, indemnity,
204
- > or other liability obligations and/or rights consistent with this
205
- > License. However, in accepting such obligations, You may act only
206
- > on Your own behalf and on Your sole responsibility, not on behalf
207
- > of any other Contributor, and only if You agree to indemnify,
208
- > defend, and hold each Contributor harmless for any liability
209
- > incurred by, or claims asserted against, such Contributor by reason
210
- > of your accepting any such warranty or additional liability.
211
- >
212
- > END OF TERMS AND CONDITIONS
213
- >
214
- > APPENDIX: How to apply the Apache License to your work.
215
- >
216
- > To apply the Apache License to your work, attach the following
217
- > boilerplate notice, with the fields enclosed by brackets "[]"
218
- > replaced with your own identifying information. (Don't include
219
- > the brackets!) The text should be enclosed in the appropriate
220
- > comment syntax for the file format. We also recommend that a
221
- > file or class name and description of purpose be included on the
222
- > same "printed page" as the copyright notice for easier
223
- > identification within third-party archives.
224
- >
225
- > Copyright 2019 Google LLC
226
- >
227
- > Licensed under the Apache License, Version 2.0 (the "License");
228
- > you may not use this file except in compliance with the License.
229
- > You may obtain a copy of the License at
230
- >
231
- > http://www.apache.org/licenses/LICENSE-2.0
232
- >
233
- > Unless required by applicable law or agreed to in writing, software
234
- > distributed under the License is distributed on an "AS IS" BASIS,
235
- > WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
236
- > See the License for the specific language governing permissions and
237
- > limitations under the License.
238
-
239
- ---------------------------------------
240
-
241
32
  ## @antfu/install-pkg
242
33
  License: MIT
243
34
  By: Anthony Fu
@@ -267,33 +58,6 @@ Repository: git+https://github.com/antfu/install-pkg.git
267
58
 
268
59
  ---------------------------------------
269
60
 
270
- ## @jridgewell/gen-mapping
271
- License: MIT
272
- By: Justin Ridgewell
273
- Repository: https://github.com/jridgewell/gen-mapping
274
-
275
- > Copyright 2022 Justin Ridgewell <jridgewell@google.com>
276
- >
277
- > Permission is hereby granted, free of charge, to any person obtaining a copy
278
- > of this software and associated documentation files (the "Software"), to deal
279
- > in the Software without restriction, including without limitation the rights
280
- > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
281
- > copies of the Software, and to permit persons to whom the Software is
282
- > furnished to do so, subject to the following conditions:
283
- >
284
- > The above copyright notice and this permission notice shall be included in
285
- > all copies or substantial portions of the Software.
286
- >
287
- > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
288
- > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
289
- > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
290
- > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
291
- > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
292
- > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
293
- > SOFTWARE.
294
-
295
- ---------------------------------------
296
-
297
61
  ## @jridgewell/resolve-uri
298
62
  License: MIT
299
63
  By: Justin Ridgewell
@@ -321,33 +85,6 @@ Repository: https://github.com/jridgewell/resolve-uri
321
85
 
322
86
  ---------------------------------------
323
87
 
324
- ## @jridgewell/set-array
325
- License: MIT
326
- By: Justin Ridgewell
327
- Repository: https://github.com/jridgewell/set-array
328
-
329
- > Copyright 2022 Justin Ridgewell <jridgewell@google.com>
330
- >
331
- > Permission is hereby granted, free of charge, to any person obtaining a copy
332
- > of this software and associated documentation files (the "Software"), to deal
333
- > in the Software without restriction, including without limitation the rights
334
- > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
335
- > copies of the Software, and to permit persons to whom the Software is
336
- > furnished to do so, subject to the following conditions:
337
- >
338
- > The above copyright notice and this permission notice shall be included in
339
- > all copies or substantial portions of the Software.
340
- >
341
- > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
342
- > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
343
- > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
344
- > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
345
- > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
346
- > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
347
- > SOFTWARE.
348
-
349
- ---------------------------------------
350
-
351
88
  ## @jridgewell/sourcemap-codec
352
89
  License: MIT
353
90
  By: Rich Harris
@@ -659,7 +396,7 @@ Repository: https://github.com/debitoor/chai-subset.git
659
396
 
660
397
  > The MIT License (MIT)
661
398
  >
662
- > Copyright (c) 2014
399
+ > Copyright (c) 2014
663
400
  >
664
401
  > Permission is hereby granted, free of charge, to any person obtaining a copy
665
402
  > of this software and associated documentation files (the "Software"), to deal
package/dist/browser.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export { startTests } from '@vitest/runner';
2
- import { a as ResolvedConfig, _ as CoverageOptions, S as CoverageProvider, Y as CoverageProviderModule } from './types-e3c9754d.js';
3
- import '@vitest/expect';
2
+ import { a as ResolvedConfig, $ as CoverageOptions, X as CoverageProvider, Z as CoverageProviderModule } from './types-b7007192.js';
4
3
  import '@vitest/snapshot';
4
+ import '@vitest/expect';
5
5
  import 'vite';
6
6
  import '@vitest/runner/types';
7
7
  import '@vitest/runner/utils';
@@ -9,10 +9,9 @@ import '@vitest/utils';
9
9
  import 'tinybench';
10
10
  import 'vite-node/client';
11
11
  import '@vitest/snapshot/manager';
12
+ import 'vite-node/server';
12
13
  import 'node:worker_threads';
13
14
  import 'vite-node';
14
- import 'source-map';
15
- import 'vite-node/server';
16
15
  import 'node:fs';
17
16
  import 'chai';
18
17
 
package/dist/browser.js CHANGED
@@ -1,6 +1,6 @@
1
1
  export { startTests } from '@vitest/runner';
2
- export { s as setupCommonEnv } from './vendor-setup.common.cef38f4e.js';
3
- export { g as getCoverageProvider, a as startCoverageInsideWorker, s as stopCoverageInsideWorker, t as takeCoverageInsideWorker } from './vendor-coverage.a585b712.js';
2
+ export { s as setupCommonEnv } from './vendor-setup.common.266b69fb.js';
3
+ export { g as getCoverageProvider, a as startCoverageInsideWorker, s as stopCoverageInsideWorker, t as takeCoverageInsideWorker } from './vendor-coverage.c8fd34c3.js';
4
4
  import '@vitest/utils';
5
5
  import './vendor-run-once.69ce7172.js';
6
6
  import './vendor-index.fad2598b.js';
package/dist/child.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import v8 from 'node:v8';
2
2
  import { c as createBirpc } from './vendor-index.7dcbfa46.js';
3
3
  import { parseRegexp } from '@vitest/utils';
4
- import { s as startViteNode, m as moduleCache, a as mockMap } from './vendor-execute.70609f6f.js';
4
+ import { s as startViteNode, m as moduleCache, a as mockMap } from './vendor-execute.a08cff9c.js';
5
5
  import { a as rpcDone } from './vendor-rpc.4d3d7a54.js';
6
6
  import { s as setupInspect } from './vendor-inspector.47fc8cbb.js';
7
7
  import 'node:url';
@@ -19,20 +19,28 @@ function init(ctx) {
19
19
  const { config } = ctx;
20
20
  process.env.VITEST_WORKER_ID = "1";
21
21
  process.env.VITEST_POOL_ID = "1";
22
+ let setCancel = (_reason) => {
23
+ };
24
+ const onCancel = new Promise((resolve) => {
25
+ setCancel = resolve;
26
+ });
22
27
  globalThis.__vitest_environment__ = config.environment;
23
28
  globalThis.__vitest_worker__ = {
24
29
  ctx,
25
30
  moduleCache,
26
31
  config,
27
32
  mockMap,
33
+ onCancel,
28
34
  durations: {
29
35
  environment: 0,
30
36
  prepare: performance.now()
31
37
  },
32
38
  rpc: createBirpc(
33
- {},
34
39
  {
35
- eventNames: ["onUserConsoleLog", "onFinished", "onCollected", "onWorkerExit"],
40
+ onCancel: setCancel
41
+ },
42
+ {
43
+ eventNames: ["onUserConsoleLog", "onFinished", "onCollected", "onWorkerExit", "onCancel"],
36
44
  serialize: v8.serialize,
37
45
  deserialize: (v) => v8.deserialize(Buffer.from(v)),
38
46
  post(v) {
@@ -4576,16 +4576,23 @@ function setup(vitestOrWorkspace, server) {
4576
4576
  if (!file)
4577
4577
  return ctx.updateSnapshot();
4578
4578
  return ctx.updateSnapshot([file.filepath]);
4579
+ },
4580
+ onCancel(reason) {
4581
+ ctx.cancelCurrentRun(reason);
4582
+ },
4583
+ getCountOfFailedTests() {
4584
+ return ctx.state.getCountOfFailedTests();
4579
4585
  }
4580
4586
  },
4581
4587
  {
4582
4588
  post: (msg) => ws.send(msg),
4583
4589
  on: (fn) => ws.on("message", fn),
4584
- eventNames: ["onUserConsoleLog", "onFinished", "onCollected"],
4590
+ eventNames: ["onUserConsoleLog", "onFinished", "onCollected", "onCancel"],
4585
4591
  serialize: stringify,
4586
4592
  deserialize: parse$3
4587
4593
  }
4588
4594
  );
4595
+ ctx.onCancel((reason) => rpc.onCancel(reason));
4589
4596
  clients.set(ws, rpc);
4590
4597
  ws.on("close", () => {
4591
4598
  clients.delete(ws);
@@ -3,7 +3,7 @@ import p from 'path';
3
3
  import require$$0$1 from 'util';
4
4
  import require$$0$3 from 'child_process';
5
5
  import { p as pathKey, s as signalExit, m as mergeStream$1, g as getStream$1, c as crossSpawn$1 } from './vendor-index.c1e09929.js';
6
- import { o as onetime$1 } from './vendor-cli-api.70680cd5.js';
6
+ import { o as onetime$1 } from './vendor-cli-api.de0530cb.js';
7
7
  import require$$0$2 from 'os';
8
8
  import 'node:buffer';
9
9
  import 'node:path';
@@ -20,7 +20,7 @@ import 'stream';
20
20
  import 'node:util';
21
21
  import 'pathe';
22
22
  import './vendor-constants.538d9b49.js';
23
- import './vendor-coverage.a585b712.js';
23
+ import './vendor-coverage.c8fd34c3.js';
24
24
  import './vendor-index.75f2b63d.js';
25
25
  import 'node:console';
26
26
  import 'local-pkg';
@@ -34,6 +34,7 @@ import 'vite';
34
34
  import 'vite-node/utils';
35
35
  import 'vite-node/client';
36
36
  import '@vitest/snapshot/manager';
37
+ import 'vite-node/server';
37
38
  import './vendor-paths.84fc7a99.js';
38
39
  import 'node:v8';
39
40
  import './vendor-index.7dcbfa46.js';
@@ -44,13 +45,11 @@ import './vendor-tasks.042d6084.js';
44
45
  import 'node:module';
45
46
  import 'node:crypto';
46
47
  import 'node:fs/promises';
47
- import 'source-map';
48
48
  import 'module';
49
49
  import 'acorn';
50
50
  import 'acorn-walk';
51
51
  import 'magic-string';
52
52
  import 'strip-literal';
53
- import 'vite-node/server';
54
53
  import 'node:readline';
55
54
  import 'readline';
56
55
 
@@ -1,7 +1,7 @@
1
1
  import { g as globalApis } from './vendor-constants.538d9b49.js';
2
- import { i as index } from './vendor-index.81b9e499.js';
2
+ import { i as index } from './vendor-index.b0b501c8.js';
3
3
  import '@vitest/runner';
4
- import './vendor-vi.a3ff54b1.js';
4
+ import './vendor-vi.458e47b1.js';
5
5
  import '@vitest/runner/utils';
6
6
  import '@vitest/utils';
7
7
  import './vendor-index.fad2598b.js';
package/dist/cli.js CHANGED
@@ -1,12 +1,13 @@
1
1
  import { normalize } from 'pathe';
2
2
  import cac from 'cac';
3
3
  import c from 'picocolors';
4
- import { v as version, s as startVitest, d as divider } from './vendor-cli-api.70680cd5.js';
4
+ import { v as version, s as startVitest, d as divider } from './vendor-cli-api.de0530cb.js';
5
5
  import './vendor-constants.538d9b49.js';
6
- import './vendor-coverage.a585b712.js';
6
+ import './vendor-coverage.c8fd34c3.js';
7
7
  import './vendor-index.75f2b63d.js';
8
8
  import 'node:console';
9
9
  import 'local-pkg';
10
+ import 'node:url';
10
11
  import './vendor-index.fad2598b.js';
11
12
  import 'std-env';
12
13
  import '@vitest/runner/utils';
@@ -14,7 +15,6 @@ import '@vitest/utils';
14
15
  import './vendor-global.6795f91f.js';
15
16
  import 'vite';
16
17
  import 'node:path';
17
- import 'node:url';
18
18
  import 'node:process';
19
19
  import 'node:fs';
20
20
  import 'path';
@@ -27,6 +27,7 @@ import './vendor-_commonjsHelpers.76cdd49e.js';
27
27
  import 'vite-node/utils';
28
28
  import 'vite-node/client';
29
29
  import '@vitest/snapshot/manager';
30
+ import 'vite-node/server';
30
31
  import './vendor-paths.84fc7a99.js';
31
32
  import 'node:v8';
32
33
  import 'node:child_process';
@@ -45,18 +46,16 @@ import 'assert';
45
46
  import 'buffer';
46
47
  import 'node:util';
47
48
  import 'node:fs/promises';
48
- import 'source-map';
49
49
  import 'module';
50
50
  import 'acorn';
51
51
  import 'acorn-walk';
52
52
  import 'magic-string';
53
53
  import 'strip-literal';
54
- import 'vite-node/server';
55
54
  import 'node:readline';
56
55
  import 'readline';
57
56
 
58
57
  const cli = cac("vitest");
59
- 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", "Enable watch mode").option("-t, --testNamePattern <pattern>", "Run tests with full names matching the specified regexp pattern").option("--dir <path>", "Base directory to scan for the test files").option("--ui", "Enable UI").option("--open", "Open UI automatically (default: !process.env.CI))").option("--api [api]", "Serve API, available options: --api.port <port>, --api.host [host] and --api.strictPort").option("--threads", "Enabled threads (default: true)").option("--single-thread", "Run tests inside a single thread, requires --threads (default: false)").option("--silent", "Silent console output from tests").option("--isolate", "Isolate environment for each test file (default: true)").option("--reporter <name>", "Specify reporters").option("--outputFile <filename/-s>", "Write test results to a file when supporter reporter is also specified, use cac's dot notation for individual outputs of multiple reporters").option("--coverage", "Enable coverage report").option("--run", "Disable watch mode").option("--mode <name>", "Override Vite mode (default: test)").option("--globals", "Inject apis globally").option("--dom", "Mock browser api with happy-dom").option("--browser [options]", "Run tests in the browser (default: false)").option("--environment <env>", "Specify runner environment, if not running in the browser (default: node)").option("--passWithNoTests", "Pass when no tests found").option("--logHeapUsage", "Show the size of heap for each test").option("--allowOnly", "Allow tests and suites that are marked as only (default: !process.env.CI)").option("--dangerouslyIgnoreUnhandledErrors", "Ignore any unhandled errors that occur").option("--shard <shard>", "Test suite shard to execute in a format of <index>/<count>").option("--changed [since]", "Run tests that are affected by the changed files (default: false)").option("--sequence <options>", "Define in what order to run tests (use --sequence.shuffle to run tests in random order)").option("--segfaultRetry <times>", "Return tests on segment fault (default: 0)", { default: 0 }).option("--no-color", "Removes colors from the console output").option("--inspect", "Enable Node.js inspector").option("--inspect-brk", "Enable Node.js inspector with break").option("--test-timeout <time>", "Default timeout of a test in milliseconds (default: 5000)").help();
58
+ 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", "Enable watch mode").option("-t, --testNamePattern <pattern>", "Run tests with full names matching the specified regexp pattern").option("--dir <path>", "Base directory to scan for the test files").option("--ui", "Enable UI").option("--open", "Open UI automatically (default: !process.env.CI))").option("--api [api]", "Serve API, available options: --api.port <port>, --api.host [host] and --api.strictPort").option("--threads", "Enabled threads (default: true)").option("--single-thread", "Run tests inside a single thread, requires --threads (default: false)").option("--silent", "Silent console output from tests").option("--hideSkippedTests", "Hide logs for skipped tests").option("--isolate", "Isolate environment for each test file (default: true)").option("--reporter <name>", "Specify reporters").option("--outputFile <filename/-s>", "Write test results to a file when supporter reporter is also specified, use cac's dot notation for individual outputs of multiple reporters").option("--coverage", "Enable coverage report").option("--run", "Disable watch mode").option("--mode <name>", "Override Vite mode (default: test)").option("--globals", "Inject apis globally").option("--dom", "Mock browser api with happy-dom").option("--browser [options]", "Run tests in the browser (default: false)").option("--environment <env>", "Specify runner environment, if not running in the browser (default: node)").option("--passWithNoTests", "Pass when no tests found").option("--logHeapUsage", "Show the size of heap for each test").option("--allowOnly", "Allow tests and suites that are marked as only (default: !process.env.CI)").option("--dangerouslyIgnoreUnhandledErrors", "Ignore any unhandled errors that occur").option("--shard <shard>", "Test suite shard to execute in a format of <index>/<count>").option("--changed [since]", "Run tests that are affected by the changed files (default: false)").option("--sequence <options>", "Define in what order to run tests (use --sequence.shuffle to run tests in random order)").option("--segfaultRetry <times>", "Return tests on segment fault (default: 0)", { default: 0 }).option("--no-color", "Removes colors from the console output").option("--inspect", "Enable Node.js inspector").option("--inspect-brk", "Enable Node.js inspector with break").option("--test-timeout <time>", "Default timeout of a test in milliseconds (default: 5000)").option("--bail <number>", "Stop test execution when given number of tests have failed", { default: 0 }).help();
60
59
  cli.command("run [...filters]").action(run);
61
60
  cli.command("related [...filters]").action(runRelated);
62
61
  cli.command("watch [...filters]").action(watch);
package/dist/config.cjs CHANGED
@@ -70,6 +70,7 @@ const config = {
70
70
  update: false,
71
71
  reporters: [],
72
72
  silent: false,
73
+ hideSkippedTests: false,
73
74
  api: false,
74
75
  ui: false,
75
76
  uiBase: "/__vitest__/",
package/dist/config.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { UserConfig as UserConfig$2, ConfigEnv } from 'vite';
2
2
  export { ConfigEnv, mergeConfig } from 'vite';
3
- import { $ as ResolvedCoverageOptions, q as UserConfig$1, a2 as CoverageC8Options, a3 as CustomProviderOptions, a1 as CoverageIstanbulOptions, af as HtmlOptions, ag as FileOptions, ah as CloverOptions, ai as CoberturaOptions, aj as HtmlSpaOptions, ak as LcovOptions, al as LcovOnlyOptions, am as TeamcityOptions, an as TextOptions, ao as ProjectOptions, F as FakeTimerInstallOpts, P as ProjectConfig } from './types-e3c9754d.js';
4
- import '@vitest/expect';
3
+ import { a0 as ResolvedCoverageOptions, q as UserConfig$1, a3 as CoverageC8Options, a4 as CustomProviderOptions, a2 as CoverageIstanbulOptions, ag as HtmlOptions, ah as FileOptions, ai as CloverOptions, aj as CoberturaOptions, ak as HtmlSpaOptions, al as LcovOptions, am as LcovOnlyOptions, an as TeamcityOptions, ao as TextOptions, ap as ProjectOptions, F as FakeTimerInstallOpts, P as ProjectConfig } from './types-b7007192.js';
5
4
  import '@vitest/snapshot';
5
+ import '@vitest/expect';
6
6
  import '@vitest/runner';
7
7
  import '@vitest/runner/types';
8
8
  import '@vitest/runner/utils';
@@ -10,10 +10,9 @@ import '@vitest/utils';
10
10
  import 'tinybench';
11
11
  import 'vite-node/client';
12
12
  import '@vitest/snapshot/manager';
13
+ import 'vite-node/server';
13
14
  import 'node:worker_threads';
14
15
  import 'vite-node';
15
- import 'source-map';
16
- import 'vite-node/server';
17
16
  import 'node:fs';
18
17
  import 'chai';
19
18
 
@@ -40,6 +39,7 @@ declare const config: {
40
39
  update: boolean;
41
40
  reporters: never[];
42
41
  silent: boolean;
42
+ hideSkippedTests: boolean;
43
43
  api: boolean;
44
44
  ui: boolean;
45
45
  uiBase: string;
@@ -73,10 +73,10 @@ declare const config: {
73
73
  declare const configDefaults: Required<Pick<UserConfig$1, keyof typeof config>>;
74
74
 
75
75
  interface UserConfig extends UserConfig$2 {
76
- test?: UserConfig$2['test'];
76
+ test?: UserConfig$2['test'] | undefined;
77
77
  }
78
78
  interface UserWorkspaceConfig extends UserConfig$2 {
79
- test?: ProjectConfig;
79
+ test?: ProjectConfig | undefined;
80
80
  }
81
81
 
82
82
  type UserConfigFn = (env: ConfigEnv) => UserConfig | Promise<UserConfig>;
package/dist/config.js CHANGED
@@ -68,6 +68,7 @@ const config = {
68
68
  update: false,
69
69
  reporters: [],
70
70
  silent: false,
71
+ hideSkippedTests: false,
71
72
  api: false,
72
73
  ui: false,
73
74
  uiBase: "/__vitest__/",
@@ -1,6 +1,6 @@
1
- import { a0 as BaseCoverageOptions, $ as ResolvedCoverageOptions } from './types-e3c9754d.js';
2
- import '@vitest/expect';
1
+ import { a1 as BaseCoverageOptions, a0 as ResolvedCoverageOptions } from './types-b7007192.js';
3
2
  import '@vitest/snapshot';
3
+ import '@vitest/expect';
4
4
  import 'vite';
5
5
  import '@vitest/runner';
6
6
  import '@vitest/runner/types';
@@ -9,10 +9,9 @@ import '@vitest/utils';
9
9
  import 'tinybench';
10
10
  import 'vite-node/client';
11
11
  import '@vitest/snapshot/manager';
12
+ import 'vite-node/server';
12
13
  import 'node:worker_threads';
13
14
  import 'vite-node';
14
- import 'source-map';
15
- import 'vite-node/server';
16
15
  import 'node:fs';
17
16
  import 'chai';
18
17
 
@@ -131,9 +130,10 @@ declare class BaseCoverageProvider {
131
130
  /**
132
131
  * Check if current coverage is above configured thresholds and bump the thresholds if needed
133
132
  */
134
- updateThresholds({ configurationFile, coverageMap, thresholds }: {
133
+ updateThresholds({ configurationFile, coverageMap, thresholds, perFile }: {
135
134
  coverageMap: CoverageMap;
136
135
  thresholds: Record<Threshold, number | undefined>;
136
+ perFile?: boolean;
137
137
  configurationFile?: string;
138
138
  }): void;
139
139
  /**
package/dist/coverage.js CHANGED
@@ -5,27 +5,27 @@ class BaseCoverageProvider {
5
5
  /**
6
6
  * Check if current coverage is above configured thresholds and bump the thresholds if needed
7
7
  */
8
- updateThresholds({ configurationFile, coverageMap, thresholds }) {
8
+ updateThresholds({ configurationFile, coverageMap, thresholds, perFile }) {
9
9
  if (!configurationFile)
10
10
  throw new Error('Missing configurationFile. The "coverage.thresholdAutoUpdate" can only be enabled when configuration file is used.');
11
- const summary = coverageMap.getCoverageSummary();
11
+ const summaries = perFile ? coverageMap.files().map((file) => coverageMap.fileCoverageFor(file).toSummary()) : [coverageMap.getCoverageSummary()];
12
12
  const thresholdsToUpdate = [];
13
13
  for (const key of THRESHOLD_KEYS) {
14
14
  const threshold = thresholds[key] || 100;
15
- const actual = summary[key].pct;
15
+ const actual = Math.min(...summaries.map((summary) => summary[key].pct));
16
16
  if (actual > threshold)
17
- thresholdsToUpdate.push(key);
17
+ thresholdsToUpdate.push([key, actual]);
18
18
  }
19
19
  if (thresholdsToUpdate.length === 0)
20
20
  return;
21
21
  const originalConfig = readFileSync(configurationFile, "utf8");
22
22
  let updatedConfig = originalConfig;
23
- for (const threshold of thresholdsToUpdate) {
23
+ for (const [threshold, newValue] of thresholdsToUpdate) {
24
24
  const previousThreshold = (thresholds[threshold] || 100).toString();
25
25
  const pattern = new RegExp(`(${threshold}\\s*:\\s*)${previousThreshold.replace(".", "\\.")}`);
26
26
  const matches = originalConfig.match(pattern);
27
27
  if (matches)
28
- updatedConfig = updatedConfig.replace(matches[0], matches[1] + summary[threshold].pct);
28
+ updatedConfig = updatedConfig.replace(matches[0], matches[1] + newValue);
29
29
  else
30
30
  console.error(`Unable to update coverage threshold ${threshold}. No threshold found using pattern ${pattern}`);
31
31
  }