vitest 0.0.35 → 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.
Files changed (62) hide show
  1. package/dist/chunk-4OVO6RD6.js +1 -0
  2. package/dist/chunk-CUG6SVUZ.js +1 -0
  3. package/dist/chunk-F27UALKJ.js +1 -0
  4. package/dist/chunk-XPSQDVUG.js +1 -0
  5. package/dist/global-CKRMAXWF.js +1 -0
  6. package/dist/happy-dom-RNJZR3YC.js +1 -0
  7. package/dist/index.d.ts +73 -6
  8. package/dist/index.js +1 -4
  9. package/dist/jsdom-6QAZGE6T.js +1 -0
  10. package/dist/node/cli.d.ts +5 -1
  11. package/dist/node/cli.js +8 -86
  12. package/dist/node/entry.d.ts +1 -1
  13. package/dist/node/entry.js +19 -12
  14. package/dist/{types.d.ts → types-d3253f2d.d.ts} +69 -18
  15. package/package.json +8 -4
  16. package/dist/constants.d.ts +0 -4
  17. package/dist/constants.js +0 -24
  18. package/dist/context.d.ts +0 -2
  19. package/dist/context.js +0 -4
  20. package/dist/integrations/chai/index.d.ts +0 -3
  21. package/dist/integrations/chai/index.js +0 -3
  22. package/dist/integrations/chai/jest-expect.d.ts +0 -2
  23. package/dist/integrations/chai/jest-expect.js +0 -67
  24. package/dist/integrations/chai/setup.d.ts +0 -2
  25. package/dist/integrations/chai/setup.js +0 -11
  26. package/dist/integrations/chai/snapshot/index.d.ts +0 -8
  27. package/dist/integrations/chai/snapshot/index.js +0 -27
  28. package/dist/integrations/chai/snapshot/manager.d.ts +0 -30
  29. package/dist/integrations/chai/snapshot/manager.js +0 -77
  30. package/dist/integrations/chai/snapshot/utils/jest-config-helper.d.ts +0 -3
  31. package/dist/integrations/chai/snapshot/utils/jest-config-helper.js +0 -39
  32. package/dist/integrations/chai/snapshot/utils/jest-reporters-lite.d.ts +0 -2
  33. package/dist/integrations/chai/snapshot/utils/jest-reporters-lite.js +0 -71
  34. package/dist/integrations/chai/snapshot/utils/jest-test-result-helper.d.ts +0 -6
  35. package/dist/integrations/chai/snapshot/utils/jest-test-result-helper.js +0 -66
  36. package/dist/integrations/chai/snapshot/utils/types.d.ts +0 -29
  37. package/dist/integrations/chai/snapshot/utils/types.js +0 -1
  38. package/dist/integrations/chai/types.d.ts +0 -3
  39. package/dist/integrations/chai/types.js +0 -1
  40. package/dist/integrations/dom/happy-dom.d.ts +0 -5
  41. package/dist/integrations/dom/happy-dom.js +0 -18
  42. package/dist/integrations/dom/jsdom.d.ts +0 -5
  43. package/dist/integrations/dom/jsdom.js +0 -21
  44. package/dist/integrations/dom/keys.d.ts +0 -1
  45. package/dist/integrations/dom/keys.js +0 -220
  46. package/dist/integrations/global.d.ts +0 -1
  47. package/dist/integrations/global.js +0 -8
  48. package/dist/integrations/sinon.d.ts +0 -3
  49. package/dist/integrations/sinon.js +0 -5
  50. package/dist/node/node.d.ts +0 -27
  51. package/dist/node/node.js +0 -167
  52. package/dist/reporters/default.d.ts +0 -24
  53. package/dist/reporters/default.js +0 -149
  54. package/dist/reporters/error.d.ts +0 -9
  55. package/dist/reporters/error.js +0 -183
  56. package/dist/run/index.d.ts +0 -8
  57. package/dist/run/index.js +0 -271
  58. package/dist/suite.d.ts +0 -56
  59. package/dist/suite.js +0 -142
  60. package/dist/types.js +0 -1
  61. package/dist/utils/hook.d.ts +0 -5
  62. package/dist/utils/hook.js +0 -14
