vitest 0.8.2 → 0.8.5

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 (41) hide show
  1. package/dist/chunk-api-setup.da2f55ae.js +4442 -0
  2. package/dist/chunk-constants.76cf224a.js +31 -0
  3. package/dist/chunk-defaults.e85b72aa.js +148 -0
  4. package/dist/chunk-install-pkg.7dd40977.js +0 -1
  5. package/dist/chunk-integrations-globals.3713535d.js +24 -0
  6. package/dist/chunk-magic-string.d5e0e473.js +0 -1
  7. package/dist/chunk-runtime-chain.c86f1eb0.js +7131 -0
  8. package/dist/chunk-runtime-mocker.7cc59bee.js +258 -0
  9. package/dist/chunk-runtime-rpc.5263102e.js +8 -0
  10. package/dist/chunk-utils-base.aff0a195.js +408 -0
  11. package/dist/chunk-utils-global.7bcfa03c.js +0 -1
  12. package/dist/chunk-utils-timers.5657f2a4.js +4655 -0
  13. package/dist/chunk-vite-node-externalize.e472da7d.js +13611 -0
  14. package/dist/chunk-vite-node-utils.a6890356.js +9152 -0
  15. package/dist/cli.js +7 -8
  16. package/dist/config.cjs +3 -2
  17. package/dist/config.d.ts +26 -2
  18. package/dist/config.js +3 -2
  19. package/dist/entry.js +83 -52
  20. package/dist/index.d.ts +32 -9
  21. package/dist/index.js +5 -6
  22. package/dist/node.d.ts +20 -4
  23. package/dist/node.js +7 -8
  24. package/dist/spy.js +102 -0
  25. package/dist/vendor-_commonjsHelpers.34b404ce.js +0 -1
  26. package/dist/vendor-index.87b2fc14.js +0 -1
  27. package/dist/vendor-index.ee829ed6.js +0 -1
  28. package/dist/worker.js +5 -6
  29. package/package.json +17 -17
  30. package/dist/chunk-api-setup.f537ec22.js +0 -4443
  31. package/dist/chunk-constants.6062c404.js +0 -32
  32. package/dist/chunk-defaults.e5535971.js +0 -148
  33. package/dist/chunk-integrations-globals.1039302d.js +0 -25
  34. package/dist/chunk-runtime-chain.f873402e.js +0 -7068
  35. package/dist/chunk-runtime-rpc.e8aa1ebe.js +0 -9
  36. package/dist/chunk-utils-base.8408f73a.js +0 -409
  37. package/dist/chunk-utils-path.02d3f287.js +0 -267
  38. package/dist/chunk-utils-timers.7bdeea22.js +0 -4653
  39. package/dist/chunk-vite-node-externalize.a2ee7060.js +0 -13470
  40. package/dist/chunk-vite-node-utils.386c09c4.js +0 -9153
  41. package/dist/jest-mock.js +0 -100
