vitest 0.21.1 → 0.22.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.
Files changed (43) hide show
  1. package/LICENSE.md +32 -4
  2. package/dist/browser.d.ts +4 -5
  3. package/dist/browser.mjs +8 -9
  4. package/dist/{chunk-api-setup.7a6ba7fb.mjs → chunk-api-setup.ecd02c18.mjs} +8 -7
  5. package/dist/{chunk-constants.26dc9f85.mjs → chunk-constants.d3f8437b.mjs} +4 -4
  6. package/dist/{chunk-install-pkg.6c6dc0c2.mjs → chunk-install-pkg.3aa3eae6.mjs} +3 -2
  7. package/dist/{chunk-defaults.02abff90.mjs → chunk-integrations-coverage.d205bd87.mjs} +23 -152
  8. package/dist/{chunk-integrations-globals.44a8f047.mjs → chunk-integrations-globals.e81d2091.mjs} +7 -6
  9. package/dist/{chunk-mock-date.bc81a3ac.mjs → chunk-mock-date.debe9954.mjs} +6 -67
  10. package/dist/chunk-node-git.71b74da4.mjs +80 -0
  11. package/dist/{chunk-runtime-chain.98d42d89.mjs → chunk-runtime-chain.6e363ba2.mjs} +4 -3
  12. package/dist/{chunk-runtime-error.87a2b5a2.mjs → chunk-runtime-error.975bd80a.mjs} +13 -12
  13. package/dist/{chunk-runtime-hooks.453f8858.mjs → chunk-runtime-hooks.4789e99d.mjs} +3 -3
  14. package/dist/{chunk-runtime-mocker.23b62bfa.mjs → chunk-runtime-mocker.c91d29ce.mjs} +5 -5
  15. package/dist/{chunk-runtime-rpc.b50ab560.mjs → chunk-runtime-rpc.29488183.mjs} +1 -1
  16. package/dist/{chunk-utils-source-map.94107ee8.mjs → chunk-utils-source-map.2a082ffd.mjs} +2 -1
  17. package/dist/{chunk-vite-node-client.fdd9592c.mjs → chunk-vite-node-client.d1ead698.mjs} +2 -2
  18. package/dist/{chunk-vite-node-debug.09afb76f.mjs → chunk-vite-node-debug.ff1d2a9f.mjs} +3 -2
  19. package/dist/{chunk-vite-node-externalize.27aee038.mjs → chunk-vite-node-externalize.3a38c8af.mjs} +153 -35
  20. package/dist/{chunk-vite-node-utils.f34df9d3.mjs → chunk-vite-node-utils.d8e5ff7b.mjs} +42 -8
  21. package/dist/cli-wrapper.mjs +107 -0
  22. package/dist/cli.mjs +15 -13
  23. package/dist/config.cjs +3 -0
  24. package/dist/config.d.ts +6 -3
  25. package/dist/config.mjs +2 -1
  26. package/dist/entry.mjs +8 -9
  27. package/dist/{global-60f880c6.d.ts → global-74489cc9.d.ts} +485 -166
  28. package/dist/{index-4a906fa4.d.ts → index-9eded9ec.d.ts} +2 -50
  29. package/dist/index.d.ts +5 -6
  30. package/dist/index.mjs +6 -5
  31. package/dist/loader.mjs +3 -2
  32. package/dist/node.d.ts +3 -3
  33. package/dist/node.mjs +14 -12
  34. package/dist/suite.mjs +5 -4
  35. package/dist/{vendor-index.61438b77.mjs → vendor-index.29636037.mjs} +1 -61
  36. package/dist/{vendor-index.62ce5c33.mjs → vendor-index.2ae8040a.mjs} +0 -0
  37. package/dist/vendor-index.9d9196cc.mjs +61 -0
  38. package/dist/{chunk-node-git.c2be9c49.mjs → vendor-index.fbec8a81.mjs} +5 -73
  39. package/dist/vendor-picocolors.807856aa.mjs +64 -0
  40. package/dist/worker.mjs +7 -6
  41. package/package.json +6 -10
  42. package/vitest.mjs +1 -1
  43. package/dist/mocker-5e2a8e41.d.ts +0 -3
package/LICENSE.md CHANGED
@@ -898,7 +898,7 @@ Repository: ehmicky/human-signals
898
898
  > same "printed page" as the copyright notice for easier
899
899
  > identification within third-party archives.
900
900
  >
901
- > Copyright 2019 ehmicky <ehmicky@gmail.com>
901
+ > Copyright 2021 ehmicky <ehmicky@gmail.com>
902
902
  >
903
903
  > Licensed under the Apache License, Version 2.0 (the "License");
904
904
  > you may not use this file except in compliance with the License.
@@ -1310,7 +1310,7 @@ Repository: sindresorhus/npm-run-path
1310
1310
 
1311
1311
  > MIT License
1312
1312
  >
1313
- > Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
1313
+ > Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
1314
1314
  >
