vitest 0.0.18 → 0.0.19
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/index.d.ts +1 -0
- package/dist/integrations/chai/jest-expect.js +3 -0
- package/dist/reporters/default.js +12 -1
- package/dist/run.d.ts +2 -1
- package/dist/run.js +43 -13
- package/dist/types.d.ts +8 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -71,8 +71,10 @@ export class DefaultReporter {
|
|
|
71
71
|
await this.listrPromise;
|
|
72
72
|
this.log();
|
|
73
73
|
this.end = performance.now();
|
|
74
|
-
const
|
|
74
|
+
const suites = files.reduce((acc, file) => acc.concat(file.suites), []);
|
|
75
75
|
const tasks = files.reduce((acc, file) => acc.concat(file.suites.flatMap(i => i.tasks)), []);
|
|
76
|
+
const failedFiles = files.filter(i => i.error);
|
|
77
|
+
const failedSuites = suites.filter(i => i.error);
|
|
76
78
|
const runable = tasks.filter(i => i.state === 'pass' || i.state === 'fail');
|
|
77
79
|
const passed = tasks.filter(i => i.state === 'pass');
|
|
78
80
|
const failed = tasks.filter(i => i.state === 'fail');
|
|
@@ -87,6 +89,15 @@ export class DefaultReporter {
|
|
|
87
89
|
this.log();
|
|
88
90
|
});
|
|
89
91
|
}
|
|
92
|
+
if (failedSuites.length) {
|
|
93
|
+
this.error(c.bold(`\nFailed to run ${failedSuites.length} suites:`));
|
|
94
|
+
failedSuites.forEach((i) => {
|
|
95
|
+
var _a;
|
|
96
|
+
this.error(`\n- ${(_a = i.file) === null || _a === void 0 ? void 0 : _a.filepath} > ${i.name}`);
|
|
97
|
+
console.error(i.error || 'Unknown error');
|
|
98
|
+
this.log();
|
|
99
|
+
});
|
|
100
|
+
}
|
|
90
101
|
if (failed.length) {
|
|
91
102
|
this.error(c.bold(`\nFailed Tests (${failed.length})`));
|
|
92
103
|
failed.forEach((task) => {
|
package/dist/run.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { File, Config, Task, RunnerContext } from './types';
|
|
1
|
+
import { File, Config, Task, RunnerContext, Suite } from './types';
|
|
2
2
|
export declare function runTask(task: Task, ctx: RunnerContext): Promise<void>;
|
|
3
3
|
export declare function collectFiles(paths: string[]): Promise<File[]>;
|
|
4
|
+
export declare function runSite(suite: Suite, ctx: RunnerContext): Promise<void>;
|
|
4
5
|
export declare function runFile(file: File, ctx: RunnerContext): Promise<void>;
|
|
5
6
|
export declare function run(config: Config): Promise<void>;
|
package/dist/run.js
CHANGED
|
@@ -14,16 +14,24 @@ export async function runTask(task, ctx) {
|
|
|
14
14
|
(_a = getSnapshotManager()) === null || _a === void 0 ? void 0 : _a.setTask(task);
|
|
15
15
|
await ((_b = reporter.onTaskBegin) === null || _b === void 0 ? void 0 : _b.call(reporter, task, ctx));
|
|
16
16
|
if (task.mode === 'run') {
|
|
17
|
-
await callHook(task.suite, 'afterEach', [task, task.suite]);
|
|
18
17
|
try {
|
|
18
|
+
await callHook(task.suite, 'beforeEach', [task, task.suite]);
|
|
19
19
|
await task.fn();
|
|
20
20
|
task.state = 'pass';
|
|
21
21
|
}
|
|
22
22
|
catch (e) {
|
|
23
23
|
task.state = 'fail';
|
|
24
24
|
task.error = e;
|
|
25
|
+
process.exitCode = 1;
|
|
26
|
+
}
|
|
27
|
+
try {
|
|
28
|
+
await callHook(task.suite, 'afterEach', [task, task.suite]);
|
|
29
|
+
}
|
|
30
|
+
catch (e) {
|
|
31
|
+
task.state = 'fail';
|
|
32
|
+
task.error = e;
|
|
33
|
+
process.exitCode = 1;
|
|
25
34
|
}
|
|
26
|
-
await callHook(task.suite, 'afterEach', [task, task.suite]);
|
|
27
35
|
}
|
|
28
36
|
await ((_c = reporter.onTaskEnd) === null || _c === void 0 ? void 0 : _c.call(reporter, task, ctx));
|
|
29
37
|
}
|
|
@@ -75,6 +83,32 @@ function interpretOnlyMode(items) {
|
|
|
75
83
|
});
|
|
76
84
|
}
|
|
77
85
|
}
|
|
86
|
+
export async function runSite(suite, ctx) {
|
|
87
|
+
var _a, _b;
|
|
88
|
+
const { reporter } = ctx;
|
|
89
|
+
await ((_a = reporter.onSuiteBegin) === null || _a === void 0 ? void 0 : _a.call(reporter, suite, ctx));
|
|
90
|
+
if (suite.mode === 'skip') {
|
|
91
|
+
suite.status = 'skip';
|
|
92
|
+
}
|
|
93
|
+
else if (suite.mode === 'todo') {
|
|
94
|
+
suite.status = 'todo';
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
try {
|
|
98
|
+
await callHook(suite, 'beforeAll', [suite]);
|
|
99
|
+
await Promise.all(suite.tasks.map(i => runTask(i, ctx)));
|
|
100
|
+
// for (const t of suite.tasks)
|
|
101
|
+
// await runTask(t, ctx)
|
|
102
|
+
await callHook(suite, 'afterAll', [suite]);
|
|
103
|
+
}
|
|
104
|
+
catch (e) {
|
|
105
|
+
suite.error = e;
|
|
106
|
+
suite.status = 'fail';
|
|
107
|
+
process.exitCode = 1;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
await ((_b = reporter.onSuiteEnd) === null || _b === void 0 ? void 0 : _b.call(reporter, suite, ctx));
|
|
111
|
+
}
|
|
78
112
|
export async function runFile(file, ctx) {
|
|
79
113
|
var _a, _b;
|
|
80
114
|
const { reporter } = ctx;
|
|
@@ -82,17 +116,13 @@ export async function runFile(file, ctx) {
|
|
|
82
116
|
if (runableSuites.length === 0)
|
|
83
117
|
return;
|
|
84
118
|
await ((_a = reporter.onFileBegin) === null || _a === void 0 ? void 0 : _a.call(reporter, file, ctx));
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
// await runTask(t, ctx)
|
|
93
|
-
await callHook(suite, 'afterAll', [suite]);
|
|
94
|
-
await ((_b = reporter.onSuiteEnd) === null || _b === void 0 ? void 0 : _b.call(reporter, suite, ctx));
|
|
95
|
-
}));
|
|
119
|
+
if (ctx.config.parallel) {
|
|
120
|
+
await Promise.all(file.suites.map(suite => runSite(suite, ctx)));
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
for (const suite of file.suites)
|
|
124
|
+
await runSite(suite, ctx);
|
|
125
|
+
}
|
|
96
126
|
await ((_b = reporter.onFileEnd) === null || _b === void 0 ? void 0 : _b.call(reporter, file, ctx));
|
|
97
127
|
}
|
|
98
128
|
export async function run(config) {
|
package/dist/types.d.ts
CHANGED
|
@@ -15,6 +15,12 @@ export interface UserOptions {
|
|
|
15
15
|
* @default false
|
|
16
16
|
*/
|
|
17
17
|
jsdom?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Run tests files in parallel
|
|
20
|
+
*
|
|
21
|
+
* @default false
|
|
22
|
+
*/
|
|
23
|
+
parallel?: boolean;
|
|
18
24
|
}
|
|
19
25
|
export interface Config extends UserOptions {
|
|
20
26
|
rootDir?: string;
|
|
@@ -47,6 +53,8 @@ export interface Suite {
|
|
|
47
53
|
mode: RunMode;
|
|
48
54
|
tasks: Task[];
|
|
49
55
|
file?: File;
|
|
56
|
+
error?: unknown;
|
|
57
|
+
status?: TaskState;
|
|
50
58
|
hooks: {
|
|
51
59
|
beforeAll: HookListener<[Suite]>[];
|
|
52
60
|
afterAll: HookListener<[Suite]>[];
|