@@ -1,220 +0,0 @@
1
- // SEE https://github.com/jsdom/jsdom/blob/master/lib/jsdom/living/interfaces.js
2
- const LIVING_KEYS = [
3
- 'DOMException',
4
- 'URL',
5
- 'URLSearchParams',
6
- 'EventTarget',
7
- 'NamedNodeMap',
8
- 'Node',
9
- 'Attr',
10
- 'Element',
11
- 'DocumentFragment',
12
- 'DOMImplementation',
13
- 'Document',
14
- 'XMLDocument',
15
- 'CharacterData',
16
- 'Text',
17
- 'CDATASection',
18
- 'ProcessingInstruction',
19
- 'Comment',
20
- 'DocumentType',
21
- 'NodeList',
22
- 'HTMLCollection',
23
- 'HTMLOptionsCollection',
24
- 'DOMStringMap',
25
- 'DOMTokenList',
26
- 'StyleSheetList',
27
- 'HTMLElement',
28
- 'HTMLHeadElement',
29
- 'HTMLTitleElement',
30
- 'HTMLBaseElement',
31
- 'HTMLLinkElement',
32
- 'HTMLMetaElement',
33
- 'HTMLStyleElement',
34
- 'HTMLBodyElement',
35
- 'HTMLHeadingElement',
36
- 'HTMLParagraphElement',
37
- 'HTMLHRElement',
38
- 'HTMLPreElement',
39
- 'HTMLUListElement',
40
- 'HTMLOListElement',
41
- 'HTMLLIElement',
42
- 'HTMLMenuElement',
43
- 'HTMLDListElement',
44
- 'HTMLDivElement',
45
- 'HTMLAnchorElement',
46
- 'HTMLAreaElement',
47
- 'HTMLBRElement',
48
- 'HTMLButtonElement',
49
- 'HTMLCanvasElement',
50
- 'HTMLDataElement',
51
- 'HTMLDataListElement',
52
- 'HTMLDetailsElement',
53
- 'HTMLDialogElement',
54
- 'HTMLDirectoryElement',
55
- 'HTMLFieldSetElement',
56
- 'HTMLFontElement',
57
- 'HTMLFormElement',
58
- 'HTMLHtmlElement',
59
- 'HTMLImageElement',
60
- 'HTMLInputElement',
61
- 'HTMLLabelElement',
62
- 'HTMLLegendElement',
63
- 'HTMLMapElement',
64
- 'HTMLMarqueeElement',
65
- 'HTMLMediaElement',
66
- 'HTMLMeterElement',
67
- 'HTMLModElement',
68
- 'HTMLOptGroupElement',
69
- 'HTMLOptionElement',
70
- 'HTMLOutputElement',
71
- 'HTMLPictureElement',
72
- 'HTMLProgressElement',
73
- 'HTMLQuoteElement',
74
- 'HTMLScriptElement',
75
- 'HTMLSelectElement',
76
- 'HTMLSlotElement',
77
- 'HTMLSourceElement',
78
- 'HTMLSpanElement',
79
- 'HTMLTableCaptionElement',
80
- 'HTMLTableCellElement',
81
- 'HTMLTableColElement',
82
- 'HTMLTableElement',
83
- 'HTMLTimeElement',
84
- 'HTMLTableRowElement',
85
- 'HTMLTableSectionElement',
86
- 'HTMLTemplateElement',
87
- 'HTMLTextAreaElement',
88
- 'HTMLUnknownElement',
89
- 'HTMLFrameElement',
90
- 'HTMLFrameSetElement',
91
- 'HTMLIFrameElement',
92
- 'HTMLEmbedElement',
93
- 'HTMLObjectElement',
94
- 'HTMLParamElement',
95
- 'HTMLVideoElement',
96
- 'HTMLAudioElement',
97
- 'HTMLTrackElement',
98
- 'SVGElement',
99
- 'SVGGraphicsElement',
100
- 'SVGSVGElement',
101
- 'SVGTitleElement',
102
- 'SVGAnimatedString',
103
- 'SVGNumber',
104
- 'SVGStringList',
105
- 'Event',
106
- 'CloseEvent',
107
- 'CustomEvent',
108
- 'MessageEvent',
109
- 'ErrorEvent',
110
- 'HashChangeEvent',
111
- 'PopStateEvent',
112
- 'StorageEvent',
113
- 'ProgressEvent',
114
- 'PageTransitionEvent',
115
- 'UIEvent',
116
- 'FocusEvent',
117
- 'InputEvent',
118
- 'MouseEvent',
119
- 'KeyboardEvent',
120
- 'TouchEvent',
121
- 'CompositionEvent',
122
- 'WheelEvent',
123
- 'BarProp',
124
- 'External',
125
- 'Location',
126
- 'History',
127
- 'Screen',
128
- 'Performance',
129
- 'Navigator',
130
- 'PluginArray',
131
- 'MimeTypeArray',
132
- 'Plugin',
133
- 'MimeType',
134
- 'FileReader',
135
- 'Blob',
136
- 'File',
137
- 'FileList',
138
- 'ValidityState',
139
- 'DOMParser',
140
- 'XMLSerializer',
141
- 'FormData',
142
- 'XMLHttpRequestEventTarget',
143
- 'XMLHttpRequestUpload',
144
- 'XMLHttpRequest',
145
- 'WebSocket',
146
- 'NodeFilter',
147
- 'NodeIterator',
148
- 'TreeWalker',
149
- 'AbstractRange',
150
- 'Range',
151
- 'StaticRange',
152
- 'Selection',
153
- 'Storage',
154
- 'CustomElementRegistry',
155
- 'ShadowRoot',
156
- 'MutationObserver',
157
- 'MutationRecord',
158
- 'Headers',
159
- 'AbortController',
160
- 'AbortSignal',
161
- ];
162
- const OTHER_KEYS = [
163
- 'addEventListener',
164
- 'alert',
165
- 'atob',
166
- 'blur',
167
- 'btoa',
168
- /* 'clearInterval', */
169
- /* 'clearTimeout', */
170
- 'close',
171
- 'confirm',
172
- /* 'console', */
173
- 'createPopup',
174
- 'dispatchEvent',
175
- 'document',
176
- 'focus',
177
- 'frames',
178
- 'getComputedStyle',
179
- 'history',
180
- 'innerHeight',
181
- 'innerWidth',
182
- 'length',
183
- 'location',
184
- 'moveBy',
185
- 'moveTo',
186
- 'name',
187
- 'navigator',
188
- 'open',
189
- 'outerHeight',
190
- 'outerWidth',
191
- 'pageXOffset',
192
- 'pageYOffset',
193
- 'parent',
194
- 'postMessage',
195
- 'print',
196
- 'prompt',
197
- 'removeEventListener',
198
- 'resizeBy',
199
- 'resizeTo',
200
- 'screen',
201
- 'screenLeft',
202
- 'screenTop',
203
- 'screenX',
204
- 'screenY',
205
- 'scroll',
206
- 'scrollBy',
207
- 'scrollLeft',
208
- 'scrollTo',
209
- 'scrollTop',
210
- 'scrollX',
211
- 'scrollY',
212
- 'self',
213
- /* 'setInterval', */
214
- /* 'setTimeout', */
215
- 'stop',
216
- /* 'toString', */
217
- 'top',
218
- 'window',
219
- ];
220
- export const KEYS = LIVING_KEYS.concat(OTHER_KEYS);
@@ -1 +0,0 @@
1
- export declare function registerApiGlobally(): void;
@@ -1,8 +0,0 @@
1
- import { globalApis } from '../constants';
2
- import * as index from '../index';
3
- export function registerApiGlobally() {
4
- globalApis.forEach((api) => {
5
- // @ts-expect-error
6
- globalThis[api] = index[api];
7
- });
8
- }
@@ -1,3 +0,0 @@
1
- import sinon from 'sinon';
2
- export { sinon };
3
- export declare const mock: sinon.SinonMockStatic, spy: sinon.SinonSpyStatic, stub: sinon.SinonStubStatic;
@@ -1,5 +0,0 @@
1
- import sinon from 'sinon';
2
- export { sinon };
3
- export const { mock, spy, stub } = sinon;
4
- // @ts-expect-error
5
- sinon.fn = sinon.spy;
@@ -1,27 +0,0 @@
1
- import { InlineConfig, ViteDevServer, TransformResult } from 'vite';
2
- export interface ModuleCache {
3
- promise?: Promise<any>;
4
- exports?: any;
5
- transformResult?: TransformResult;
6
- }
7
- declare global {
8
- namespace NodeJS {
9
- interface Process {
10
- __vite_node__: {
11
- server: ViteDevServer;
12
- watch?: boolean;
13
- moduleCache: Map<string, ModuleCache>;
14
- };
15
- }
16
- }
17
- }
18
- export interface ViteNodeOptions {
19
- silent?: boolean;
20
- root: string;
21
- files: string[];
22
- _?: string[];
23
- shouldExternalize?: (file: string, server: ViteDevServer) => boolean;
24
- config?: string;
25
- defaultConfig?: InlineConfig;
26
- }
27
- export declare function run(argv: ViteNodeOptions): Promise<void>;
package/dist/node/node.js DELETED
@@ -1,167 +0,0 @@
1
- import { builtinModules, createRequire } from 'module';
2
- import { fileURLToPath, pathToFileURL } from 'url';
3
- import { dirname, resolve, relative } from 'path';
4
- import vm from 'vm';
5
- import { createServer, mergeConfig } from 'vite';
6
- import c from 'picocolors';
7
- import { slash } from '@antfu/utils';
8
- const { red, dim, yellow } = c;
9
- const moduleCache = new Map();
10
- export async function run(argv) {
11
- process.exitCode = 0;
12
- const root = argv.root || process.cwd();
13
- process.chdir(root);
14
- const files = argv.files || argv._;
15
- argv.shouldExternalize = argv.shouldExternalize || (id => id.includes('/node_modules/'));
16
- const server = await createServer(mergeConfig(argv.defaultConfig || {}, {
17
- logLevel: 'error',
18
- clearScreen: false,
19
- configFile: argv.config,
20
- root,
21
- resolve: {},
22
- }));
23
- await server.pluginContainer.buildStart({});
24
- process.__vite_node__ = {
25
- server,
26
- moduleCache,
27
- };
28
- try {
29
- await execute(files, server, argv);
30
- }
31
- catch (e) {
32
- process.exitCode = 1;
33
- throw e;
34
- }
35
- finally {
36
- if (!process.__vite_node__.watch)
37
- await server.close();
38
- }
39
- }
40
- function normalizeId(id) {
41
- // Virtual modules start with `\0`
42
- if (id && id.startsWith('/@id/__x00__'))
43
- id = `\0${id.slice('/@id/__x00__'.length)}`;
44
- if (id && id.startsWith('/@id/'))
45
- id = id.slice('/@id/'.length);
46
- if (id.startsWith('__vite-browser-external:'))
47
- id = id.slice('__vite-browser-external:'.length);
48
- return id;
49
- }
50
- function toFilePath(id, server) {
51
- let absolute = slash(id).startsWith('/@fs/')
52
- ? id.slice(4)
53
- : id.startsWith(dirname(server.config.root))
54
- ? id
55
- : id.startsWith('/')
56
- ? slash(resolve(server.config.root, id.slice(1)))
57
- : id;
58
- if (absolute.startsWith('//'))
59
- absolute = absolute.slice(1);
60
- return absolute;
61
- }
62
- const stubRequests = {
63
- '/@vite/client': {
64
- injectQuery: (id) => id,
65
- createHotContext() {
66
- return {
67
- accept: () => { },
68
- prune: () => { },
69
- };
70
- },
71
- updateStyle() { },
72
- },
73
- };
74
- async function transform(server, id) {
75
- if (id.match(/\.(?:[cm]?[jt]sx?|json)$/)) {
76
- return await server.transformRequest(id, { ssr: true });
77
- }
78
- else {
79
- // for components like Vue, we want to use the client side
80
- // plugins but then covert the code to be consumed by the server
81
- const result = await server.transformRequest(id);
82
- if (!result)
83
- return undefined;
84
- return await server.ssrTransform(result.code, result.map, id);
85
- }
86
- }
87
- function setCache(id, mod) {
88
- if (!moduleCache.has(id))
89
- moduleCache.set(id, mod);
90
- else
91
- Object.assign(moduleCache.get(id), mod);
92
- }
93
- async function execute(files, server, options) {
94
- const result = [];
95
- for (const file of files)
96
- result.push(await cachedRequest(`/@fs/${slash(resolve(file))}`, []));
97
- return result;
98
- async function directRequest(id, fsPath, callstack) {
99
- callstack = [...callstack, id];
100
- const request = async (dep) => {
101
- if (callstack.includes(dep)) {
102
- if (!moduleCache.get(dep)) {
103
- throw new Error(`${red('Circular dependency detected')}\nStack:\n${[...callstack, dep].reverse().map((i) => {
104
- const path = relative(server.config.root, toFilePath(normalizeId(i), server));
105
- return dim(' -> ') + (i === dep ? yellow(path) : path);
106
- }).join('\n')}\n`);
107
- }
108
- return moduleCache.get(dep).exports;
109
- }
110
- return cachedRequest(dep, callstack);
111
- };
112
- if (id in stubRequests)
113
- return stubRequests[id];
114
- const result = await transform(server, id);
115
- if (!result)
116
- throw new Error(`failed to load ${id}`);
117
- const url = pathToFileURL(fsPath);
118
- const exports = {};
119
- setCache(id, { transformResult: result, exports });
120
- const __filename = fileURLToPath(url);
121
- const context = {
122
- require: createRequire(url),
123
- __filename,
124
- __dirname: dirname(__filename),
125
- __vite_ssr_import__: request,
126
- __vite_ssr_dynamic_import__: request,
127
- __vite_ssr_exports__: exports,
128
- __vite_ssr_exportAll__: (obj) => exportAll(exports, obj),
129
- __vite_ssr_import_meta__: { url },
130
- };
131
- const fn = vm.runInThisContext(`async (${Object.keys(context).join(',')}) => { ${result.code} }`, {
132
- filename: fsPath,
133
- lineOffset: 0,
134
- });
135
- await fn(...Object.values(context));
136
- return exports;
137
- }
138
- async function cachedRequest(rawId, callstack) {
139
- var _a, _b;
140
- const id = normalizeId(rawId);
141
- if (builtinModules.includes(id))
142
- return import(id);
143
- const fsPath = toFilePath(id, server);
144
- if (options.shouldExternalize(fsPath, server))
145
- return import(fsPath);
146
- if ((_a = moduleCache.get(fsPath)) === null || _a === void 0 ? void 0 : _a.promise)
147
- return (_b = moduleCache.get(fsPath)) === null || _b === void 0 ? void 0 : _b.promise;
148
- const promise = directRequest(id, fsPath, callstack);
149
- setCache(fsPath, { promise });
150
- return await promise;
151
- }
152
- function exportAll(exports, sourceModule) {
153
- // eslint-disable-next-line no-restricted-syntax
154
- for (const key in sourceModule) {
155
- if (key !== 'default') {
156
- try {
157
- Object.defineProperty(exports, key, {
158
- enumerable: true,
159
- configurable: true,
160
- get() { return sourceModule[key]; },
161
- });
162
- }
163
- catch (_err) { }
164
- }
165
- }
166
- }
167
- }
@@ -1,24 +0,0 @@
1
- import Listr from 'listr';
2
- import { File, Reporter, RunnerContext, Task, ResolvedConfig } from '../types';
3
- interface TaskPromise {
4
- promise: Promise<void>;
5
- resolve: () => void;
6
- reject: (e: unknown) => void;
7
- }
8
- export declare class DefaultReporter implements Reporter {
9
- start: number;
10
- end: number;
11
- listr: Listr | null;
12
- listrPromise: Promise<void> | null;
13
- taskMap: Map<Task, TaskPromise>;
14
- cwd: string;
15
- relative(path: string): string;
16
- onStart(config: ResolvedConfig): void;
17
- onCollected(files: File[]): void;
18
- onTaskEnd(task: Task): void;
19
- onFinished(ctx: RunnerContext, files?: File[]): Promise<void>;
20
- onWatcherStart(ctx: RunnerContext): Promise<void>;
21
- onWatcherRerun(files: string[], trigger: string): Promise<void>;
22
- onSnapshotUpdate(): void;
23
- }
24
- export {};
@@ -1,149 +0,0 @@
1
- /* eslint-disable no-console */
2
- import { performance } from 'perf_hooks';
3
- import { relative } from 'path';
4
- import c from 'picocolors';
5
- import Listr from 'listr';
6
- import { printError } from './error';
7
- const CROSS = '✖ ';
8
- export class DefaultReporter {
9
- constructor() {
10
- this.start = 0;
11
- this.end = 0;
12
- this.listr = null;
13
- this.listrPromise = null;
14
- this.taskMap = new Map();
15
- this.cwd = process.cwd();
16
- }
17
- relative(path) {
18
- return relative(this.cwd, path);
19
- }
20
- onStart(config) {
21
- this.cwd = config.root;
22
- console.log(c.green(`Running tests under ${c.gray(this.cwd)}\n`));
23
- }
24
- onCollected(files) {
25
- this.start = performance.now();
26
- this.taskMap = new Map();
27
- const tasks = files.reduce((acc, file) => acc.concat(file.suites.flatMap(i => i.tasks)), []);
28
- tasks.forEach((t) => {
29
- const obj = {};
30
- obj.promise = new Promise((resolve, reject) => {
31
- obj.resolve = resolve;
32
- obj.reject = reject;
33
- });
34
- this.taskMap.set(t, obj);
35
- });
36
- const createTasksListr = (tasks) => {
37
- return tasks.map((task) => {
38
- return {
39
- title: task.name,
40
- skip: () => task.mode === 'skip',
41
- task: async () => {
42
- var _a;
43
- return await ((_a = this.taskMap.get(task)) === null || _a === void 0 ? void 0 : _a.promise);
44
- },
45
- };
46
- });
47
- };
48
- const listrOptions = {
49
- exitOnError: false,
50
- };
51
- this.listr = new Listr(files.map((file) => {
52
- return {
53
- title: this.relative(file.filepath),
54
- task: () => {
55
- if (file.error)
56
- throw file.error;
57
- const suites = file.suites.filter(i => i.tasks.length);
58
- if (!suites.length)
59
- throw new Error('No tasks found');
60
- return new Listr(suites.flatMap((suite) => {
61
- if (!suite.name)
62
- return createTasksListr(suite.tasks);
63
- return [{
64
- title: suite.name,
65
- skip: () => suite.mode !== 'run',
66
- task: () => new Listr(createTasksListr(suite.tasks), listrOptions),
67
- }];
68
- }), listrOptions);
69
- },
70
- };
71
- }), listrOptions);
72
- this.listrPromise = this.listr.run().catch(() => { });
73
- }
74
- onTaskEnd(task) {
75
- var _a, _b;
76
- if (task.state === 'fail')
77
- (_a = this.taskMap.get(task)) === null || _a === void 0 ? void 0 : _a.reject(task.error);
78
- else
79
- (_b = this.taskMap.get(task)) === null || _b === void 0 ? void 0 : _b.resolve();
80
- }
81
- async onFinished(ctx, files = ctx.files) {
82
- var _a;
83
- await this.listrPromise;
84
- this.end = performance.now();
85
- console.log();
86
- const snapshot = ctx.snapshotManager.report();
87
- if (snapshot)
88
- console.log(snapshot.join('\n'));
89
- const suites = files.flatMap(i => i.suites);
90
- const tasks = suites.flatMap(i => i.tasks);
91
- const failedFiles = files.filter(i => i.error);
92
- const failedSuites = suites.filter(i => i.error);
93
- const runnable = tasks.filter(i => i.state === 'pass' || i.state === 'fail');
94
- const passed = tasks.filter(i => i.state === 'pass');
95
- const failed = tasks.filter(i => i.state === 'fail');
96
- const skipped = tasks.filter(i => i.state === 'skip');
97
- const todo = tasks.filter(i => i.state === 'todo');
98
- if (failedFiles.length) {
99
- console.error(c.red(c.bold(`\nFailed to parse ${failedFiles.length} files:`)));
100
- for (const file of failedFiles)
101
- console.error(c.red(`- ${file.filepath}`));
102
- console.log();
103
- for (const file of failedFiles) {
104
- await printError(file.error);
105
- console.log();
106
- }
107
- }
108
- if (failedSuites.length) {
109
- console.error(c.bold(c.red(`\nFailed to run ${failedSuites.length} suites:`)));
110
- for (const suite of failedSuites) {
111
- console.error(c.red(`\n- ${(_a = suite.file) === null || _a === void 0 ? void 0 : _a.filepath} > ${suite.name}`));
112
- await printError(suite.error);
113
- console.log();
114
- }
115
- }
116
- if (failed.length) {
117
- console.error(c.bold(c.red(`\nFailed Tests (${failed.length})`)));
118
- for (const task of failed) {
119
- console.error(`${c.red(`\n${CROSS + c.inverse(' FAIL ')}`)} ${[task.suite.name, task.name].filter(Boolean).join(' > ')}`);
120
- await printError(task.error);
121
- console.log();
122
- }
123
- }
124
- console.log(c.bold(c.green(`Passed ${passed.length} / ${runnable.length}`)));
125
- if (failed.length)
126
- console.log(c.bold(c.red(`Failed ${failed.length} / ${runnable.length}`)));
127
- if (skipped.length)
128
- console.log(c.yellow(`Skipped ${skipped.length}`));
129
- if (todo.length)
130
- console.log(c.dim(`Todo ${todo.length}`));
131
- console.log(`Time ${(this.end - this.start).toFixed(2)}ms`);
132
- }
133
- async onWatcherStart(ctx) {
134
- await this.listrPromise;
135
- const failed = ctx.tasks.filter(i => i.state === 'fail');
136
- if (failed.length)
137
- console.log(`\n${c.bold(c.inverse(c.red(' FAIL ')))}${c.red(` ${failed.length} tests failed. Watching for file changes...`)}`);
138
- else
139
- console.log(`\n${c.bold(c.inverse(c.green(' PASS ')))}${c.green(' Watching for file changes...')}`);
140
- }
141
- async onWatcherRerun(files, trigger) {
142
- await this.listrPromise;
143
- console.clear();
144
- console.log(c.blue('Re-running tests...') + c.dim(` [ ${this.relative(trigger)} ]\n`));
145
- }
146
- // TODO:
147
- onSnapshotUpdate() {
148
- }
149
- }
@@ -1,9 +0,0 @@
1
- export declare function printError(error: unknown): Promise<void>;
2
- interface Poisition {
3
- line: number;
4
- column: number;
5
- }
6
- export declare function posToNumber(source: string, pos: number | Poisition): number;
7
- export declare function numberToPos(source: string, offset: number | Poisition): Poisition;
8
- export declare function generateCodeFrame(source: string, start?: number | Poisition, end?: number, range?: number): string;
9
- export {};