1315
1315
  > Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
1316
1316
  >
@@ -1395,7 +1395,7 @@ Repository: sindresorhus/path-key
1395
1395
 
1396
1396
  > MIT License
1397
1397
  >
1398
- > Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
1398
+ > Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
1399
1399
  >
1400
1400
  > Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
1401
1401
  >
@@ -1911,7 +1911,7 @@ Repository: sindresorhus/strip-final-newline
1911
1911
 
1912
1912
  > MIT License
1913
1913
  >
1914
- > Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
1914
+ > Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
1915
1915
  >
1916
1916
  > Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
1917
1917
  >
@@ -1977,6 +1977,34 @@ Repository: git+ssh://git@github.com/chaijs/type-detect.git
1977
1977
 
1978
1978
  ---------------------------------------
1979
1979
 
1980
+ ## ufo
1981
+ License: MIT
1982
+ Repository: unjs/ufo
1983
+
1984
+ > MIT License
1985
+ >
1986
+ > Copyright (c) 2020 Nuxt Contrib
1987
+ >
1988
+ > Permission is hereby granted, free of charge, to any person obtaining a copy
1989
+ > of this software and associated documentation files (the "Software"), to deal
1990
+ > in the Software without restriction, including without limitation the rights
1991
+ > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1992
+ > copies of the Software, and to permit persons to whom the Software is
1993
+ > furnished to do so, subject to the following conditions:
1994
+ >
1995
+ > The above copyright notice and this permission notice shall be included in all
1996
+ > copies or substantial portions of the Software.
1997
+ >
1998
+ > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1999
+ > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2000
+ > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2001
+ > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2002
+ > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2003
+ > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2004
+ > SOFTWARE.
2005
+
2006
+ ---------------------------------------
2007
+
1980
2008
  ## vite-node
1981
2009
  License: MIT
1982
2010
  By: Anthony Fu
package/dist/browser.d.ts CHANGED
@@ -1,13 +1,12 @@
1
- export { E as EnhancedSpy, q as Mock, r as MockContext, p as MockInstance, u as Mocked, v as MockedClass, n as MockedFunction, o as MockedObject, R as ResolveIdFunction, S as SpyInstance, W as WorkerContext, x as WorkerGlobalState, w as WorkerRPC, h as afterAll, k as afterEach, g as beforeAll, j as beforeEach, m as createExpect, e as describe, l as expect, i as it, d as suite, t as test } from './index-4a906fa4.js';
2
- import { R as ResolvedConfig } from './global-60f880c6.js';
3
- export { A as ApiConfig, C as ArgumentsType, z as Arrayable, y as Awaitable, B as BuiltinEnvironment, a0 as C8Options, O as Constructable, $ as CoverageReporter, K as DeepMerge, D as DoneCallback, W as Environment, E as EnvironmentOptions, Q as EnvironmentReturn, _ as ErrorWithDiff, a as File, l as HookCleanupCallback, H as HookListener, I as InlineConfig, J as JSDOMOptions, G as MergeInsertions, P as ModuleCache, M as ModuleGraphData, L as MutableArray, N as Nullable, Z as ParsedStack, Y as Position, b as Reporter, a1 as ResolvedC8Options, R as ResolvedConfig, c as RunMode, p as RuntimeContext, r as SnapshotData, u as SnapshotMatchOptions, v as SnapshotResult, t as SnapshotStateOptions, x as SnapshotSummary, s as SnapshotUpdateState, S as Suite, k as SuiteAPI, n as SuiteCollector, o as SuiteFactory, m as SuiteHooks, h as Task, e as TaskBase, f as TaskResult, T as TaskResultPack, d as TaskState, g as Test, j as TestAPI, q as TestContext, i as TestFunction, w as UncheckedSnapshot, U as UserConfig, X as UserConsoleLog, V as Vitest } from './global-60f880c6.js';
1
+ export { E as EnhancedSpy, q as Mock, r as MockContext, p as MockInstance, u as Mocked, v as MockedClass, n as MockedFunction, o as MockedObject, S as SpyInstance, h as afterAll, k as afterEach, g as beforeAll, j as beforeEach, m as createExpect, e as describe, l as expect, i as it, d as suite, t as test } from './index-9eded9ec.js';
2
+ import { R as ResolvedConfig } from './global-74489cc9.js';
3
+ export { z as AfterSuiteRunMeta, A as ApiConfig, O as ArgumentsType, L as Arrayable, K as Awaitable, a9 as BaseCoverageOptions, B as BuiltinEnvironment, Y as Constructable, ab as CoverageC8Options, aa as CoverageIstanbulOptions, a7 as CoverageOptions, a4 as CoverageProvider, a5 as CoverageProviderModule, a6 as CoverageReporter, Q as DeepMerge, D as DoneCallback, $ as Environment, E as EnvironmentOptions, _ as EnvironmentReturn, a3 as ErrorWithDiff, a as File, l as HookCleanupCallback, H as HookListener, I as InlineConfig, J as JSDOMOptions, P as MergeInsertions, Z as ModuleCache, M as ModuleGraphData, X as MutableArray, N as Nullable, a2 as ParsedStack, a1 as Position, b as Reporter, y as ResolveIdFunction, R as ResolvedConfig, a8 as ResolvedCoverageOptions, c as RunMode, p as RuntimeContext, r as SnapshotData, u as SnapshotMatchOptions, v as SnapshotResult, t as SnapshotStateOptions, x as SnapshotSummary, s as SnapshotUpdateState, S as Suite, k as SuiteAPI, n as SuiteCollector, o as SuiteFactory, m as SuiteHooks, h as Task, e as TaskBase, f as TaskResult, T as TaskResultPack, d as TaskState, g as Test, j as TestAPI, q as TestContext, i as TestFunction, w as UncheckedSnapshot, U as UserConfig, a0 as UserConsoleLog, V as Vitest, W as WorkerContext, G as WorkerGlobalState, C as WorkerRPC } from './global-74489cc9.js';
4
4
  import * as chai from 'chai';
