vitest 0.0.32 → 0.0.36
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.gh.md +71 -12
- package/dist/chunk-4OVO6RD6.js +1 -0
- package/dist/chunk-CUG6SVUZ.js +1 -0
- package/dist/chunk-F27UALKJ.js +1 -0
- package/dist/chunk-XPSQDVUG.js +1 -0
- package/dist/global-CKRMAXWF.js +1 -0
- package/dist/happy-dom-RNJZR3YC.js +1 -0
- package/dist/index.d.ts +73 -6
- package/dist/index.js +1 -4
- package/dist/jsdom-6QAZGE6T.js +1 -0
- package/dist/node/cli.d.ts +5 -1
- package/dist/node/cli.js +8 -86
- package/dist/node/entry.d.ts +1 -1
- package/dist/node/entry.js +19 -12
- package/dist/types-d3253f2d.d.ts +213 -0
- package/package.json +11 -6
- package/dist/constants.d.ts +0 -3
- package/dist/constants.js +0 -23
- package/dist/context.d.ts +0 -2
- package/dist/context.js +0 -4
- package/dist/integrations/chai/index.d.ts +0 -3
- package/dist/integrations/chai/index.js +0 -3
- package/dist/integrations/chai/jest-expect.d.ts +0 -2
- package/dist/integrations/chai/jest-expect.js +0 -67
- package/dist/integrations/chai/setup.d.ts +0 -2
- package/dist/integrations/chai/setup.js +0 -11
- package/dist/integrations/chai/snapshot/index.d.ts +0 -8
- package/dist/integrations/chai/snapshot/index.js +0 -27
- package/dist/integrations/chai/snapshot/manager.d.ts +0 -30
- package/dist/integrations/chai/snapshot/manager.js +0 -77
- package/dist/integrations/chai/snapshot/utils/jest-config-helper.d.ts +0 -3
- package/dist/integrations/chai/snapshot/utils/jest-config-helper.js +0 -39
- package/dist/integrations/chai/snapshot/utils/jest-reporters-lite.d.ts +0 -2
- package/dist/integrations/chai/snapshot/utils/jest-reporters-lite.js +0 -71
- package/dist/integrations/chai/snapshot/utils/jest-test-result-helper.d.ts +0 -6
- package/dist/integrations/chai/snapshot/utils/jest-test-result-helper.js +0 -66
- package/dist/integrations/chai/snapshot/utils/types.d.ts +0 -29
- package/dist/integrations/chai/snapshot/utils/types.js +0 -1
- package/dist/integrations/chai/types.d.ts +0 -3
- package/dist/integrations/chai/types.js +0 -1
- package/dist/integrations/global.d.ts +0 -1
- package/dist/integrations/global.js +0 -8
- package/dist/integrations/jsdom/index.d.ts +0 -5
- package/dist/integrations/jsdom/index.js +0 -21
- package/dist/integrations/jsdom/keys.d.ts +0 -1
- package/dist/integrations/jsdom/keys.js +0 -220
- package/dist/integrations/sinon.d.ts +0 -3
- package/dist/integrations/sinon.js +0 -5
- package/dist/node/node.d.ts +0 -23
- package/dist/node/node.js +0 -159
- package/dist/reporters/default.d.ts +0 -24
- package/dist/reporters/default.js +0 -149
- package/dist/reporters/error.d.ts +0 -9
- package/dist/reporters/error.js +0 -182
- package/dist/run/index.d.ts +0 -8
- package/dist/run/index.js +0 -248
- package/dist/suite.d.ts +0 -26
- package/dist/suite.js +0 -91
- package/dist/types.d.ts +0 -138
- package/dist/types.js +0 -1
- package/dist/utils/hook.d.ts +0 -5
- package/dist/utils/hook.js +0 -14
package/dist/suite.js
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { context } from './context';
|
|
2
|
-
export const defaultSuite = suite('');
|
|
3
|
-
function getCurrentSuite() {
|
|
4
|
-
return context.currentSuite || defaultSuite;
|
|
5
|
-
}
|
|
6
|
-
function createSuiteCollector(name, factory = () => { }, mode) {
|
|
7
|
-
const queue = [];
|
|
8
|
-
const factoryQueue = [];
|
|
9
|
-
const suiteBase = {
|
|
10
|
-
name,
|
|
11
|
-
mode,
|
|
12
|
-
hooks: {
|
|
13
|
-
beforeAll: [],
|
|
14
|
-
afterAll: [],
|
|
15
|
-
beforeEach: [],
|
|
16
|
-
afterEach: [],
|
|
17
|
-
},
|
|
18
|
-
};
|
|
19
|
-
const collector = {
|
|
20
|
-
name,
|
|
21
|
-
mode,
|
|
22
|
-
test,
|
|
23
|
-
collect,
|
|
24
|
-
clear,
|
|
25
|
-
on: addHook,
|
|
26
|
-
};
|
|
27
|
-
function addHook(name, ...fn) {
|
|
28
|
-
suiteBase.hooks[name].push(...fn);
|
|
29
|
-
}
|
|
30
|
-
function collectTask(name, fn, mode) {
|
|
31
|
-
queue.push({
|
|
32
|
-
name,
|
|
33
|
-
mode,
|
|
34
|
-
suite: {},
|
|
35
|
-
state: (mode !== 'run' && mode !== 'only') ? mode : undefined,
|
|
36
|
-
fn,
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
function test(name, fn) {
|
|
40
|
-
collectTask(name, fn, 'run');
|
|
41
|
-
}
|
|
42
|
-
test.skip = (name, fn) => collectTask(name, fn, 'skip');
|
|
43
|
-
test.only = (name, fn) => collectTask(name, fn, 'only');
|
|
44
|
-
test.todo = (name) => collectTask(name, () => { }, 'todo');
|
|
45
|
-
function clear() {
|
|
46
|
-
queue.length = 0;
|
|
47
|
-
factoryQueue.length = 0;
|
|
48
|
-
}
|
|
49
|
-
async function collect(file) {
|
|
50
|
-
factoryQueue.length = 0;
|
|
51
|
-
if (factory)
|
|
52
|
-
await factory(test);
|
|
53
|
-
const tasks = [...factoryQueue, ...queue];
|
|
54
|
-
const suite = Object.assign(Object.assign({}, suiteBase), { tasks,
|
|
55
|
-
file });
|
|
56
|
-
tasks.forEach((task) => {
|
|
57
|
-
task.suite = suite;
|
|
58
|
-
if (file)
|
|
59
|
-
task.file = file;
|
|
60
|
-
});
|
|
61
|
-
return suite;
|
|
62
|
-
}
|
|
63
|
-
context.currentSuite = collector;
|
|
64
|
-
context.suites.push(collector);
|
|
65
|
-
return collector;
|
|
66
|
-
}
|
|
67
|
-
// apis
|
|
68
|
-
export const test = (name, fn) => getCurrentSuite().test(name, fn);
|
|
69
|
-
test.skip = (name, fn) => getCurrentSuite().test.skip(name, fn);
|
|
70
|
-
test.only = (name, fn) => getCurrentSuite().test.only(name, fn);
|
|
71
|
-
test.todo = (name) => getCurrentSuite().test.todo(name);
|
|
72
|
-
export function suite(suiteName, factory) {
|
|
73
|
-
return createSuiteCollector(suiteName, factory, 'run');
|
|
74
|
-
}
|
|
75
|
-
suite.skip = (suiteName, factory) => createSuiteCollector(suiteName, factory, 'skip');
|
|
76
|
-
suite.only = (suiteName, factory) => createSuiteCollector(suiteName, factory, 'only');
|
|
77
|
-
suite.todo = (suiteName) => createSuiteCollector(suiteName, undefined, 'todo');
|
|
78
|
-
// alias
|
|
79
|
-
export const describe = suite;
|
|
80
|
-
export const it = test;
|
|
81
|
-
// hooks
|
|
82
|
-
export const beforeAll = (fn) => getCurrentSuite().on('beforeAll', fn);
|
|
83
|
-
export const afterAll = (fn) => getCurrentSuite().on('afterAll', fn);
|
|
84
|
-
export const beforeEach = (fn) => getCurrentSuite().on('beforeEach', fn);
|
|
85
|
-
export const afterEach = (fn) => getCurrentSuite().on('afterEach', fn);
|
|
86
|
-
// utils
|
|
87
|
-
export function clearContext() {
|
|
88
|
-
context.suites.length = 0;
|
|
89
|
-
defaultSuite.clear();
|
|
90
|
-
context.currentSuite = defaultSuite;
|
|
91
|
-
}
|
package/dist/types.d.ts
DELETED
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import { SnapshotManager } from './integrations/chai/snapshot/manager';
|
|
2
|
-
export declare type Awaitable<T> = Promise<T> | T;
|
|
3
|
-
export interface UserOptions {
|
|
4
|
-
/**
|
|
5
|
-
* Include globs for test files
|
|
6
|
-
*
|
|
7
|
-
* @default ['**\/*.test.ts']
|
|
8
|
-
*/
|
|
9
|
-
includes?: string[];
|
|
10
|
-
/**
|
|
11
|
-
* Exclude globs for test files
|
|
12
|
-
* @default ['**\/node_modules\/**']
|
|
13
|
-
*/
|
|
14
|
-
excludes?: string[];
|
|
15
|
-
/**
|
|
16
|
-
* Handling for dependencies inlining or externalizing
|
|
17
|
-
*/
|
|
18
|
-
deps?: {
|
|
19
|
-
external?: (string | RegExp)[];
|
|
20
|
-
inline?: (string | RegExp)[];
|
|
21
|
-
};
|
|
22
|
-
/**
|
|
23
|
-
* Register apis globally
|
|
24
|
-
*
|
|
25
|
-
* @default false
|
|
26
|
-
*/
|
|
27
|
-
global?: boolean;
|
|
28
|
-
/**
|
|
29
|
-
* Use `js-dom` to mock browser APIs
|
|
30
|
-
*
|
|
31
|
-
* @default false
|
|
32
|
-
*/
|
|
33
|
-
jsdom?: boolean;
|
|
34
|
-
/**
|
|
35
|
-
* Run tests files in parallel
|
|
36
|
-
*
|
|
37
|
-
* @default false
|
|
38
|
-
*/
|
|
39
|
-
parallel?: boolean;
|
|
40
|
-
/**
|
|
41
|
-
* Update snapshot files
|
|
42
|
-
*
|
|
43
|
-
* @default false
|
|
44
|
-
*/
|
|
45
|
-
update?: boolean;
|
|
46
|
-
/**
|
|
47
|
-
* Watch mode
|
|
48
|
-
*
|
|
49
|
-
* @default false
|
|
50
|
-
*/
|
|
51
|
-
watch?: boolean;
|
|
52
|
-
/**
|
|
53
|
-
* Project root
|
|
54
|
-
*/
|
|
55
|
-
root?: string;
|
|
56
|
-
/**
|
|
57
|
-
* Custom reporter for output
|
|
58
|
-
*/
|
|
59
|
-
reporter?: Reporter;
|
|
60
|
-
}
|
|
61
|
-
export interface ResolvedConfig extends Required<UserOptions> {
|
|
62
|
-
filters?: string[];
|
|
63
|
-
config?: string;
|
|
64
|
-
}
|
|
65
|
-
export declare type RunMode = 'run' | 'skip' | 'only' | 'todo';
|
|
66
|
-
export declare type TaskState = RunMode | 'pass' | 'fail';
|
|
67
|
-
export interface Task {
|
|
68
|
-
name: string;
|
|
69
|
-
mode: RunMode;
|
|
70
|
-
suite: Suite;
|
|
71
|
-
fn: () => Awaitable<void>;
|
|
72
|
-
file?: File;
|
|
73
|
-
state?: TaskState;
|
|
74
|
-
error?: unknown;
|
|
75
|
-
}
|
|
76
|
-
export declare type TestFunction = () => Awaitable<void>;
|
|
77
|
-
export interface TestCollector {
|
|
78
|
-
(name: string, fn: TestFunction): void;
|
|
79
|
-
only: (name: string, fn: TestFunction) => void;
|
|
80
|
-
skip: (name: string, fn: TestFunction) => void;
|
|
81
|
-
todo: (name: string) => void;
|
|
82
|
-
}
|
|
83
|
-
export declare type HookListener<T extends any[]> = (...args: T) => Awaitable<void>;
|
|
84
|
-
export interface Suite {
|
|
85
|
-
name: string;
|
|
86
|
-
mode: RunMode;
|
|
87
|
-
tasks: Task[];
|
|
88
|
-
file?: File;
|
|
89
|
-
error?: unknown;
|
|
90
|
-
status?: TaskState;
|
|
91
|
-
hooks: {
|
|
92
|
-
beforeAll: HookListener<[Suite]>[];
|
|
93
|
-
afterAll: HookListener<[Suite]>[];
|
|
94
|
-
beforeEach: HookListener<[Task, Suite]>[];
|
|
95
|
-
afterEach: HookListener<[Task, Suite]>[];
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
export interface SuiteCollector {
|
|
99
|
-
readonly name: string;
|
|
100
|
-
readonly mode: RunMode;
|
|
101
|
-
test: TestCollector;
|
|
102
|
-
collect: (file?: File) => Promise<Suite>;
|
|
103
|
-
clear: () => void;
|
|
104
|
-
on: <T extends keyof Suite['hooks']>(name: T, ...fn: Suite['hooks'][T]) => void;
|
|
105
|
-
}
|
|
106
|
-
export declare type TestFactory = (test: (name: string, fn: TestFunction) => void) => Awaitable<void>;
|
|
107
|
-
export interface File {
|
|
108
|
-
filepath: string;
|
|
109
|
-
suites: Suite[];
|
|
110
|
-
collected: boolean;
|
|
111
|
-
error?: unknown;
|
|
112
|
-
}
|
|
113
|
-
export interface RunnerContext {
|
|
114
|
-
filesMap: Record<string, File>;
|
|
115
|
-
files: File[];
|
|
116
|
-
suites: Suite[];
|
|
117
|
-
tasks: Task[];
|
|
118
|
-
config: ResolvedConfig;
|
|
119
|
-
reporter: Reporter;
|
|
120
|
-
snapshotManager: SnapshotManager;
|
|
121
|
-
}
|
|
122
|
-
export interface GlobalContext {
|
|
123
|
-
suites: SuiteCollector[];
|
|
124
|
-
currentSuite: SuiteCollector | null;
|
|
125
|
-
}
|
|
126
|
-
export interface Reporter {
|
|
127
|
-
onStart?: (config: ResolvedConfig) => Awaitable<void>;
|
|
128
|
-
onCollected?: (files: File[], ctx: RunnerContext) => Awaitable<void>;
|
|
129
|
-
onFinished?: (ctx: RunnerContext, files?: File[]) => Awaitable<void>;
|
|
130
|
-
onSuiteBegin?: (suite: Suite, ctx: RunnerContext) => Awaitable<void>;
|
|
131
|
-
onSuiteEnd?: (suite: Suite, ctx: RunnerContext) => Awaitable<void>;
|
|
132
|
-
onFileBegin?: (file: File, ctx: RunnerContext) => Awaitable<void>;
|
|
133
|
-
onFileEnd?: (file: File, ctx: RunnerContext) => Awaitable<void>;
|
|
134
|
-
onTaskBegin?: (task: Task, ctx: RunnerContext) => Awaitable<void>;
|
|
135
|
-
onTaskEnd?: (task: Task, ctx: RunnerContext) => Awaitable<void>;
|
|
136
|
-
onWatcherStart?: (ctx: RunnerContext) => Awaitable<void>;
|
|
137
|
-
onWatcherRerun?: (files: string[], trigger: string, ctx: RunnerContext) => Awaitable<void>;
|
|
138
|
-
}
|
package/dist/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/utils/hook.d.ts
DELETED
package/dist/utils/hook.js
DELETED