vitest 0.0.76 → 0.0.77
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/dist/cli.js +35 -23
- package/dist/{constants-d4c70610.js → constants-2435fa16.js} +11 -1
- package/dist/entry.js +11 -5
- package/dist/{error-1df12c37.js → error-c9295525.js} +0 -0
- package/dist/{global-784f167d.js → global-38c2f902.js} +4 -4
- package/dist/{index-bf952d9c.js → index-6feda5ef.js} +1 -1
- package/dist/{index-6427e0f2.js → index-9e71c815.js} +0 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +3 -3
- package/dist/middleware-37267df8.js +34 -0
- package/dist/{suite-1bc54c1b.js → suite-95be5909.js} +1 -1
- package/dist/worker.js +2 -2
- package/package.json +9 -37
- package/README.gh.md +0 -105
- package/README.npm.md +0 -9
package/dist/cli.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import require$$2, { EventEmitter } from 'events';
|
|
2
|
-
import { s as stringWidth, a as ansiStyles, b as stripAnsi, c as sliceAnsi, d as c, F as F_POINTER, e as F_DOWN, f as F_LONG_DASH, g as F_DOWN_RIGHT, h as F_DOT, i as F_CHECK, j as F_CROSS, k as cliTruncate, l as F_RIGHT, p as printError } from './error-
|
|
2
|
+
import { s as stringWidth, a as ansiStyles, b as stripAnsi, c as sliceAnsi, d as c, F as F_POINTER, e as F_DOWN, f as F_LONG_DASH, g as F_DOWN_RIGHT, h as F_DOT, i as F_CHECK, j as F_CROSS, k as cliTruncate, l as F_RIGHT, p as printError } from './error-c9295525.js';
|
|
3
3
|
import { performance } from 'perf_hooks';
|
|
4
4
|
import path, { isAbsolute, relative, dirname, basename, resolve } from 'path';
|
|
5
|
-
import { g as getNames, s as slash, a as getTests, b as getSuites,
|
|
5
|
+
import { g as getNames, s as slash, a as getTests, b as getSuites, h as hasFailed } from './utils-9dcc4050.js';
|
|
6
6
|
import process$2 from 'process';
|
|
7
7
|
import require$$0 from 'assert';
|
|
8
8
|
import { promises } from 'fs';
|
|
9
9
|
import { createServer } from 'vite';
|
|
10
|
-
import { d as defaultIncludes, a as defaultExcludes, b as distDir } from './constants-
|
|
10
|
+
import { d as defaultIncludes, a as defaultExcludes, b as defaultPort, c as configFiles, e as distDir } from './constants-2435fa16.js';
|
|
11
11
|
import { MessageChannel } from 'worker_threads';
|
|
12
12
|
import { pathToFileURL } from 'url';
|
|
13
13
|
import Piscina from 'piscina';
|
|
@@ -632,7 +632,7 @@ const cac = (name = "") => new CAC(name);
|
|
|
632
632
|
|
|
633
633
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
634
634
|
|
|
635
|
-
var version = "0.0.
|
|
635
|
+
var version = "0.0.77";
|
|
636
636
|
|
|
637
637
|
const ESC = '\u001B[';
|
|
638
638
|
const OSC = '\u001B]';
|
|
@@ -2127,16 +2127,7 @@ var __spreadValues$1 = (a, b) => {
|
|
|
2127
2127
|
}
|
|
2128
2128
|
return a;
|
|
2129
2129
|
};
|
|
2130
|
-
const configFiles = [
|
|
2131
|
-
"vitest.config.ts",
|
|
2132
|
-
"vitest.config.js",
|
|
2133
|
-
"vitest.config.mjs",
|
|
2134
|
-
"vite.config.ts",
|
|
2135
|
-
"vite.config.js",
|
|
2136
|
-
"vite.config.mjs"
|
|
2137
|
-
];
|
|
2138
2130
|
async function initViteServer(options = {}) {
|
|
2139
|
-
var _a, _b;
|
|
2140
2131
|
const root = resolve(options.root || process.cwd());
|
|
2141
2132
|
process.chdir(root);
|
|
2142
2133
|
if (options.dom)
|
|
@@ -2145,13 +2136,27 @@ async function initViteServer(options = {}) {
|
|
|
2145
2136
|
const resolved = __spreadValues$1({}, options);
|
|
2146
2137
|
resolved.config = configPath;
|
|
2147
2138
|
resolved.root = root;
|
|
2148
|
-
if (options.cliFilters)
|
|
2149
|
-
resolved.cliFilters = toArray(options.cliFilters);
|
|
2150
2139
|
const server = await createServer({
|
|
2151
2140
|
root,
|
|
2152
2141
|
logLevel: "error",
|
|
2153
2142
|
clearScreen: false,
|
|
2154
2143
|
configFile: resolved.config,
|
|
2144
|
+
plugins: [
|
|
2145
|
+
{
|
|
2146
|
+
name: "vitest",
|
|
2147
|
+
configResolved(viteConfig) {
|
|
2148
|
+
resolveConfig(resolved, viteConfig);
|
|
2149
|
+
},
|
|
2150
|
+
async configureServer(server2) {
|
|
2151
|
+
if (resolved.api)
|
|
2152
|
+
server2.middlewares.use((await import('./middleware-37267df8.js')).default());
|
|
2153
|
+
}
|
|
2154
|
+
}
|
|
2155
|
+
],
|
|
2156
|
+
server: {
|
|
2157
|
+
open: options.open,
|
|
2158
|
+
strictPort: true
|
|
2159
|
+
},
|
|
2155
2160
|
optimizeDeps: {
|
|
2156
2161
|
exclude: [
|
|
2157
2162
|
"vitest"
|
|
@@ -2159,7 +2164,16 @@ async function initViteServer(options = {}) {
|
|
|
2159
2164
|
}
|
|
2160
2165
|
});
|
|
2161
2166
|
await server.pluginContainer.buildStart({});
|
|
2162
|
-
|
|
2167
|
+
if (typeof resolved.api === "number")
|
|
2168
|
+
await server.listen(resolved.api);
|
|
2169
|
+
return {
|
|
2170
|
+
server,
|
|
2171
|
+
config: resolved
|
|
2172
|
+
};
|
|
2173
|
+
}
|
|
2174
|
+
function resolveConfig(resolved, viteConfig) {
|
|
2175
|
+
var _a, _b;
|
|
2176
|
+
Object.assign(resolved, viteConfig.test);
|
|
2163
2177
|
resolved.depsInline = ((_a = resolved.deps) == null ? void 0 : _a.inline) || [];
|
|
2164
2178
|
resolved.depsExternal = ((_b = resolved.deps) == null ? void 0 : _b.external) || [];
|
|
2165
2179
|
resolved.environment = resolved.environment || "node";
|
|
@@ -2176,15 +2190,13 @@ async function initViteServer(options = {}) {
|
|
|
2176
2190
|
resolved.maxThreads = parseInt(process.env.VITEST_MAX_THREADS);
|
|
2177
2191
|
if (process.env.VITEST_MIN_THREADS)
|
|
2178
2192
|
resolved.minThreads = parseInt(process.env.VITEST_MIN_THREADS);
|
|
2179
|
-
resolved.setupFiles = Array.from(resolved.setupFiles || []).map((i) => resolve(root, i));
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
config: resolved
|
|
2183
|
-
};
|
|
2193
|
+
resolved.setupFiles = Array.from(resolved.setupFiles || []).map((i) => resolve(resolved.root, i));
|
|
2194
|
+
if (resolved.api === true)
|
|
2195
|
+
resolved.api = defaultPort;
|
|
2184
2196
|
}
|
|
2185
2197
|
|
|
2186
2198
|
async function transformRequest(server, id) {
|
|
2187
|
-
if (id.match(/\.(?:[cm]?[jt]
|
|
2199
|
+
if (id.match(/\.(?:[cm]?[jt]s|json)$/)) {
|
|
2188
2200
|
return await server.transformRequest(id, { ssr: true });
|
|
2189
2201
|
} else {
|
|
2190
2202
|
const result = await server.transformRequest(id);
|
|
@@ -2473,7 +2485,7 @@ var __spreadValues = (a, b) => {
|
|
|
2473
2485
|
};
|
|
2474
2486
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
2475
2487
|
const cli = cac("vitest");
|
|
2476
|
-
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", "watch mode").option("--threads", "enabled threads", { default: true }).option("--silent", "silent").option("--global", "inject apis globally").option("--dom", "mock browser api with happy-dom").option("--environment <env>", "runner environment", {
|
|
2488
|
+
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", "watch mode").option("-o, --open", "open Vitest UI").option("--api", "listen to port and serve API").option("--threads", "enabled threads", { default: true }).option("--silent", "silent").option("--global", "inject apis globally").option("--dom", "mock browser api with happy-dom").option("--environment <env>", "runner environment", {
|
|
2477
2489
|
default: "node"
|
|
2478
2490
|
}).help();
|
|
2479
2491
|
cli.command("run [...filters]").action(run);
|
|
@@ -4,6 +4,16 @@ import { fileURLToPath } from 'url';
|
|
|
4
4
|
const distDir = resolve(fileURLToPath(import.meta.url), "../../dist");
|
|
5
5
|
const defaultIncludes = ["**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"];
|
|
6
6
|
const defaultExcludes = ["**/node_modules/**", "**/dist/**"];
|
|
7
|
+
const defaultPort = 51204;
|
|
8
|
+
const API_PATH = "/__vitest_api__";
|
|
9
|
+
const configFiles = [
|
|
10
|
+
"vitest.config.ts",
|
|
11
|
+
"vitest.config.js",
|
|
12
|
+
"vitest.config.mjs",
|
|
13
|
+
"vite.config.ts",
|
|
14
|
+
"vite.config.js",
|
|
15
|
+
"vite.config.mjs"
|
|
16
|
+
];
|
|
7
17
|
const globalApis = [
|
|
8
18
|
"suite",
|
|
9
19
|
"test",
|
|
@@ -22,4 +32,4 @@ const globalApis = [
|
|
|
22
32
|
"afterEach"
|
|
23
33
|
];
|
|
24
34
|
|
|
25
|
-
export { defaultExcludes as a,
|
|
35
|
+
export { API_PATH as A, defaultExcludes as a, defaultPort as b, configFiles as c, defaultIncludes as d, distDir as e, globalApis as g };
|
package/dist/entry.js
CHANGED
|
@@ -7,10 +7,10 @@ import Subset from 'chai-subset';
|
|
|
7
7
|
import path, { basename } from 'path';
|
|
8
8
|
import { g as getNames, t as toArray, i as interpretOnlyMode, p as partitionSuiteChildren, c as hasTests, h as hasFailed } from './utils-9dcc4050.js';
|
|
9
9
|
import fs from 'fs';
|
|
10
|
-
import { d as c$1, m as generateDiff } from './error-
|
|
10
|
+
import { d as c$1, m as generateDiff } from './error-c9295525.js';
|
|
11
11
|
import { performance } from 'perf_hooks';
|
|
12
|
-
import { b as setHooks, c as createSuiteHooks, e as clearContext, f as defaultSuite, h as context, j as getHooks, k as getFn } from './suite-
|
|
13
|
-
import { n as nanoid } from './index-
|
|
12
|
+
import { b as setHooks, c as createSuiteHooks, e as clearContext, f as defaultSuite, h as context, j as getHooks, k as getFn } from './suite-95be5909.js';
|
|
13
|
+
import { n as nanoid } from './index-9e71c815.js';
|
|
14
14
|
import 'tty';
|
|
15
15
|
import 'source-map';
|
|
16
16
|
|
|
@@ -203,6 +203,7 @@ const OTHER_KEYS = [
|
|
|
203
203
|
"innerWidth",
|
|
204
204
|
"length",
|
|
205
205
|
"location",
|
|
206
|
+
"matchMedia",
|
|
206
207
|
"moveBy",
|
|
207
208
|
"moveTo",
|
|
208
209
|
"name",
|
|
@@ -2934,7 +2935,12 @@ class SnapshotClient {
|
|
|
2934
2935
|
inlineSnapshot: inlineSnapshot == null ? void 0 : inlineSnapshot.trim()
|
|
2935
2936
|
});
|
|
2936
2937
|
if (!pass) {
|
|
2937
|
-
|
|
2938
|
+
try {
|
|
2939
|
+
expect(actual.trim()).equals(expected ? expected.trim() : "");
|
|
2940
|
+
} catch (error) {
|
|
2941
|
+
error.message = `Snapshot \`${key || "unknown"}\` mismatched`;
|
|
2942
|
+
throw error;
|
|
2943
|
+
}
|
|
2938
2944
|
}
|
|
2939
2945
|
}
|
|
2940
2946
|
async saveSnap() {
|
|
@@ -3614,7 +3620,7 @@ async function setupGlobalEnv(config) {
|
|
|
3614
3620
|
setupConsoleLogSpy();
|
|
3615
3621
|
await setupChai();
|
|
3616
3622
|
if (config.global)
|
|
3617
|
-
(await import('./global-
|
|
3623
|
+
(await import('./global-38c2f902.js')).registerApiGlobally();
|
|
3618
3624
|
}
|
|
3619
3625
|
function setupConsoleLogSpy() {
|
|
3620
3626
|
const stdout = new Writable({
|
|
File without changes
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { g as globalApis } from './constants-
|
|
2
|
-
import { i as index } from './index-
|
|
1
|
+
import { g as globalApis } from './constants-2435fa16.js';
|
|
2
|
+
import { i as index } from './index-6feda5ef.js';
|
|
3
3
|
import 'path';
|
|
4
4
|
import 'url';
|
|
5
|
-
import './suite-
|
|
6
|
-
import './index-
|
|
5
|
+
import './suite-95be5909.js';
|
|
6
|
+
import './index-9e71c815.js';
|
|
7
7
|
import 'chai';
|
|
8
8
|
import 'sinon';
|
|
9
9
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { g as getCurrentSuite, w as withTimeout, a as getDefaultHookTimeout, s as suite, t as test, d as describe, i as it } from './suite-
|
|
1
|
+
import { g as getCurrentSuite, w as withTimeout, a as getDefaultHookTimeout, s as suite, t as test, d as describe, i as it } from './suite-95be5909.js';
|
|
2
2
|
import chai, { assert, should, expect } from 'chai';
|
|
3
3
|
import sinon from 'sinon';
|
|
4
4
|
|
|
File without changes
|
package/dist/index.d.ts
CHANGED
|
@@ -397,10 +397,22 @@ interface UserOptions {
|
|
|
397
397
|
* @default false
|
|
398
398
|
*/
|
|
399
399
|
silent?: boolean;
|
|
400
|
+
/**
|
|
401
|
+
* Open Vitest UI
|
|
402
|
+
*/
|
|
403
|
+
open?: boolean;
|
|
400
404
|
/**
|
|
401
405
|
* Path to setup files
|
|
402
406
|
*/
|
|
403
407
|
setupFiles?: string | string[];
|
|
408
|
+
/**
|
|
409
|
+
* Listen to port and serve API
|
|
410
|
+
*
|
|
411
|
+
* When set to try, the default port is 55555
|
|
412
|
+
*
|
|
413
|
+
* @default false
|
|
414
|
+
*/
|
|
415
|
+
api?: boolean | number;
|
|
404
416
|
}
|
|
405
417
|
interface CliOptions extends UserOptions {
|
|
406
418
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { d as describe, i as it, s as suite, t as test } from './suite-
|
|
2
|
-
export { a as afterAll, d as afterEach, b as beforeAll, c as beforeEach, m as mock, s as spy, e as stub } from './index-
|
|
1
|
+
export { d as describe, i as it, s as suite, t as test } from './suite-95be5909.js';
|
|
2
|
+
export { a as afterAll, d as afterEach, b as beforeAll, c as beforeEach, m as mock, s as spy, e as stub } from './index-6feda5ef.js';
|
|
3
3
|
export { assert, default as chai, expect, should } from 'chai';
|
|
4
4
|
export { default as sinon } from 'sinon';
|
|
5
|
-
import './index-
|
|
5
|
+
import './index-9e71c815.js';
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { stringify } from 'flatted';
|
|
2
|
+
import { A as API_PATH } from './constants-2435fa16.js';
|
|
3
|
+
import 'path';
|
|
4
|
+
import 'url';
|
|
5
|
+
|
|
6
|
+
function sendFlatted(res, data) {
|
|
7
|
+
res.setHeader("Content-Type", "application/json");
|
|
8
|
+
res.write(stringify(data));
|
|
9
|
+
res.statusCode = 200;
|
|
10
|
+
res.end();
|
|
11
|
+
}
|
|
12
|
+
function middlewareAPI() {
|
|
13
|
+
return (req, res, next) => {
|
|
14
|
+
var _a;
|
|
15
|
+
if (!((_a = req.url) == null ? void 0 : _a.startsWith(API_PATH)))
|
|
16
|
+
return next();
|
|
17
|
+
const url = req.url.slice(API_PATH.length);
|
|
18
|
+
const ctx = process.__vitest__;
|
|
19
|
+
if (url === "/") {
|
|
20
|
+
return sendFlatted(res, {
|
|
21
|
+
files: ctx.state.filesMap
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
if (url === "/files") {
|
|
25
|
+
return sendFlatted(res, {
|
|
26
|
+
files: Object.keys(ctx.state.filesMap)
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
res.statusCode = 404;
|
|
30
|
+
res.end();
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export { middlewareAPI as default, sendFlatted };
|
package/dist/worker.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { resolve, dirname } from 'path';
|
|
2
|
-
import { n as nanoid } from './index-
|
|
3
|
-
import {
|
|
2
|
+
import { n as nanoid } from './index-9e71c815.js';
|
|
3
|
+
import { e as distDir } from './constants-2435fa16.js';
|
|
4
4
|
import { builtinModules, createRequire } from 'module';
|
|
5
5
|
import { pathToFileURL, fileURLToPath } from 'url';
|
|
6
6
|
import vm from 'vm';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vitest",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.77",
|
|
4
4
|
"description": "A blazing fast unit test framework powered by Vite",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vite",
|
|
@@ -38,22 +38,6 @@
|
|
|
38
38
|
"bin",
|
|
39
39
|
"*.d.ts"
|
|
40
40
|
],
|
|
41
|
-
"scripts": {
|
|
42
|
-
"build": "rimraf dist && rollup -c",
|
|
43
|
-
"coverage": "node bin/vitest.mjs -r test/core --coverage",
|
|
44
|
-
"dev": "rollup -c -w src",
|
|
45
|
-
"docs": "npm -C docs run dev",
|
|
46
|
-
"docs:build": "npm -C docs run build",
|
|
47
|
-
"docs:serve": "npm -C docs run serve",
|
|
48
|
-
"lint": "eslint \"{src,test}/**/*.ts\"",
|
|
49
|
-
"prepublishOnly": "nr build",
|
|
50
|
-
"release": "bumpp --commit --push --tag && esmo scripts/publish.ts",
|
|
51
|
-
"test": "node bin/vitest.mjs -r test/core",
|
|
52
|
-
"test:all": "cross-env CI=true pnpm -r --stream --filter !vitest run test --",
|
|
53
|
-
"test:ci": "cross-env CI=true pnpm -r --stream --filter !vitest --filter !@vitest/test-fails run test --",
|
|
54
|
-
"typecheck": "tsc --noEmit && nr lint",
|
|
55
|
-
"ci": "ni && nr typecheck && nr lint && nr build && nr test:all"
|
|
56
|
-
},
|
|
57
41
|
"dependencies": {
|
|
58
42
|
"@types/chai": "^4.3.0",
|
|
59
43
|
"@types/chai-subset": "^1.3.3",
|
|
@@ -62,6 +46,7 @@
|
|
|
62
46
|
"chai": "^4.3.4",
|
|
63
47
|
"chai-subset": "^1.6.0",
|
|
64
48
|
"fast-glob": "^3.2.7",
|
|
49
|
+
"flatted": "^3.2.4",
|
|
65
50
|
"local-pkg": "^0.4.0",
|
|
66
51
|
"micromatch": "^4.0.4",
|
|
67
52
|
"piscina": "^3.2.0",
|
|
@@ -70,42 +55,24 @@
|
|
|
70
55
|
"source-map": "^0.7.3"
|
|
71
56
|
},
|
|
72
57
|
"devDependencies": {
|
|
73
|
-
"@antfu/eslint-config": "^0.13.1",
|
|
74
|
-
"@antfu/ni": "^0.12.0",
|
|
75
|
-
"@rollup/plugin-alias": "^3.1.8",
|
|
76
|
-
"@rollup/plugin-commonjs": "^21.0.1",
|
|
77
|
-
"@rollup/plugin-json": "^4.1.0",
|
|
78
|
-
"@rollup/plugin-node-resolve": "^13.0.6",
|
|
79
58
|
"@types/diff": "^5.0.1",
|
|
80
59
|
"@types/jsdom": "^16.2.13",
|
|
81
60
|
"@types/micromatch": "^4.0.2",
|
|
82
61
|
"@types/natural-compare": "^1.4.1",
|
|
83
62
|
"@types/node": "^16.11.12",
|
|
84
|
-
"@types/sade": "^1.7.3",
|
|
85
|
-
"bumpp": "^7.1.1",
|
|
86
63
|
"c8": "^7.10.0",
|
|
87
64
|
"cac": "^6.7.12",
|
|
88
65
|
"cli-truncate": "^3.1.0",
|
|
89
|
-
"cross-env": "^7.0.3",
|
|
90
66
|
"diff": "^5.0.0",
|
|
91
|
-
"eslint": "^8.4.1",
|
|
92
|
-
"esno": "^0.12.1",
|
|
93
67
|
"find-up": "^6.2.0",
|
|
94
68
|
"happy-dom": "^2.24.5",
|
|
95
69
|
"jsdom": "^19.0.0",
|
|
96
70
|
"log-update": "^5.0.0",
|
|
97
71
|
"nanoid": "^3.1.30",
|
|
98
72
|
"natural-compare": "^1.4.0",
|
|
99
|
-
"npm-run-all": "^4.1.5",
|
|
100
73
|
"picocolors": "^1.0.0",
|
|
101
74
|
"pretty-format": "^27.4.2",
|
|
102
|
-
"
|
|
103
|
-
"rollup-plugin-dts": "^4.0.1",
|
|
104
|
-
"rollup-plugin-esbuild": "^4.7.2",
|
|
105
|
-
"strip-ansi": "^7.0.1",
|
|
106
|
-
"tsup": "^5.11.1",
|
|
107
|
-
"typescript": "^4.5.3",
|
|
108
|
-
"vite": "^2.7.1"
|
|
75
|
+
"strip-ansi": "^7.0.1"
|
|
109
76
|
},
|
|
110
77
|
"peerDependencies": {
|
|
111
78
|
"c8": "*",
|
|
@@ -126,5 +93,10 @@
|
|
|
126
93
|
},
|
|
127
94
|
"engines": {
|
|
128
95
|
"node": ">=16.0.0"
|
|
96
|
+
},
|
|
97
|
+
"scripts": {
|
|
98
|
+
"build": "rimraf dist && rollup -c",
|
|
99
|
+
"dev": "rollup -c --watch src",
|
|
100
|
+
"typecheck": "tsc --noEmit"
|
|
129
101
|
}
|
|
130
|
-
}
|
|
102
|
+
}
|
package/README.gh.md
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
<p align="center">
|
|
2
|
-
<img src="https://user-images.githubusercontent.com/11247099/145112184-a9ff6727-661c-439d-9ada-963124a281f7.png" height="200">
|
|
3
|
-
</p>
|
|
4
|
-
|
|
5
|
-
<h1 align="center">
|
|
6
|
-
Vitest
|
|
7
|
-
</h1>
|
|
8
|
-
<p align="center">
|
|
9
|
-
A blazing fast unit test framework powered by Vite.
|
|
10
|
-
<p>
|
|
11
|
-
<p align="center">
|
|
12
|
-
<a href="https://www.npmjs.com/package/vitest"><img src="https://img.shields.io/npm/v/vitest?color=a1b858&label="></a>
|
|
13
|
-
<p>
|
|
14
|
-
<h2 align="center">
|
|
15
|
-
<a href="https://preview.vitest.dev">Open the Docs</a>
|
|
16
|
-
</h2>
|
|
17
|
-
<h3 align="center">
|
|
18
|
-
<a href=https://discord.com/invite/2zYZNngd7y"><i>Get involved!</i></a>
|
|
19
|
-
</h3>
|
|
20
|
-
<br>
|
|
21
|
-
<br>
|
|
22
|
-
|
|
23
|
-
> 💖 **This project is currently in closed beta exclusively for Sponsors.**<br>
|
|
24
|
-
> Become a Sponsor of [@patak-dev](https://github.com/sponsors/patak-dev) or [@antfu](https://github.com/sponsors/antfu) to access the source code and issues tracker.
|
|
25
|
-
|
|
26
|
-
> ⚠️ **DISCLAIMER**: Vitest is still in development and not stable yet. It's not recommended to use it in production.
|
|
27
|
-
|
|
28
|
-
> Vitest requires Vite v2.7 and Node v16
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
Switch to Vitest by following the [Getting Started Guide](https://preview.vitest.dev/guide) or learn [why we are building a new test runner](https://preview.vitest.dev/guide).
|
|
32
|
-
|
|
33
|
-
## Features
|
|
34
|
-
|
|
35
|
-
- [Vite](https://vitejs.dev/)'s config, transformers, resolvers, and plugins. Use the same setup from your app!
|
|
36
|
-
- [Jest Snapshot](https://jestjs.io/docs/snapshot-testing)
|
|
37
|
-
- [Chai](https://www.chaijs.com/) built-in for assertions, with [Jest expect](https://jestjs.io/docs/expect) compatible APIs.
|
|
38
|
-
- [Smart & instant watch mode](#watch-mode), like HMR for tests!
|
|
39
|
-
- [Native code coverage](#coverage) via [c8](https://github.com/bcoe/c8)
|
|
40
|
-
- [Sinon](https://sinonjs.org/) built-in for mocking, stubbing, and spies.
|
|
41
|
-
- [JSDOM](https://github.com/jsdom/jsdom) and [happy-dom](https://github.com/capricorn86/happy-dom) for DOM and browser API mocking
|
|
42
|
-
- Components testing ([Vue](./test/vue), [React](./test/react), [Lit](./test/lit), [Vitesse](./test/vitesse))
|
|
43
|
-
- Workers multi-threading via [Piscina](https://github.com/piscinajs/piscina)
|
|
44
|
-
- ESM first, top level await
|
|
45
|
-
- Out-of-box TypeScript / JSX support
|
|
46
|
-
- Filtering, timeouts, concurrent for suite and tests
|
|
47
|
-
|
|
48
|
-
```ts
|
|
49
|
-
import { it, describe, expect, assert } from 'vitest'
|
|
50
|
-
|
|
51
|
-
describe('suite name', () => {
|
|
52
|
-
it('foo', () => {
|
|
53
|
-
expect(1 + 1).toEqual(2)
|
|
54
|
-
expect(true).to.be.true
|
|
55
|
-
})
|
|
56
|
-
|
|
57
|
-
it('bar', () => {
|
|
58
|
-
assert.equal(Math.sqrt(4), 2)
|
|
59
|
-
})
|
|
60
|
-
|
|
61
|
-
it('snapshot', () => {
|
|
62
|
-
expect({ foo: 'bar' }).toMatchSnapshot()
|
|
63
|
-
})
|
|
64
|
-
})
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
```bash
|
|
68
|
-
$ npx vitest
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
## Examples
|
|
72
|
-
|
|
73
|
-
- [Unit Testing](./test/core)
|
|
74
|
-
- [Vue Component Testing](./test/vue)
|
|
75
|
-
- [React Component Testing](./test/react)
|
|
76
|
-
- [Lit Component Testing](./test/lit)
|
|
77
|
-
- [Vitesse Component Testing](./test/vitesse)
|
|
78
|
-
|
|
79
|
-
## Projects using Vitest
|
|
80
|
-
|
|
81
|
-
- [unocss](https://github.com/antfu/unocss)
|
|
82
|
-
- [unplugin-auto-import](https://github.com/antfu/unplugin-auto-import)
|
|
83
|
-
- [unplugin-vue-components](https://github.com/antfu/unplugin-vue-components)
|
|
84
|
-
- [vitesse-lite](https://github.com/antfu/vitesse-lite)
|
|
85
|
-
|
|
86
|
-
## Sponsors
|
|
87
|
-
|
|
88
|
-
<p align="center">
|
|
89
|
-
<a href="https://cdn.jsdelivr.net/gh/antfu/static/sponsors.svg">
|
|
90
|
-
<img src='https://cdn.jsdelivr.net/gh/antfu/static/sponsors.svg'/>
|
|
91
|
-
</a>
|
|
92
|
-
</p>
|
|
93
|
-
|
|
94
|
-
## Credits
|
|
95
|
-
|
|
96
|
-
Thanks to:
|
|
97
|
-
|
|
98
|
-
- [@patak-dev](https://github.com/patak-dev) for the awesome package name!
|
|
99
|
-
- [The Vite team](https://github.com/vitejs/vite) for brainstorming the initial idea.
|
|
100
|
-
- [@pi0](https://github.com/pi0) for the idea and implementation of using Vite to transform and bundle the server code.
|
|
101
|
-
- [@lukeed](https://github.com/lukeed) for the work on [uvu](https://github.com/lukeed/uvu) where we are inspired a lot from.
|
|
102
|
-
|
|
103
|
-
## License
|
|
104
|
-
|
|
105
|
-
[MIT](./LICENSE) License © 2021 [Anthony Fu](https://github.com/antfu)
|
package/README.npm.md
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
# vitest
|
|
2
|
-
|
|
3
|
-
[](https://www.npmjs.com/package/vitest)
|
|
4
|
-
|
|
5
|
-
A blazing fast unit test framework powered by Vite.
|
|
6
|
-
|
|
7
|
-
> **This project is currently in closed beta exclusively for Sponsors.**<br>
|
|
8
|
-
> Become a Sponsor of [@patak-dev](https://github.com/sponsors/patak-dev) or [@antfu](https://github.com/sponsors/antfu) to access the source code and issues tracker.
|
|
9
|
-
> Learn more at [vitest.dev](https://vitest.dev)
|