5
5
  export { chai };
6
6
  export { assert, should } from 'chai';
7
- import 'worker_threads';
8
- import './mocker-5e2a8e41.js';
9
7
  import 'tinyspy';
10
8
  import 'vite';
9
+ import 'worker_threads';
11
10
  import 'fs';
12
11
 
13
12
  declare function startTests(paths: string[], config: ResolvedConfig): Promise<void>;
package/dist/browser.mjs CHANGED
@@ -1,22 +1,21 @@
1
- export { c as createExpect, d as describe, b as expect, i as it, s as suite, t as test } from './chunk-runtime-chain.98d42d89.mjs';
2
- export { a as afterAll, d as afterEach, b as beforeAll, c as beforeEach } from './chunk-runtime-hooks.453f8858.mjs';
3
- export { a as setupGlobalEnv, s as startTests } from './chunk-runtime-error.87a2b5a2.mjs';
1
+ export { c as createExpect, d as describe, b as expect, i as it, s as suite, t as test } from './chunk-runtime-chain.6e363ba2.mjs';
2
+ export { a as afterAll, d as afterEach, b as beforeAll, c as beforeEach } from './chunk-runtime-hooks.4789e99d.mjs';
3
+ export { a as setupGlobalEnv, s as startTests } from './chunk-runtime-error.975bd80a.mjs';
4
4
  import * as chai from 'chai';
5
5
  export { chai };
6
6
  export { assert, should } from 'chai';
7
7
  import 'util';
8
- import './chunk-mock-date.bc81a3ac.mjs';
8
+ import './chunk-mock-date.debe9954.mjs';
9
9
  import 'path';
10
+ import './vendor-picocolors.807856aa.mjs';
10
11
  import 'tty';
11
12
  import 'local-pkg';
12
13
  import './vendor-_commonjsHelpers.4da45ef5.mjs';
13
- import './chunk-runtime-rpc.b50ab560.mjs';
14
+ import './chunk-runtime-rpc.29488183.mjs';
14
15
  import './chunk-utils-global.fa20c2f6.mjs';
15
16
  import './chunk-utils-timers.b48455ed.mjs';
16
17
  import 'fs';
17
- import './chunk-utils-source-map.94107ee8.mjs';
18
+ import './chunk-utils-source-map.2a082ffd.mjs';
18
19
  import './spy.mjs';
19
20
  import 'tinyspy';
20
- import './chunk-defaults.02abff90.mjs';
21
- import 'module';
22
- import 'url';
21
+ import './chunk-integrations-coverage.d205bd87.mjs';
@@ -1,5 +1,5 @@
1
1
  import { promises } from 'fs';
2
- import { c as createBirpc } from './chunk-vite-node-client.fdd9592c.mjs';
2
+ import { c as createBirpc } from './chunk-vite-node-client.d1ead698.mjs';
3
3
  import require$$0$1 from 'stream';
4
4
  import require$$0 from 'zlib';
5
5
  import require$$3 from 'net';
@@ -8,16 +8,17 @@ import require$$5 from 'crypto';
8
8
  import require$$2 from 'events';
9
9
  import require$$1 from 'https';
10
10
  import require$$2$1 from 'http';
11
- import _url from 'url';
12
- import { A as API_PATH } from './chunk-constants.26dc9f85.mjs';
13
- import { j as interpretSourcePos, p as parseStacktrace } from './chunk-utils-source-map.94107ee8.mjs';
11
+ import url from 'url';
12
+ import { A as API_PATH } from './chunk-constants.d3f8437b.mjs';
13
+ import { j as interpretSourcePos, p as parseStacktrace } from './chunk-utils-source-map.2a082ffd.mjs';
14
14
  import 'module';
15
15
  import 'vm';
16
- import './chunk-mock-date.bc81a3ac.mjs';
16
+ import './chunk-mock-date.debe9954.mjs';
17
17
  import 'path';
