vitest 0.0.10 → 0.0.11
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/reporters/default.d.ts +1 -1
- package/dist/reporters/default.js +39 -20
- package/dist/run.js +15 -8
- package/dist/types.d.ts +2 -0
- package/package.json +11 -10
|
@@ -5,13 +5,13 @@ export declare class DefaultReporter implements Reporter {
|
|
|
5
5
|
end: number;
|
|
6
6
|
onStart(): void;
|
|
7
7
|
onCollected(): void;
|
|
8
|
-
onFinished({ files }: RunnerContext): void;
|
|
9
8
|
onSuiteBegin(suite: Suite): void;
|
|
10
9
|
onSuiteEnd(suite: Suite): void;
|
|
11
10
|
onFileBegin(file: File): void;
|
|
12
11
|
onFileEnd(): void;
|
|
13
12
|
onTaskBegin(task: Task): void;
|
|
14
13
|
onTaskEnd(task: Task): void;
|
|
14
|
+
onFinished({ files }: RunnerContext): void;
|
|
15
15
|
private getIndent;
|
|
16
16
|
private log;
|
|
17
17
|
private error;
|
|
@@ -3,6 +3,8 @@ import { performance } from 'perf_hooks';
|
|
|
3
3
|
import c from 'picocolors';
|
|
4
4
|
import ora from 'ora';
|
|
5
5
|
const DOT = '· ';
|
|
6
|
+
const CHECK = '✔ ';
|
|
7
|
+
const CROSS = '⤫ ';
|
|
6
8
|
export class DefaultReporter {
|
|
7
9
|
constructor() {
|
|
8
10
|
this.indent = 0;
|
|
@@ -15,23 +17,6 @@ export class DefaultReporter {
|
|
|
15
17
|
onCollected() {
|
|
16
18
|
this.start = performance.now();
|
|
17
19
|
}
|
|
18
|
-
onFinished({ files }) {
|
|
19
|
-
this.end = performance.now();
|
|
20
|
-
const tasks = files.reduce((acc, file) => acc.concat(file.suites.flatMap(i => i.tasks)), []);
|
|
21
|
-
const passed = tasks.filter(i => i.status === 'pass');
|
|
22
|
-
const failed = tasks.filter(i => i.status === 'fail');
|
|
23
|
-
const skipped = tasks.filter(i => i.status === 'skip');
|
|
24
|
-
const todo = tasks.filter(i => i.status === 'todo');
|
|
25
|
-
this.indent = 0;
|
|
26
|
-
this.log(c.green(`Passed ${passed.length} / ${tasks.length}`));
|
|
27
|
-
if (skipped.length)
|
|
28
|
-
this.log(c.yellow(`Skipped ${skipped.length}`));
|
|
29
|
-
if (todo.length)
|
|
30
|
-
this.log(c.dim(`Todo ${todo.length}`));
|
|
31
|
-
if (failed.length)
|
|
32
|
-
this.log(c.red(`Failed ${failed.length} / ${tasks.length}`));
|
|
33
|
-
this.log(`Time ${(this.end - this.start).toFixed(2)}ms`);
|
|
34
|
-
}
|
|
35
20
|
onSuiteBegin(suite) {
|
|
36
21
|
if (suite.name) {
|
|
37
22
|
this.indent += 1;
|
|
@@ -64,7 +49,7 @@ export class DefaultReporter {
|
|
|
64
49
|
// @ts-expect-error
|
|
65
50
|
(_a = task.__ora) === null || _a === void 0 ? void 0 : _a.stop();
|
|
66
51
|
if (task.status === 'pass') {
|
|
67
|
-
this.log(`${c.green(
|
|
52
|
+
this.log(`${c.green(CHECK + task.name)}`);
|
|
68
53
|
}
|
|
69
54
|
else if (task.status === 'skip') {
|
|
70
55
|
this.log(c.dim(c.yellow(`${DOT + task.name} (skipped)`)));
|
|
@@ -73,12 +58,46 @@ export class DefaultReporter {
|
|
|
73
58
|
this.log(c.dim(`${DOT + task.name} (todo)`));
|
|
74
59
|
}
|
|
75
60
|
else {
|
|
76
|
-
this.error(`${c.red(
|
|
77
|
-
this.error(String(task.error), 1);
|
|
61
|
+
this.error(`${c.red(`${CROSS}${task.name}`)}`);
|
|
78
62
|
process.exitCode = 1;
|
|
79
63
|
}
|
|
80
64
|
this.indent -= 1;
|
|
81
65
|
}
|
|
66
|
+
onFinished({ files }) {
|
|
67
|
+
this.end = performance.now();
|
|
68
|
+
const failedFiles = files.filter(i => i.error);
|
|
69
|
+
const tasks = files.reduce((acc, file) => acc.concat(file.suites.flatMap(i => i.tasks)), []);
|
|
70
|
+
const passed = tasks.filter(i => i.status === 'pass');
|
|
71
|
+
const failed = tasks.filter(i => i.status === 'fail');
|
|
72
|
+
const skipped = tasks.filter(i => i.status === 'skip');
|
|
73
|
+
const todo = tasks.filter(i => i.status === 'todo');
|
|
74
|
+
this.indent = 0;
|
|
75
|
+
if (failedFiles.length) {
|
|
76
|
+
this.error(c.bold(`\nFailed to parse ${failedFiles.length} files:`));
|
|
77
|
+
failedFiles.forEach((i) => {
|
|
78
|
+
this.error(`\n- ${i.filepath}`);
|
|
79
|
+
console.error(i.error || 'Unknown error');
|
|
80
|
+
this.log();
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
if (failed.length) {
|
|
84
|
+
this.error(c.bold(`\nFailed Tests (${failed.length})`));
|
|
85
|
+
failed.forEach((task) => {
|
|
86
|
+
var _a;
|
|
87
|
+
this.error(`\n${CROSS + c.inverse(c.red(' FAIL '))} ${[task.suite.name, task.name].filter(Boolean).join(' > ')} ${c.gray(`${(_a = task.file) === null || _a === void 0 ? void 0 : _a.filepath}`)}`);
|
|
88
|
+
console.error(task.error || 'Unknown error');
|
|
89
|
+
this.log();
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
this.log(c.green(`Passed ${passed.length} / ${tasks.length}`));
|
|
93
|
+
if (failed.length)
|
|
94
|
+
this.log(c.red(`Failed ${failed.length} / ${tasks.length}`));
|
|
95
|
+
if (skipped.length)
|
|
96
|
+
this.log(c.yellow(`Skipped ${skipped.length}`));
|
|
97
|
+
if (todo.length)
|
|
98
|
+
this.log(c.dim(`Todo ${todo.length}`));
|
|
99
|
+
this.log(`Time ${(this.end - this.start).toFixed(2)}ms`);
|
|
100
|
+
}
|
|
82
101
|
getIndent(offest = 0) {
|
|
83
102
|
return ' '.repeat((this.indent + offest) * 2);
|
|
84
103
|
}
|
package/dist/run.js
CHANGED
|
@@ -34,19 +34,26 @@ export async function runTask(task, ctx) {
|
|
|
34
34
|
export async function collectFiles(files) {
|
|
35
35
|
const result = [];
|
|
36
36
|
for (const filepath of files) {
|
|
37
|
-
clearContext();
|
|
38
|
-
await import(filepath);
|
|
39
|
-
const collectors = [defaultSuite, ...context.suites];
|
|
40
|
-
const suites = [];
|
|
41
37
|
const file = {
|
|
42
38
|
filepath,
|
|
43
39
|
suites: [],
|
|
40
|
+
collected: false,
|
|
44
41
|
};
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
42
|
+
clearContext();
|
|
43
|
+
try {
|
|
44
|
+
await import(filepath);
|
|
45
|
+
const collectors = [defaultSuite, ...context.suites];
|
|
46
|
+
for (const c of collectors) {
|
|
47
|
+
context.currentSuite = c;
|
|
48
|
+
file.suites.push(await c.collect(file));
|
|
49
|
+
}
|
|
50
|
+
file.collected = true;
|
|
51
|
+
}
|
|
52
|
+
catch (e) {
|
|
53
|
+
file.error = e;
|
|
54
|
+
file.collected = false;
|
|
55
|
+
process.exitCode = 1;
|
|
48
56
|
}
|
|
49
|
-
file.suites = suites;
|
|
50
57
|
result.push(file);
|
|
51
58
|
}
|
|
52
59
|
return result;
|
package/dist/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vitest",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.11",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "",
|
|
6
6
|
"keywords": [],
|
|
@@ -32,6 +32,15 @@
|
|
|
32
32
|
"bin": {
|
|
33
33
|
"vitest": "./bin/vitest.mjs"
|
|
34
34
|
},
|
|
35
|
+
"scripts": {
|
|
36
|
+
"build": "tsc",
|
|
37
|
+
"watch": "tsc --watch",
|
|
38
|
+
"lint": "eslint \"{src,test}/**/*.ts\"",
|
|
39
|
+
"prepublishOnly": "nr build",
|
|
40
|
+
"release": "bumpp --commit --push --tag && pnpm publish",
|
|
41
|
+
"test": "node bin/vitest.mjs --dev",
|
|
42
|
+
"test:update": "nr test -u"
|
|
43
|
+
},
|
|
35
44
|
"devDependencies": {
|
|
36
45
|
"@antfu/eslint-config": "^0.11.1",
|
|
37
46
|
"@antfu/ni": "^0.11.0",
|
|
@@ -59,13 +68,5 @@
|
|
|
59
68
|
"sinon": "^12.0.1",
|
|
60
69
|
"sinon-chai": "^3.7.0",
|
|
61
70
|
"vite-node": "^0.1.10"
|
|
62
|
-
},
|
|
63
|
-
"scripts": {
|
|
64
|
-
"build": "tsc",
|
|
65
|
-
"watch": "tsc --watch",
|
|
66
|
-
"lint": "eslint \"{src,test}/**/*.ts\"",
|
|
67
|
-
"release": "bumpp --commit --push --tag && pnpm publish",
|
|
68
|
-
"test": "node bin/vitest.mjs --dev",
|
|
69
|
-
"test:update": "nr test -u"
|
|
70
71
|
}
|
|
71
|
-
}
|
|
72
|
+
}
|