vitest 0.0.8 → 0.0.9
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/README.md +13 -10
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/reporters/default.d.ts +5 -4
- package/dist/reporters/default.js +23 -14
- package/package.json +14 -10
package/README.md
CHANGED
|
@@ -6,12 +6,14 @@ A blazing fast test runner powered by Vite.
|
|
|
6
6
|
|
|
7
7
|
## Features
|
|
8
8
|
|
|
9
|
-
- Vite's
|
|
10
|
-
- Jest Snapshot.
|
|
11
|
-
- Chai for assertions
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
9
|
+
- [Vite](https://vitejs.dev/)'s config, transformers, resolvers, and plugins. Powered by [vite-node](https://github.com/antfu/vite-node)
|
|
10
|
+
- [Jest Snapshot](https://jestjs.io/docs/snapshot-testing)
|
|
11
|
+
- [Chai](https://www.chaijs.com/) for assertions
|
|
12
|
+
- [Sinon](https://sinonjs.org/) for mocking
|
|
13
|
+
- Async suite / test, top level await
|
|
14
|
+
- ESM friendly
|
|
15
|
+
- Out-of-box TypeScript support
|
|
16
|
+
- Suite and Test filtering (skip, only, todo)
|
|
15
17
|
|
|
16
18
|
```ts
|
|
17
19
|
import { it, describe, expect, assert } from 'vitest'
|
|
@@ -91,17 +93,18 @@ Use `.todo` to stub suites and tests that should be implemented
|
|
|
91
93
|
describe.todo('unimplemented suite')
|
|
92
94
|
|
|
93
95
|
// An entry will be shown in the report for this task
|
|
94
|
-
describe
|
|
96
|
+
describe('suite', () => {
|
|
95
97
|
it.todo('unimplemented task')
|
|
96
98
|
})
|
|
97
99
|
```
|
|
98
100
|
|
|
99
101
|
## TODO
|
|
100
102
|
|
|
101
|
-
- [
|
|
103
|
+
- [x] Reporter & Better output
|
|
104
|
+
- [x] Task filter
|
|
105
|
+
- [x] Mock
|
|
106
|
+
- [ ] Parallel Executing
|
|
102
107
|
- [ ] CLI Help
|
|
103
|
-
- [ ] Task filter
|
|
104
|
-
- [ ] Mock
|
|
105
108
|
- [ ] JSDom
|
|
106
109
|
- [ ] Watch
|
|
107
110
|
- [ ] Coverage
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import sinon from 'sinon';
|
|
1
2
|
export * from './types';
|
|
2
3
|
export * from './suite';
|
|
3
4
|
export * from './config';
|
|
4
5
|
export * from './chai';
|
|
5
6
|
export { beforeAll, afterAll, beforeEach, afterEach, beforeFile, afterFile, beforeSuite, afterSuite } from './hooks';
|
|
7
|
+
export { sinon };
|
|
8
|
+
export declare const mock: sinon.SinonMockStatic, spy: sinon.SinonSpyStatic;
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import sinon from 'sinon';
|
|
1
2
|
export * from './types';
|
|
2
3
|
export * from './suite';
|
|
3
4
|
export * from './config';
|
|
4
5
|
export * from './chai';
|
|
5
6
|
export { beforeAll, afterAll, beforeEach, afterEach, beforeFile, afterFile, beforeSuite, afterSuite } from './hooks';
|
|
7
|
+
export { sinon };
|
|
8
|
+
export const { mock, spy } = sinon;
|
|
@@ -10,9 +10,10 @@ export declare class DefaultReporter implements Reporter {
|
|
|
10
10
|
onSuiteEnd(suite: Suite): void;
|
|
11
11
|
onFileBegin(file: File): void;
|
|
12
12
|
onFileEnd(): void;
|
|
13
|
-
onTaskBegin(): void;
|
|
14
|
-
onTaskEnd(
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
onTaskBegin(task: Task): void;
|
|
14
|
+
onTaskEnd(task: Task): void;
|
|
15
|
+
private getIndent;
|
|
16
|
+
private log;
|
|
17
|
+
private error;
|
|
17
18
|
onSnapshotUpdate(): void;
|
|
18
19
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { relative } from 'path';
|
|
2
2
|
import { performance } from 'perf_hooks';
|
|
3
3
|
import c from 'picocolors';
|
|
4
|
+
import ora from 'ora';
|
|
4
5
|
const DOT = '· ';
|
|
5
6
|
export class DefaultReporter {
|
|
6
7
|
constructor() {
|
|
@@ -53,33 +54,41 @@ export class DefaultReporter {
|
|
|
53
54
|
onFileEnd() {
|
|
54
55
|
this.log();
|
|
55
56
|
}
|
|
56
|
-
onTaskBegin() {
|
|
57
|
+
onTaskBegin(task) {
|
|
57
58
|
this.indent += 1;
|
|
59
|
+
// @ts-expect-error
|
|
60
|
+
task.__ora = ora({ text: task.name, prefixText: this.getIndent().slice(1), spinner: 'arc' }).start();
|
|
58
61
|
}
|
|
59
|
-
onTaskEnd(
|
|
60
|
-
|
|
61
|
-
|
|
62
|
+
onTaskEnd(task) {
|
|
63
|
+
var _a;
|
|
64
|
+
// @ts-expect-error
|
|
65
|
+
(_a = task.__ora) === null || _a === void 0 ? void 0 : _a.stop();
|
|
66
|
+
if (task.status === 'pass') {
|
|
67
|
+
this.log(`${c.green(`✔ ${task.name}`)}`);
|
|
62
68
|
}
|
|
63
|
-
else if (
|
|
64
|
-
this.log(c.dim(c.yellow(`${DOT +
|
|
69
|
+
else if (task.status === 'skip') {
|
|
70
|
+
this.log(c.dim(c.yellow(`${DOT + task.name} (skipped)`)));
|
|
65
71
|
}
|
|
66
|
-
else if (
|
|
67
|
-
this.log(c.dim(`${DOT +
|
|
72
|
+
else if (task.status === 'todo') {
|
|
73
|
+
this.log(c.dim(`${DOT + task.name} (todo)`));
|
|
68
74
|
}
|
|
69
75
|
else {
|
|
70
|
-
this.error(`${c.red(`⤫ ${c.inverse(c.red(' FAIL '))} ${
|
|
71
|
-
this.error(String(
|
|
76
|
+
this.error(`${c.red(`⤫ ${c.inverse(c.red(' FAIL '))} ${task.name}`)}`);
|
|
77
|
+
this.error(String(task.error), 1);
|
|
72
78
|
process.exitCode = 1;
|
|
73
79
|
}
|
|
74
80
|
this.indent -= 1;
|
|
75
81
|
}
|
|
76
|
-
|
|
82
|
+
getIndent(offest = 0) {
|
|
83
|
+
return ' '.repeat((this.indent + offest) * 2);
|
|
84
|
+
}
|
|
85
|
+
log(msg = '', indentOffset = 0) {
|
|
77
86
|
// eslint-disable-next-line no-console
|
|
78
|
-
console.log(`${
|
|
87
|
+
console.log(`${this.getIndent(indentOffset)}${msg}`);
|
|
79
88
|
}
|
|
80
|
-
error(msg = '',
|
|
89
|
+
error(msg = '', indentOffset = 0) {
|
|
81
90
|
// eslint-disable-next-line no-console
|
|
82
|
-
console.error(c.red(`${
|
|
91
|
+
console.error(c.red(`${this.getIndent(indentOffset)}${msg}`));
|
|
83
92
|
}
|
|
84
93
|
onSnapshotUpdate() {
|
|
85
94
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vitest",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.9",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "",
|
|
6
6
|
"keywords": [],
|
|
@@ -32,11 +32,21 @@
|
|
|
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",
|
|
38
47
|
"@types/minimist": "^1.2.2",
|
|
39
48
|
"@types/node": "^16.11.11",
|
|
49
|
+
"@types/sinon": "^10.0.6",
|
|
40
50
|
"bumpp": "^7.1.1",
|
|
41
51
|
"eslint": "^8.3.0",
|
|
42
52
|
"esno": "^0.12.1",
|
|
@@ -52,15 +62,9 @@
|
|
|
52
62
|
"jest-snapshot": "^27.4.2",
|
|
53
63
|
"jest-util": "^27.4.2",
|
|
54
64
|
"minimist": "^1.2.5",
|
|
65
|
+
"ora": "^6.0.1",
|
|
55
66
|
"picocolors": "^1.0.0",
|
|
67
|
+
"sinon": "^12.0.1",
|
|
56
68
|
"vite-node": "^0.1.10"
|
|
57
|
-
},
|
|
58
|
-
"scripts": {
|
|
59
|
-
"build": "tsc",
|
|
60
|
-
"watch": "tsc --watch",
|
|
61
|
-
"lint": "eslint \"{src,test}/**/*.ts\"",
|
|
62
|
-
"release": "bumpp --commit --push --tag && pnpm publish",
|
|
63
|
-
"test": "node bin/vitest.mjs --dev",
|
|
64
|
-
"test:update": "nr test -u"
|
|
65
69
|
}
|
|
66
|
-
}
|
|
70
|
+
}
|