18
+ import './vendor-picocolors.807856aa.mjs';
18
19
  import 'tty';
19
20
  import 'local-pkg';
20
- import './chunk-vite-node-utils.f34df9d3.mjs';
21
+ import './chunk-vite-node-utils.d8e5ff7b.mjs';
21
22
  import 'assert';
22
23
  import 'util';
23
24
  import 'debug';
@@ -2514,7 +2515,7 @@ const http$1 = require$$2$1;
2514
2515
  const net = require$$3;
2515
2516
  const tls = require$$4;
2516
2517
  const { randomBytes, createHash: createHash$1 } = require$$5;
2517
- const { URL: URL$1 } = _url;
2518
+ const { URL: URL$1 } = url;
2518
2519
 
2519
2520
  const PerMessageDeflate$1 = permessageDeflate;
2520
2521
  const Receiver = receiver;
@@ -1,8 +1,8 @@
1
- import _url from 'url';
2
- import { y as resolve } from './chunk-mock-date.bc81a3ac.mjs';
1
+ import url from 'url';
2
+ import { x as resolve } from './chunk-mock-date.debe9954.mjs';
3
3
 
4
- const rootDir = resolve(_url.fileURLToPath(import.meta.url), "../../");
5
- const distDir = resolve(_url.fileURLToPath(import.meta.url), "../../dist");
4
+ const rootDir = resolve(url.fileURLToPath(import.meta.url), "../../");
5
+ const distDir = resolve(url.fileURLToPath(import.meta.url), "../../dist");
6
6
  const defaultPort = 51204;
7
7
  const API_PATH = "/__vitest_api__";