@@ -0,0 +1,31 @@
1
+ import { fileURLToPath } from 'url';
2
+ import { u as resolve } from './chunk-utils-base.aff0a195.js';
3
+
4
+ const distDir = resolve(fileURLToPath(import.meta.url), "../../dist");
5
+ const defaultPort = 51204;
6
+ const API_PATH = "/__vitest_api__";
7
+ const configFiles = [
8
+ "vitest.config.ts",
9
+ "vitest.config.js",
10
+ "vitest.config.mjs",
11
+ "vite.config.ts",
12
+ "vite.config.js",
13
+ "vite.config.mjs"
14
+ ];
15
+ const globalApis = [
16
+ "suite",
17
+ "test",
18
+ "describe",
19
+ "it",
20
+ "chai",
21
+ "expect",
22
+ "assert",
23
+ "vitest",
24
+ "vi",
25
+ "beforeAll",
26
+ "afterAll",
27
+ "beforeEach",
28
+ "afterEach"
29
+ ];
30
+
31
+ export { API_PATH as A, defaultPort as a, configFiles as c, distDir as d, globalApis as g };
@@ -0,0 +1,148 @@
1
+ import { existsSync, promises } from 'fs';
2
+ import { createRequire } from 'module';
3
+ import { pathToFileURL } from 'url';
4
+ import { t as toArray, u as resolve } from './chunk-utils-base.aff0a195.js';
5
+
6
+ const defaultInclude = ["**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"];
7
+ const defaultExclude = ["**/node_modules/**", "**/dist/**", "**/cypress/**", "**/.{idea,git,cache,output,temp}/**"];
8
+ const defaultCoverageExcludes = [
9
+ "coverage/**",
10
+ "packages/*/test{,s}/**",
11
+ "**/*.d.ts",
12
+ "cypress/**",
13
+ "test{,s}/**",
14
+ "test{,-*}.{js,cjs,mjs,ts,tsx,jsx}",
15
+ "**/*{.,-}test.{js,cjs,mjs,ts,tsx,jsx}",
16
+ "**/__tests__/**",
17
+ "**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc}.config.{js,cjs,mjs,ts}",
18
+ "**/.{eslint,mocha,prettier}rc.{js,cjs,yml}"
19
+ ];
20
+ const coverageConfigDefaults = {
21
+ enabled: false,
22
+ clean: true,
23
+ cleanOnRerun: false,
24
+ reportsDirectory: "./coverage",
25
+ excludeNodeModules: true,
26
+ exclude: defaultCoverageExcludes,
27
+ reporter: ["text", "html"],
28
+ allowExternal: false,
29
+ extension: [".js", ".cjs", ".mjs", ".ts", ".tsx", ".jsx", ".vue", ".svelte"]
30
+ };
31
+ const config = {
32
+ allowOnly: !process.env.CI,
33
+ watch: !process.env.CI,
34
+ globals: false,
35
+ environment: "node",
36
+ threads: true,
37
+ clearMocks: false,
38
+ restoreMocks: false,
39
+ mockReset: false,
40
+ include: defaultInclude,
41
+ exclude: defaultExclude,
42
+ testTimeout: 5e3,
43
+ hookTimeout: 1e4,
44
+ isolate: true,
45
+ watchIgnore: [/\/node_modules\//, /\/dist\//],
46
+ update: false,
47
+ reporters: [],
48
+ silent: false,
49
+ api: false,
50
+ ui: false,
51
+ uiBase: "/__vitest__/",
52
+ open: true,
53
+ coverage: coverageConfigDefaults
54
+ };
55
+ const configDefaults = Object.freeze(config);
56
+
57
+ var __defProp = Object.defineProperty;
58
+ var __defProps = Object.defineProperties;
59
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
60
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
61
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
62
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
63
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
64
+ var __spreadValues = (a, b) => {
65
+ for (var prop in b || (b = {}))
66
+ if (__hasOwnProp.call(b, prop))
67
+ __defNormalProp(a, prop, b[prop]);
68
+ if (__getOwnPropSymbols)
69
+ for (var prop of __getOwnPropSymbols(b)) {
70
+ if (__propIsEnum.call(b, prop))
71
+ __defNormalProp(a, prop, b[prop]);
72
+ }
73
+ return a;
74
+ };
75
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
76
+ function resolveC8Options(options, root) {
77
+ const resolved = __spreadValues(__spreadValues({}, configDefaults.coverage), options);
78
+ resolved.reporter = toArray(resolved.reporter);
79
+ resolved.reportsDirectory = resolve(root, resolved.reportsDirectory);
80
+ resolved.tempDirectory = process.env.NODE_V8_COVERAGE || resolve(resolved.reportsDirectory, "tmp");
81
+ return resolved;
82
+ }
83
+ async function cleanCoverage(options, clean = true) {
84
+ if (clean && existsSync(options.reportsDirectory))
85
+ await promises.rm(options.reportsDirectory, { recursive: true, force: true });
86
+ if (!existsSync(options.tempDirectory))
87
+ await promises.mkdir(options.tempDirectory, { recursive: true });
88
+ }
89
+ const require2 = createRequire(import.meta.url);
90
+ function takeCoverage() {
91
+ const v8 = require2("v8");
92
+ if (v8.takeCoverage == null)
93
+ console.warn("[Vitest] takeCoverage is not available in this NodeJs version.\nCoverage could be incomplete. Update to NodeJs 14.18.");
94
+ else
95
+ v8.takeCoverage();
96
+ }
97
+ async function reportCoverage(ctx) {
98
+ takeCoverage();
99
+ const createReport = require2("c8/lib/report");
100
+ const report = createReport(ctx.config.coverage);
101
+ const sourceMapMeta = {};
102
+ await Promise.all(Array.from(ctx.vitenode.fetchCache.entries()).filter((i) => !i[0].includes("/node_modules/")).map(async ([file, { result }]) => {
103
+ const map = result.map;
104
+ if (!map)
105
+ return;
106
+ const url = pathToFileURL(file).href;
107
+ let code;
108
+ try {
109
+ code = (await promises.readFile(file)).toString();
110
+ } catch {
111
+ }
112
+ const sources = [url];
113
+ sourceMapMeta[url] = {
114
+ source: result.code,
115
+ map: __spreadProps(__spreadValues({
116
+ sourcesContent: code ? [code] : void 0
117
+ }, map), {
118
+ sources
119
+ })
120
+ };
121
+ }));
122
+ const offset = 203;
123
+ report._getSourceMap = (coverage) => {
124
+ const path = pathToFileURL(coverage.url).href;
125
+ const data = sourceMapMeta[path];
126
+ if (!data)
127
+ return {};
128
+ return {
129
+ sourceMap: {
130
+ sourcemap: data.map
131
+ },
132
+ source: Array(offset).fill(".").join("") + data.source
133
+ };
134
+ };
135
+ await report.run();
136
+ if (ctx.config.coverage.enabled) {
137
+ if (ctx.config.coverage["100"]) {
138
+ ctx.config.coverage.lines = 100;
139
+ ctx.config.coverage.functions = 100;
140
+ ctx.config.coverage.branches = 100;
141
+ ctx.config.coverage.statements = 100;
142
+ }
143
+ const { checkCoverages } = require2("c8/lib/commands/check-coverage");
144
+ await checkCoverages(ctx.config.coverage, report);
145
+ }
146
+ }
147
+
148
+ export { cleanCoverage as a, reportCoverage as b, configDefaults as c, resolveC8Options as r, takeCoverage as t };