8
8
  const configFiles = [
@@ -2,9 +2,10 @@ import path$2 from 'path';
2
2
  import fs$2 from 'fs';
3
3
  import util from 'util';
4
4
  import childProcess$1 from 'child_process';
5
- import { p as pathKey, m as mergeStream$1, g as getStream$1, c as crossSpawn$1 } from './vendor-index.62ce5c33.mjs';
6
- import { s as signalExit, o as onetime$1 } from './vendor-index.61438b77.mjs';
5
+ import { p as pathKey, m as mergeStream$1, g as getStream$1, c as crossSpawn$1 } from './vendor-index.2ae8040a.mjs';
6
+ import { o as onetime$1 } from './vendor-index.9d9196cc.mjs';
7
7
  import require$$0 from 'os';
8
+ import { s as signalExit } from './vendor-index.29636037.mjs';
8
9
  import './vendor-_commonjsHelpers.4da45ef5.mjs';
9
10
  import 'buffer';
10
11
  import 'stream';
@@ -1,7 +1,3 @@
1
- import { existsSync, promises } from 'fs';
2
- import { createRequire } from 'module';
3
- import _url from 'url';
4
- import { t as toArray, y as resolve } from './chunk-mock-date.bc81a3ac.mjs';
5
1
  import { importModule } from 'local-pkg';
6
2
 
7
3
  /*
@@ -139,156 +135,31 @@ function pLimit(concurrency) {
139
135
  return generator;
140
136
  }
141
137
 
142
- const defaultInclude = ["**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"];
143
- const defaultExclude = ["**/node_modules/**", "**/dist/**", "**/cypress/**", "**/.{idea,git,cache,output,temp}/**"];
144
- const defaultCoverageExcludes = [
145
- "coverage/**",
146
- "dist/**",
147
- "packages/*/test{,s}/**",
148
- "**/*.d.ts",
149
- "cypress/**",
150
- "test{,s}/**",
151
- "test{,-*}.{js,cjs,mjs,ts,tsx,jsx}",
152
- "**/*{.,-}test.{js,cjs,mjs,ts,tsx,jsx}",
153
- "**/*{.,-}spec.{js,cjs,mjs,ts,tsx,jsx}",
154
- "**/__tests__/**",
155
- "**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress}.config.{js,cjs,mjs,ts}",
156
- "**/.{eslint,mocha,prettier}rc.{js,cjs,yml}"
157
- ];
158
- const coverageConfigDefaults = {
159
- enabled: false,
160
- clean: true,
161
- cleanOnRerun: false,
162
- reportsDirectory: "./coverage",
163
- excludeNodeModules: true,
164
- exclude: defaultCoverageExcludes,
165
- reporter: ["text", "html", "clover"],
166
- allowExternal: false,
167
- extension: [".js", ".cjs", ".mjs", ".ts", ".tsx", ".jsx", ".vue", ".svelte"]
168
- };
169
- const fakeTimersDefaults = {
170
- loopLimit: 1e4,
171
- shouldClearNativeTimers: true,
172
- toFake: [
173
- "setTimeout",
174
- "clearTimeout",
175
- "setInterval",
176
- "clearInterval",
177
- "setImmediate",
178
- "clearImmediate",
179
- "Date"
180
- ]
138
+ const CoverageProviderMap = {
139
+ c8: "@vitest/coverage-c8",
140
+ istanbul: "@vitest/coverage-istanbul"
181
141
  };
182
- const config = {
183
- allowOnly: !process.env.CI,
184
- watch: !process.env.CI,
185
- globals: false,
186
- environment: "node",
187
- threads: true,
188
- clearMocks: false,
189
- restoreMocks: false,
190
- mockReset: false,
191
- include: defaultInclude,
192
- exclude: defaultExclude,
193
- testTimeout: 5e3,
194
- hookTimeout: 1e4,
195
- teardownTimeout: 1e3,
196
- isolate: true,
197
- watchExclude: ["**/node_modules/**", "**/dist/**"],
198
- forceRerunTriggers: [
199
- "**/package.json/**",
200
- "**/vitest.config.*/**",
201
- "**/vite.config.*/**"
202
- ],
203
- update: false,
204
- reporters: [],
205
- silent: false,
206
- api: false,
207
- ui: false,
208
- uiBase: "/__vitest__/",
209
- open: true,
210
- css: {
211
- include: [/\.module\./]
212
- },
213
- coverage: coverageConfigDefaults,
214
- fakeTimers: fakeTimersDefaults,
215
- maxConcurrency: 5,
216
- dangerouslyIgnoreUnhandledErrors: false
217
- };
218
- const configDefaults = Object.freeze(config);
219
-
220
- function resolveC8Options(options, root) {
221
- const resolved = {
222
- ...configDefaults.coverage,
223
- ...options
224
- };
225
- resolved.reporter = toArray(resolved.reporter);
226
- resolved.reportsDirectory = resolve(root, resolved.reportsDirectory);
227
- resolved.tempDirectory = process.env.NODE_V8_COVERAGE || resolve(resolved.reportsDirectory, "tmp");
228
- return resolved;
229
- }
230
- async function cleanCoverage(options, clean = true) {
231
- if (clean && existsSync(options.reportsDirectory))
232
- await promises.rm(options.reportsDirectory, { recursive: true, force: true });
233
- if (!existsSync(options.tempDirectory))
234
- await promises.mkdir(options.tempDirectory, { recursive: true });
142
+ async function resolveCoverageProvider(provider) {
143
+ if (typeof provider === "string") {
144
+ const pkg = CoverageProviderMap[provider];
145
+ if (!pkg)
146
+ throw new Error(`Unknown coverage provider: ${provider}`);
147
+ return await importModule(pkg);
148
+ } else {
149
+ return provider;
150
+ }
235
151
  }
236
- const require = createRequire(import.meta.url);
237
- function takeCoverage() {
238
- const v8 = require("v8");
239
- if (v8.takeCoverage == null)
240
- console.warn("[Vitest] takeCoverage is not available in this NodeJs version.\nCoverage could be incomplete. Update to NodeJs 14.18.");
241
- else
242
- v8.takeCoverage();
152
+ async function getCoverageProvider(options) {
153
+ if ((options == null ? void 0 : options.enabled) && (options == null ? void 0 : options.provider)) {
154
+ const { getProvider } = await resolveCoverageProvider(options.provider);
155
+ return await getProvider();
156
+ }
157
+ return null;
243
158
  }
244
- async function reportCoverage(ctx) {
245
- takeCoverage();
246
- const createReport = require("c8/lib/report");
247
- const report = createReport(ctx.config.coverage);
248
- const sourceMapMeta = {};
249
- await Promise.all(Array.from(ctx.vitenode.fetchCache.entries()).filter((i) => !i[0].includes("/node_modules/")).map(async ([file, { result }]) => {
250
- const map = result.map;
251
- if (!map)
252
- return;
253
- const url = _url.pathToFileURL(file).href;
254
- let code;
255
- try {
256
- code = (await promises.readFile(file)).toString();
257
- } catch {
258
- }
259
- const sources = [url];
260
- sourceMapMeta[url] = {
261
- source: result.code,
262
- map: {
263
- sourcesContent: code ? [code] : void 0,
264
- ...map,
265
- sources
266
- }
267
- };
268
- }));
269
- const offset = 224;
270
- report._getSourceMap = (coverage) => {
271
- const path = _url.pathToFileURL(coverage.url).href;
272
- const data = sourceMapMeta[path];
273
- if (!data)
274
- return {};
275
- return {
276
- sourceMap: {
277
- sourcemap: data.map
278
- },
279
- source: Array(offset).fill(".").join("") + data.source
280
- };
281
- };
282
- await report.run();
283
- if (ctx.config.coverage.enabled) {
284
- if (ctx.config.coverage["100"]) {
285
- ctx.config.coverage.lines = 100;
286
- ctx.config.coverage.functions = 100;
287
- ctx.config.coverage.branches = 100;
288
- ctx.config.coverage.statements = 100;
289
- }
290
- const { checkCoverages } = require("c8/lib/commands/check-coverage");
291
- await checkCoverages(ctx.config.coverage, report);
159
+ async function takeCoverageInsideWorker(options) {
160
+ if (options.enabled && options.provider) {
161
+ const { takeCoverage } = await resolveCoverageProvider(options.provider);
162
+ return await (takeCoverage == null ? void 0 : takeCoverage());
292
163
  }
293
164
  }
294
165
 
@@ -677,4 +548,4 @@ const envPackageNames = {
677
548
  "edge-runtime": "@edge-runtime/vm"
678
549
  };
679
550
 
680
- export { cleanCoverage as a, reportCoverage as b, configDefaults as c, envPackageNames as d, environments as e, envs as f, pLimit as p, resolveC8Options as r, takeCoverage as t };
551
+ export { CoverageProviderMap as C, envPackageNames as a, envs as b, environments as e, getCoverageProvider as g, pLimit as p, takeCoverageInsideWorker as t };
@@ -1,19 +1,20 @@
1
- import { g as globalApis } from './chunk-constants.26dc9f85.mjs';
2
- import { i as index } from './chunk-runtime-hooks.453f8858.mjs';
1
+ import { g as globalApis } from './chunk-constants.d3f8437b.mjs';
2
+ import { i as index } from './chunk-runtime-hooks.4789e99d.mjs';
3
3
  import 'url';
4
- import './chunk-mock-date.bc81a3ac.mjs';
4
+ import './chunk-mock-date.debe9954.mjs';
5
5
  import 'path';
6
+ import './vendor-picocolors.807856aa.mjs';
6
7
  import 'tty';
7
8
  import 'local-pkg';
8
- import './chunk-runtime-chain.98d42d89.mjs';
9
+ import './chunk-runtime-chain.6e363ba2.mjs';
9
10
  import 'util';
10
11
  import 'chai';
11
12
  import './vendor-_commonjsHelpers.4da45ef5.mjs';
12
- import './chunk-runtime-rpc.b50ab560.mjs';
13
+ import './chunk-runtime-rpc.29488183.mjs';
13
14
  import './chunk-utils-global.fa20c2f6.mjs';
14
15
  import './chunk-utils-timers.b48455ed.mjs';
15
16
  import 'fs';
16
- import './chunk-utils-source-map.94107ee8.mjs';
17
+ import './chunk-utils-source-map.2a082ffd.mjs';
17
18
  import './spy.mjs';
18
19
  import 'tinyspy';
19
20
 
@@ -1,68 +1,7 @@
1
1
  import path, { relative as relative$1 } from 'path';
2
- import require$$0 from 'tty';
2
+ import { p as picocolors } from './vendor-picocolors.807856aa.mjs';
3
3
  import { isPackageExists } from 'local-pkg';
4
4
 
5
- var picocolors = {exports: {}};
6
-
7
- let tty = require$$0;
8
-
9
- let isColorSupported =
10
- !("NO_COLOR" in process.env || process.argv.includes("--no-color")) &&
11
- ("FORCE_COLOR" in process.env ||
12
- process.argv.includes("--color") ||
13
- process.platform === "win32" ||
14
- (tty.isatty(1) && process.env.TERM !== "dumb") ||
15
- "CI" in process.env);
16
-
17
- let formatter =
18
- (open, close, replace = open) =>
19
- input => {
20
- let string = "" + input;
21
- let index = string.indexOf(close, open.length);
22
- return ~index
23
- ? open + replaceClose(string, close, replace, index) + close
24
- : open + string + close
25
- };
26
-
27
- let replaceClose = (string, close, replace, index) => {
28
- let start = string.substring(0, index) + replace;
29
- let end = string.substring(index + close.length);
30
- let nextIndex = end.indexOf(close);
31
- return ~nextIndex ? start + replaceClose(end, close, replace, nextIndex) : start + end
32
- };
33
-
34
- let createColors = (enabled = isColorSupported) => ({
35
- isColorSupported: enabled,
36
- reset: enabled ? s => `\x1b[0m${s}\x1b[0m` : String,
37
- bold: enabled ? formatter("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m") : String,
38
- dim: enabled ? formatter("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m") : String,
39
- italic: enabled ? formatter("\x1b[3m", "\x1b[23m") : String,
40
- underline: enabled ? formatter("\x1b[4m", "\x1b[24m") : String,
41
- inverse: enabled ? formatter("\x1b[7m", "\x1b[27m") : String,
42
- hidden: enabled ? formatter("\x1b[8m", "\x1b[28m") : String,
43
- strikethrough: enabled ? formatter("\x1b[9m", "\x1b[29m") : String,
44
- black: enabled ? formatter("\x1b[30m", "\x1b[39m") : String,
45
- red: enabled ? formatter("\x1b[31m", "\x1b[39m") : String,
46
- green: enabled ? formatter("\x1b[32m", "\x1b[39m") : String,
47
- yellow: enabled ? formatter("\x1b[33m", "\x1b[39m") : String,
48
- blue: enabled ? formatter("\x1b[34m", "\x1b[39m") : String,
49
- magenta: enabled ? formatter("\x1b[35m", "\x1b[39m") : String,
50
- cyan: enabled ? formatter("\x1b[36m", "\x1b[39m") : String,
51
- white: enabled ? formatter("\x1b[37m", "\x1b[39m") : String,
52
- gray: enabled ? formatter("\x1b[90m", "\x1b[39m") : String,
53
- bgBlack: enabled ? formatter("\x1b[40m", "\x1b[49m") : String,
54
- bgRed: enabled ? formatter("\x1b[41m", "\x1b[49m") : String,
55
- bgGreen: enabled ? formatter("\x1b[42m", "\x1b[49m") : String,
56
- bgYellow: enabled ? formatter("\x1b[43m", "\x1b[49m") : String,
57
- bgBlue: enabled ? formatter("\x1b[44m", "\x1b[49m") : String,
58
- bgMagenta: enabled ? formatter("\x1b[45m", "\x1b[49m") : String,
59
- bgCyan: enabled ? formatter("\x1b[46m", "\x1b[49m") : String,
60
- bgWhite: enabled ? formatter("\x1b[47m", "\x1b[49m") : String,
61
- });
62
-
63
- picocolors.exports = createColors();
64
- picocolors.exports.createColors = createColors;
65
-
66
5
  function normalizeWindowsPath(input = "") {
67
6
  if (!input.includes("\\")) {
68
7
  return input;
@@ -381,9 +320,9 @@ function deepMerge(target, ...sources) {
381
320
  const source = sources.shift();
382
321
  if (source === void 0)
383
322
  return target;
384
- if (isMergableObject(target) && isMergableObject(source)) {
323
+ if (isMergeableObject(target) && isMergeableObject(source)) {
385
324
  Object.keys(source).forEach((key) => {
386
- if (isMergableObject(source[key])) {
325
+ if (isMergeableObject(source[key])) {
387
326
  if (!target[key])
388
327
  target[key] = {};
389
328
  deepMerge(target[key], source[key]);
@@ -394,7 +333,7 @@ function deepMerge(target, ...sources) {
394
333
  }
395
334
  return deepMerge(target, ...sources);
396
335
  }
397
- function isMergableObject(item) {
336
+ function isMergeableObject(item) {
398
337
  return isPlainObject(item) && !Array.isArray(item);
399
338
  }
400
339
  function assertTypes(value, name, types) {
@@ -507,7 +446,7 @@ async function ensurePackageInstalled(dependency, root) {
507
446
  message: picocolors.exports.reset(`Do you want to install ${picocolors.exports.green(dependency)}?`)
508
447
  });
509
448
  if (install) {
510
- await (await import('./chunk-install-pkg.6c6dc0c2.mjs')).installPackage(dependency, { dev: true });
449
+ await (await import('./chunk-install-pkg.3aa3eae6.mjs')).installPackage(dependency, { dev: true });
511
450
  process.stderr.write(picocolors.exports.yellow(`
512
451
  Package ${dependency} installed, re-run the command to start.
513
452
  `));
@@ -552,4 +491,4 @@ class AggregateErrorPonyfill extends Error {
552
491
  }
553
492
  }
554
493
 
555
- export { AggregateErrorPonyfill as A, isAbsolute as B, relative as C, getTests as D, hasFailedSnapshot as E, getSuites as F, normalize as G, deepMerge as H, toNamespacedPath as I, ensurePackageInstalled as J, stdout as K, extname as L, isWindows as M, mergeSlashes as N, getAllMockableProperties as O, RealDate as R, resetModules as a, getNames as b, assertTypes as c, dirname as d, getFullName as e, notNullish as f, getCallLastIndex as g, deepClone as h, isObject as i, join as j, getType as k, isNode as l, mockDate as m, noop as n, relativePath as o, picocolors as p, isBrowser as q, resetDate as r, slash as s, toArray as t, partitionSuiteChildren as u, shuffle as v, hasTests as w, hasFailed as x, resolve as y, basename as z };
494
+ export { AggregateErrorPonyfill as A, relative as B, getTests as C, hasFailedSnapshot as D, getSuites as E, normalize as F, deepMerge as G, toNamespacedPath as H, ensurePackageInstalled as I, stdout as J, extname as K, isWindows as L, mergeSlashes as M, getAllMockableProperties as N, RealDate as R, resetModules as a, getNames as b, assertTypes as c, dirname as d, getFullName as e, notNullish as f, getCallLastIndex as g, deepClone as h, isObject as i, join as j, getType as k, isNode as l, mockDate as m, noop as n, relativePath as o, isBrowser as p, partitionSuiteChildren as q, resetDate as r, slash as s, toArray as t, shuffle as u, hasTests as v, hasFailed as w, resolve as x, basename as y, isAbsolute as z };
@@ -0,0 +1,80 @@
1
+ import { x as resolve } from './chunk-mock-date.debe9954.mjs';
2
+ import { e as execa } from './vendor-index.fbec8a81.mjs';
3
+ import 'path';
4
+ import './vendor-picocolors.807856aa.mjs';
5
+ import 'tty';
6
+ import 'local-pkg';
7
+ import 'buffer';
8
+ import 'child_process';
9
+ import 'process';
10
+ import './vendor-index.2ae8040a.mjs';
11
+ import './vendor-_commonjsHelpers.4da45ef5.mjs';
12
+ import 'fs';
13
+ import 'stream';
14
+ import 'util';
15
+ import 'url';
16
+ import 'os';
17
+ import './vendor-index.29636037.mjs';
18
+ import 'assert';
19
+ import 'events';
20
+
21
+ class VitestGit {
22
+ constructor(cwd) {
23
+ this.cwd = cwd;
24
+ }
25
+ async resolveFilesWithGitCommand(args) {
26
+ let result;
27
+ try {
28
+ result = await execa("git", args, { cwd: this.root });
29
+ } catch (e) {
30
+ e.message = e.stderr;
31
+ throw e;
32
+ }
33
+ return result.stdout.split("\n").filter((s) => s !== "").map((changedPath) => resolve(this.root, changedPath));
34
+ }
35
+ async findChangedFiles(options) {
36
+ const root = await this.getRoot(this.cwd);
37
+ if (!root)
38
+ return null;
39
+ this.root = root;
40
+ const changedSince = options.changedSince;
41
+ if (typeof changedSince === "string") {
42
+ const [committed, staged2, unstaged2] = await Promise.all([
43
+ this.getFilesSince(changedSince),
44
+ this.getStagedFiles(),
45
+ this.getUnstagedFiles()
46
+ ]);
47
+ return [...committed, ...staged2, ...unstaged2];
48
+ }
49
+ const [staged, unstaged] = await Promise.all([
50
+ this.getStagedFiles(),
51
+ this.getUnstagedFiles()
52
+ ]);
53
+ return [...staged, ...unstaged];
54
+ }
55
+ getFilesSince(hash) {
56
+ return this.resolveFilesWithGitCommand(["diff", "--name-only", `${hash}...HEAD`]);
57
+ }
58
+ getStagedFiles() {
59
+ return this.resolveFilesWithGitCommand(["diff", "--cached", "--name-only"]);
60
+ }
61
+ getUnstagedFiles() {
62
+ return this.resolveFilesWithGitCommand([
63
+ "ls-files",
64
+ "--other",
65
+ "--modified",
66
+ "--exclude-standard"
67
+ ]);
68
+ }
69
+ async getRoot(cwd) {
70
+ const options = ["rev-parse", "--show-cdup"];
71
+ try {
72
+ const result = await execa("git", options, { cwd });
73
+ return resolve(cwd, result.stdout);
74
+ } catch {
75
+ return null;
76
+ }
77
+ }
78
+ }
79
+
80
+ export { VitestGit };
@@ -1,12 +1,13 @@
1
1
  import util$1 from 'util';
2
- import { i as isObject, j as join, d as dirname, g as getCallLastIndex, s as slash, b as getNames, c as assertTypes, p as picocolors, e as getFullName, n as noop } from './chunk-mock-date.bc81a3ac.mjs';
2
+ import { i as isObject, j as join, d as dirname, g as getCallLastIndex, s as slash, b as getNames, c as assertTypes, e as getFullName, n as noop } from './chunk-mock-date.debe9954.mjs';
3
3
  import * as chai$2 from 'chai';
4
4
  import { expect, AssertionError, util } from 'chai';
5
5
  import { c as commonjsGlobal } from './vendor-_commonjsHelpers.4da45ef5.mjs';
6
- import { r as rpc } from './chunk-runtime-rpc.b50ab560.mjs';
6
+ import { r as rpc } from './chunk-runtime-rpc.29488183.mjs';
7
7
  import fs, { promises } from 'fs';
8
- import { a as plugins_1, f as format_1, g as getOriginalPos, b as posToNumber, n as numberToPos, l as lineSplitRE, p as parseStacktrace, u as unifiedDiff, s as stringify, m as matcherUtils } from './chunk-utils-source-map.94107ee8.mjs';
8
+ import { a as plugins_1, f as format_1, g as getOriginalPos, b as posToNumber, n as numberToPos, l as lineSplitRE, p as parseStacktrace, u as unifiedDiff, s as stringify, m as matcherUtils } from './chunk-utils-source-map.2a082ffd.mjs';
9
9
  import { g as getWorkerState } from './chunk-utils-global.fa20c2f6.mjs';
10
+ import { p as picocolors } from './vendor-picocolors.807856aa.mjs';
10
11
  import { isMockFunction } from './spy.mjs';
11
12
  import { s as safeSetTimeout, a as safeClearTimeout } from './chunk-utils-timers.b48455ed.mjs';
12
13