vitest 0.0.97 → 0.0.101
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/LICENSE.md +1835 -0
- package/dist/_commonjsHelpers-bdec4bbd.js +7 -0
- package/dist/cli.js +13 -22
- package/dist/{constants-9cfa4d7b.js → constants-a1417084.js} +2 -2
- package/dist/entry.js +111 -18
- package/dist/error-d97062cd.js +4737 -0
- package/dist/{global-473089f7.js → global-5b58e48f.js} +7 -4
- package/dist/{index-e7a421bb.js → index-0c3a317d.js} +2 -1
- package/dist/{index-ca1a0bda.js → index-37755855.js} +2628 -151
- package/dist/{index-5cc247ff.js → index-825cb54c.js} +2 -3
- package/dist/{index-368448f4.js → index-f580d714.js} +1 -1
- package/dist/index.d.ts +32 -111
- package/dist/index.js +6 -2
- package/dist/{middleware-bf0f818d.js → middleware-05e03d95.js} +5 -2
- package/dist/node.js +11 -10
- package/dist/suite-4f3fb0b5.js +201 -0
- package/dist/{utils-70b78878.js → utils-c8e62373.js} +187 -3
- package/dist/utils.js +2 -1
- package/dist/worker.js +6 -4
- package/package.json +13 -12
- package/{bin/vitest.mjs → vitest.mjs} +3 -4
- package/LICENSE +0 -22
- package/dist/error-7405ce56.js +0 -1416
- package/dist/suite-b8c6cb53.js +0 -236
|
@@ -1,8 +1,7 @@
|
|
|
1
|
+
import { c as commonjsGlobal } from './_commonjsHelpers-bdec4bbd.js';
|
|
1
2
|
import assert$1 from 'assert';
|
|
2
3
|
import require$$2 from 'events';
|
|
3
4
|
|
|
4
|
-
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
5
|
-
|
|
6
5
|
var onetime$2 = {exports: {}};
|
|
7
6
|
|
|
8
7
|
var mimicFn$2 = {exports: {}};
|
|
@@ -328,4 +327,4 @@ if (!processOk(process$1)) {
|
|
|
328
327
|
|
|
329
328
|
var signalExit = signalExit$1.exports;
|
|
330
329
|
|
|
331
|
-
export { signalExit$1 as a, onetime$2 as b,
|
|
330
|
+
export { signalExit$1 as a, onetime$2 as b, onetime$1 as o, signalExit as s };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { g as getCurrentSuite, w as withTimeout, a as getDefaultHookTimeout, s as suite, t as test, d as describe, i as it } from './suite-
|
|
1
|
+
import { g as getCurrentSuite, w as withTimeout, a as getDefaultHookTimeout, s as suite, t as test, d as describe, i as it } from './suite-4f3fb0b5.js';
|
|
2
2
|
import chai, { util, assert, should, expect } from 'chai';
|
|
3
3
|
import * as tinyspy from 'tinyspy';
|
|
4
4
|
import { spies } from 'tinyspy';
|
package/dist/index.d.ts
CHANGED
|
@@ -173,6 +173,12 @@ interface UserConsoleLog {
|
|
|
173
173
|
taskId?: string;
|
|
174
174
|
}
|
|
175
175
|
|
|
176
|
+
declare type ChainableFunction<T extends string, Args extends any[], R = any> = {
|
|
177
|
+
(...args: Args): R;
|
|
178
|
+
} & {
|
|
179
|
+
[x in T]: ChainableFunction<T, Args, R>;
|
|
180
|
+
};
|
|
181
|
+
|
|
176
182
|
declare type RunMode = 'run' | 'skip' | 'only' | 'todo';
|
|
177
183
|
declare type TaskState = RunMode | 'pass' | 'fail';
|
|
178
184
|
declare type ComputeMode = 'serial' | 'concurrent';
|
|
@@ -203,36 +209,16 @@ interface Test extends TaskBase {
|
|
|
203
209
|
type: 'test';
|
|
204
210
|
suite: Suite;
|
|
205
211
|
result?: TaskResult;
|
|
212
|
+
fails?: boolean;
|
|
206
213
|
}
|
|
207
214
|
declare type Task = Test | Suite | File;
|
|
208
215
|
declare type DoneCallback = (error?: any) => void;
|
|
209
216
|
declare type TestFunction = (done: DoneCallback) => Awaitable<void>;
|
|
210
|
-
declare type
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
todo: (name: string) => void;
|
|
216
|
-
}
|
|
217
|
-
interface OnlyCollector {
|
|
218
|
-
(name: string, fn: TestFunction, timeout?: number): void;
|
|
219
|
-
concurrent: TestCollectorFn;
|
|
220
|
-
}
|
|
221
|
-
interface SkipCollector {
|
|
222
|
-
(name: string, fn: TestFunction, timeout?: number): void;
|
|
223
|
-
concurrent: TestCollectorFn;
|
|
224
|
-
}
|
|
225
|
-
interface TodoCollector {
|
|
226
|
-
(name: string): void;
|
|
227
|
-
concurrent: (name: string) => void;
|
|
228
|
-
}
|
|
229
|
-
interface TestCollector {
|
|
230
|
-
(name: string, fn: TestFunction, timeout?: number): void;
|
|
231
|
-
concurrent: ConcurrentCollector;
|
|
232
|
-
only: OnlyCollector;
|
|
233
|
-
skip: SkipCollector;
|
|
234
|
-
todo: TodoCollector;
|
|
235
|
-
}
|
|
217
|
+
declare type TestCollector = ChainableFunction<'concurrent' | 'only' | 'skip' | 'todo' | 'fails', [
|
|
218
|
+
name: string,
|
|
219
|
+
fn?: TestFunction,
|
|
220
|
+
timeout?: number
|
|
221
|
+
], void>;
|
|
236
222
|
declare type HookListener<T extends any[]> = (...args: T) => Awaitable<void>;
|
|
237
223
|
interface SuiteHooks {
|
|
238
224
|
beforeAll: HookListener<[Suite]>[];
|
|
@@ -420,6 +406,12 @@ interface InlineConfig {
|
|
|
420
406
|
* Path to setup files
|
|
421
407
|
*/
|
|
422
408
|
setupFiles?: string | string[];
|
|
409
|
+
/**
|
|
410
|
+
* Pattern of file paths to be ignore from triggering watch rerun
|
|
411
|
+
*
|
|
412
|
+
* @default ['**\/node_modules\/**', '**\/dist/**']
|
|
413
|
+
*/
|
|
414
|
+
watchIgnore?: (string | RegExp)[];
|
|
423
415
|
/**
|
|
424
416
|
* Open Vitest UI
|
|
425
417
|
* @internal WIP
|
|
@@ -446,7 +438,14 @@ interface UserConfig extends InlineConfig {
|
|
|
446
438
|
* - `vite.config.ts`
|
|
447
439
|
*/
|
|
448
440
|
config?: string | undefined;
|
|
441
|
+
/**
|
|
442
|
+
* Use happy-dom
|
|
443
|
+
*/
|
|
449
444
|
dom?: boolean;
|
|
445
|
+
/**
|
|
446
|
+
* Do not watch
|
|
447
|
+
*/
|
|
448
|
+
run?: boolean;
|
|
450
449
|
}
|
|
451
450
|
interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters'> {
|
|
452
451
|
config?: string;
|
|
@@ -479,90 +478,10 @@ declare type RpcPayload<T extends keyof RpcMap = keyof RpcMap> = {
|
|
|
479
478
|
args: RpcMap[T][0];
|
|
480
479
|
};
|
|
481
480
|
|
|
482
|
-
declare const suite:
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
skip(suiteName: string, factory?: TestFactory | undefined): SuiteCollector;
|
|
487
|
-
only(suiteName: string, factory?: TestFactory | undefined): SuiteCollector;
|
|
488
|
-
todo(suiteName: string): SuiteCollector;
|
|
489
|
-
};
|
|
490
|
-
skip: {
|
|
491
|
-
(suiteName: string, factory?: TestFactory | undefined): SuiteCollector;
|
|
492
|
-
concurrent: (suiteName: string, factory?: TestFactory | undefined) => SuiteCollector;
|
|
493
|
-
};
|
|
494
|
-
only: {
|
|
495
|
-
(suiteName: string, factory?: TestFactory | undefined): SuiteCollector;
|
|
496
|
-
concurrent: (suiteName: string, factory?: TestFactory | undefined) => SuiteCollector;
|
|
497
|
-
};
|
|
498
|
-
todo: {
|
|
499
|
-
(suiteName: string): SuiteCollector;
|
|
500
|
-
concurrent: (suiteName: string) => SuiteCollector;
|
|
501
|
-
};
|
|
502
|
-
};
|
|
503
|
-
declare const test: {
|
|
504
|
-
(name: string, fn: TestFunction, timeout?: number | undefined): void;
|
|
505
|
-
concurrent: {
|
|
506
|
-
(name: string, fn: TestFunction, timeout?: number | undefined): void;
|
|
507
|
-
skip(name: string, fn: TestFunction, timeout?: number | undefined): void;
|
|
508
|
-
only(name: string, fn: TestFunction, timeout?: number | undefined): void;
|
|
509
|
-
todo(name: string): void;
|
|
510
|
-
};
|
|
511
|
-
skip: {
|
|
512
|
-
(name: string, fn: TestFunction, timeout?: number | undefined): void;
|
|
513
|
-
concurrent(name: string, fn: TestFunction, timeout?: number | undefined): void;
|
|
514
|
-
};
|
|
515
|
-
only: {
|
|
516
|
-
(name: string, fn: TestFunction, timeout?: number | undefined): void;
|
|
517
|
-
concurrent(name: string, fn: TestFunction, timeout?: number | undefined): void;
|
|
518
|
-
};
|
|
519
|
-
todo: {
|
|
520
|
-
(name: string): void;
|
|
521
|
-
concurrent(name: string): void;
|
|
522
|
-
};
|
|
523
|
-
};
|
|
524
|
-
declare const describe: {
|
|
525
|
-
(suiteName: string, factory?: TestFactory | undefined): SuiteCollector;
|
|
526
|
-
concurrent: {
|
|
527
|
-
(suiteName: string, factory?: TestFactory | undefined): SuiteCollector;
|
|
528
|
-
skip(suiteName: string, factory?: TestFactory | undefined): SuiteCollector;
|
|
529
|
-
only(suiteName: string, factory?: TestFactory | undefined): SuiteCollector;
|
|
530
|
-
todo(suiteName: string): SuiteCollector;
|
|
531
|
-
};
|
|
532
|
-
skip: {
|
|
533
|
-
(suiteName: string, factory?: TestFactory | undefined): SuiteCollector;
|
|
534
|
-
concurrent: (suiteName: string, factory?: TestFactory | undefined) => SuiteCollector;
|
|
535
|
-
};
|
|
536
|
-
only: {
|
|
537
|
-
(suiteName: string, factory?: TestFactory | undefined): SuiteCollector;
|
|
538
|
-
concurrent: (suiteName: string, factory?: TestFactory | undefined) => SuiteCollector;
|
|
539
|
-
};
|
|
540
|
-
todo: {
|
|
541
|
-
(suiteName: string): SuiteCollector;
|
|
542
|
-
concurrent: (suiteName: string) => SuiteCollector;
|
|
543
|
-
};
|
|
544
|
-
};
|
|
545
|
-
declare const it: {
|
|
546
|
-
(name: string, fn: TestFunction, timeout?: number | undefined): void;
|
|
547
|
-
concurrent: {
|
|
548
|
-
(name: string, fn: TestFunction, timeout?: number | undefined): void;
|
|
549
|
-
skip(name: string, fn: TestFunction, timeout?: number | undefined): void;
|
|
550
|
-
only(name: string, fn: TestFunction, timeout?: number | undefined): void;
|
|
551
|
-
todo(name: string): void;
|
|
552
|
-
};
|
|
553
|
-
skip: {
|
|
554
|
-
(name: string, fn: TestFunction, timeout?: number | undefined): void;
|
|
555
|
-
concurrent(name: string, fn: TestFunction, timeout?: number | undefined): void;
|
|
556
|
-
};
|
|
557
|
-
only: {
|
|
558
|
-
(name: string, fn: TestFunction, timeout?: number | undefined): void;
|
|
559
|
-
concurrent(name: string, fn: TestFunction, timeout?: number | undefined): void;
|
|
560
|
-
};
|
|
561
|
-
todo: {
|
|
562
|
-
(name: string): void;
|
|
563
|
-
concurrent(name: string): void;
|
|
564
|
-
};
|
|
565
|
-
};
|
|
481
|
+
declare const suite: ChainableFunction<"skip" | "only" | "todo" | "concurrent", [name: string, factory?: TestFactory | undefined], SuiteCollector>;
|
|
482
|
+
declare const test: TestCollector;
|
|
483
|
+
declare const describe: ChainableFunction<"skip" | "only" | "todo" | "concurrent", [name: string, factory?: TestFactory | undefined], SuiteCollector>;
|
|
484
|
+
declare const it: TestCollector;
|
|
566
485
|
declare global {
|
|
567
486
|
namespace NodeJS {
|
|
568
487
|
interface Process {
|
|
@@ -651,12 +570,14 @@ declare class VitestUtils {
|
|
|
651
570
|
declare const vitest: VitestUtils;
|
|
652
571
|
declare const vi: VitestUtils;
|
|
653
572
|
|
|
573
|
+
declare type VitestInlineConfig = InlineConfig;
|
|
574
|
+
|
|
654
575
|
declare module 'vite' {
|
|
655
576
|
interface UserConfig {
|
|
656
577
|
/**
|
|
657
578
|
* Options for Vitest
|
|
658
579
|
*/
|
|
659
|
-
test?:
|
|
580
|
+
test?: VitestInlineConfig;
|
|
660
581
|
}
|
|
661
582
|
}
|
|
662
583
|
declare global {
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
export { d as describe, i as it, s as suite, t as test } from './suite-
|
|
2
|
-
export { a as afterAll, d as afterEach, b as beforeAll, c as beforeEach, f as fn, s as spyOn, e as vi, v as vitest } from './index-
|
|
1
|
+
export { d as describe, i as it, s as suite, t as test } from './suite-4f3fb0b5.js';
|
|
2
|
+
export { a as afterAll, d as afterEach, b as beforeAll, c as beforeEach, f as fn, s as spyOn, e as vi, v as vitest } from './index-f580d714.js';
|
|
3
3
|
export { assert, default as chai, expect, should } from 'chai';
|
|
4
4
|
import './index-9e71c815.js';
|
|
5
|
+
import './utils-c8e62373.js';
|
|
6
|
+
import 'tty';
|
|
7
|
+
import 'local-pkg';
|
|
8
|
+
import 'path';
|
|
5
9
|
import 'tinyspy';
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import { A as API_PATH } from './constants-
|
|
2
|
-
import 'path';
|
|
1
|
+
import { A as API_PATH } from './constants-a1417084.js';
|
|
3
2
|
import 'url';
|
|
3
|
+
import './utils-c8e62373.js';
|
|
4
|
+
import 'tty';
|
|
5
|
+
import 'local-pkg';
|
|
6
|
+
import 'path';
|
|
4
7
|
|
|
5
8
|
/*! (c) 2020 Andrea Giammarchi */
|
|
6
9
|
|
package/dist/node.js
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
export { c as createVitest } from './index-
|
|
1
|
+
export { c as createVitest } from './index-37755855.js';
|
|
2
|
+
import './utils-c8e62373.js';
|
|
3
|
+
import 'tty';
|
|
4
|
+
import 'local-pkg';
|
|
2
5
|
import 'path';
|
|
3
6
|
import 'vite';
|
|
4
7
|
import 'process';
|
|
5
8
|
import 'fs';
|
|
6
|
-
import '
|
|
9
|
+
import 'os';
|
|
7
10
|
import 'util';
|
|
8
|
-
import '
|
|
11
|
+
import 'stream';
|
|
12
|
+
import 'events';
|
|
13
|
+
import './constants-a1417084.js';
|
|
9
14
|
import 'url';
|
|
10
|
-
import './utils-70b78878.js';
|
|
11
|
-
import 'tty';
|
|
12
|
-
import 'local-pkg';
|
|
13
15
|
import 'perf_hooks';
|
|
14
|
-
import './error-
|
|
15
|
-
import '
|
|
16
|
-
import './
|
|
16
|
+
import './error-d97062cd.js';
|
|
17
|
+
import './index-825cb54c.js';
|
|
18
|
+
import './_commonjsHelpers-bdec4bbd.js';
|
|
17
19
|
import 'assert';
|
|
18
|
-
import 'events';
|
|
19
20
|
import 'worker_threads';
|
|
20
21
|
import 'tinypool';
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { n as nanoid } from './index-9e71c815.js';
|
|
2
|
+
import { n as noop } from './utils-c8e62373.js';
|
|
3
|
+
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __defProps = Object.defineProperties;
|
|
6
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
10
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
11
|
+
var __spreadValues = (a, b) => {
|
|
12
|
+
for (var prop in b || (b = {}))
|
|
13
|
+
if (__hasOwnProp.call(b, prop))
|
|
14
|
+
__defNormalProp(a, prop, b[prop]);
|
|
15
|
+
if (__getOwnPropSymbols)
|
|
16
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
17
|
+
if (__propIsEnum.call(b, prop))
|
|
18
|
+
__defNormalProp(a, prop, b[prop]);
|
|
19
|
+
}
|
|
20
|
+
return a;
|
|
21
|
+
};
|
|
22
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
23
|
+
function createChainable(keys, fn) {
|
|
24
|
+
function create(obj) {
|
|
25
|
+
const chain2 = function(...args) {
|
|
26
|
+
return fn.apply(obj, args);
|
|
27
|
+
};
|
|
28
|
+
for (const key of keys) {
|
|
29
|
+
Object.defineProperty(chain2, key, {
|
|
30
|
+
get() {
|
|
31
|
+
return create(__spreadProps(__spreadValues({}, obj), { [key]: true }));
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
return chain2;
|
|
36
|
+
}
|
|
37
|
+
const chain = create({});
|
|
38
|
+
chain.fn = fn;
|
|
39
|
+
return chain;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const context = {
|
|
43
|
+
tasks: [],
|
|
44
|
+
currentSuite: null
|
|
45
|
+
};
|
|
46
|
+
function collectTask(task) {
|
|
47
|
+
var _a;
|
|
48
|
+
(_a = context.currentSuite) == null ? void 0 : _a.tasks.push(task);
|
|
49
|
+
}
|
|
50
|
+
async function runWithSuite(suite, fn) {
|
|
51
|
+
const prev = context.currentSuite;
|
|
52
|
+
context.currentSuite = suite;
|
|
53
|
+
await fn();
|
|
54
|
+
context.currentSuite = prev;
|
|
55
|
+
}
|
|
56
|
+
function getDefaultTestTimeout() {
|
|
57
|
+
return process.__vitest_worker__.config.testTimeout;
|
|
58
|
+
}
|
|
59
|
+
function getDefaultHookTimeout() {
|
|
60
|
+
return process.__vitest_worker__.config.hookTimeout;
|
|
61
|
+
}
|
|
62
|
+
function withTimeout(fn, _timeout) {
|
|
63
|
+
const timeout = _timeout ?? getDefaultTestTimeout();
|
|
64
|
+
if (timeout <= 0 || timeout === Infinity)
|
|
65
|
+
return fn;
|
|
66
|
+
return (...args) => {
|
|
67
|
+
return Promise.race([fn(...args), new Promise((resolve, reject) => {
|
|
68
|
+
const timer = setTimeout(() => {
|
|
69
|
+
clearTimeout(timer);
|
|
70
|
+
reject(new Error(`Test timed out in ${timeout}ms.`));
|
|
71
|
+
}, timeout);
|
|
72
|
+
timer.unref();
|
|
73
|
+
})]);
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function ensureAsyncTest(fn) {
|
|
77
|
+
if (!fn.length)
|
|
78
|
+
return fn;
|
|
79
|
+
return () => new Promise((resolve, reject) => {
|
|
80
|
+
const done = (...args) => args[0] ? reject(args[0]) : resolve();
|
|
81
|
+
fn(done);
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
function normalizeTest(fn, timeout) {
|
|
85
|
+
return withTimeout(ensureAsyncTest(fn), timeout);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const fnMap = /* @__PURE__ */ new WeakMap();
|
|
89
|
+
const hooksMap = /* @__PURE__ */ new WeakMap();
|
|
90
|
+
function setFn(key, fn) {
|
|
91
|
+
fnMap.set(key, fn);
|
|
92
|
+
}
|
|
93
|
+
function getFn(key) {
|
|
94
|
+
return fnMap.get(key);
|
|
95
|
+
}
|
|
96
|
+
function setHooks(key, hooks) {
|
|
97
|
+
hooksMap.set(key, hooks);
|
|
98
|
+
}
|
|
99
|
+
function getHooks(key) {
|
|
100
|
+
return hooksMap.get(key);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const suite = createSuite();
|
|
104
|
+
const test = createChainable(["concurrent", "skip", "only", "todo", "fails"], function(name, fn, timeout) {
|
|
105
|
+
getCurrentSuite().test.fn.call(this, name, fn, timeout);
|
|
106
|
+
});
|
|
107
|
+
const describe = suite;
|
|
108
|
+
const it = test;
|
|
109
|
+
const defaultSuite = suite("");
|
|
110
|
+
function clearContext() {
|
|
111
|
+
context.tasks.length = 0;
|
|
112
|
+
defaultSuite.clear();
|
|
113
|
+
context.currentSuite = defaultSuite;
|
|
114
|
+
}
|
|
115
|
+
function getCurrentSuite() {
|
|
116
|
+
return context.currentSuite || defaultSuite;
|
|
117
|
+
}
|
|
118
|
+
function createSuiteHooks() {
|
|
119
|
+
return {
|
|
120
|
+
beforeAll: [],
|
|
121
|
+
afterAll: [],
|
|
122
|
+
beforeEach: [],
|
|
123
|
+
afterEach: []
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
function createSuiteCollector(name, factory = () => {
|
|
127
|
+
}, mode, suiteComputeMode) {
|
|
128
|
+
const tasks = [];
|
|
129
|
+
const factoryQueue = [];
|
|
130
|
+
let suite2;
|
|
131
|
+
initSuite();
|
|
132
|
+
const test2 = createChainable(["concurrent", "skip", "only", "todo", "fails"], function(name2, fn, timeout) {
|
|
133
|
+
const mode2 = this.only ? "only" : this.skip ? "skip" : this.todo ? "todo" : "run";
|
|
134
|
+
const computeMode = this.concurrent ? "concurrent" : void 0;
|
|
135
|
+
const test3 = {
|
|
136
|
+
id: nanoid(),
|
|
137
|
+
type: "test",
|
|
138
|
+
name: name2,
|
|
139
|
+
mode: mode2,
|
|
140
|
+
computeMode: computeMode ?? (suiteComputeMode ?? "serial"),
|
|
141
|
+
suite: void 0,
|
|
142
|
+
fails: this.fails
|
|
143
|
+
};
|
|
144
|
+
setFn(test3, normalizeTest(fn || noop, timeout));
|
|
145
|
+
tasks.push(test3);
|
|
146
|
+
});
|
|
147
|
+
const collector = {
|
|
148
|
+
type: "collector",
|
|
149
|
+
name,
|
|
150
|
+
mode,
|
|
151
|
+
test: test2,
|
|
152
|
+
tasks,
|
|
153
|
+
collect,
|
|
154
|
+
clear,
|
|
155
|
+
on: addHook
|
|
156
|
+
};
|
|
157
|
+
function addHook(name2, ...fn) {
|
|
158
|
+
getHooks(suite2)[name2].push(...fn);
|
|
159
|
+
}
|
|
160
|
+
function initSuite() {
|
|
161
|
+
suite2 = {
|
|
162
|
+
id: nanoid(),
|
|
163
|
+
type: "suite",
|
|
164
|
+
computeMode: "serial",
|
|
165
|
+
name,
|
|
166
|
+
mode,
|
|
167
|
+
tasks: []
|
|
168
|
+
};
|
|
169
|
+
setHooks(suite2, createSuiteHooks());
|
|
170
|
+
}
|
|
171
|
+
function clear() {
|
|
172
|
+
tasks.length = 0;
|
|
173
|
+
factoryQueue.length = 0;
|
|
174
|
+
initSuite();
|
|
175
|
+
}
|
|
176
|
+
async function collect(file) {
|
|
177
|
+
factoryQueue.length = 0;
|
|
178
|
+
if (factory)
|
|
179
|
+
await runWithSuite(collector, () => factory(test2));
|
|
180
|
+
const allChildren = await Promise.all([...factoryQueue, ...tasks].map((i) => i.type === "collector" ? i.collect(file) : i));
|
|
181
|
+
suite2.file = file;
|
|
182
|
+
suite2.tasks = allChildren;
|
|
183
|
+
allChildren.forEach((task) => {
|
|
184
|
+
task.suite = suite2;
|
|
185
|
+
if (file)
|
|
186
|
+
task.file = file;
|
|
187
|
+
});
|
|
188
|
+
return suite2;
|
|
189
|
+
}
|
|
190
|
+
collectTask(collector);
|
|
191
|
+
return collector;
|
|
192
|
+
}
|
|
193
|
+
function createSuite() {
|
|
194
|
+
return createChainable(["concurrent", "skip", "only", "todo"], function(name, factory) {
|
|
195
|
+
const mode = this.only ? "only" : this.skip ? "skip" : this.todo ? "todo" : "run";
|
|
196
|
+
const computeMode = this.concurrent ? "concurrent" : void 0;
|
|
197
|
+
return createSuiteCollector(name, factory, mode, computeMode);
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export { getDefaultHookTimeout as a, setHooks as b, createSuiteHooks as c, describe as d, clearContext as e, defaultSuite as f, getCurrentSuite as g, context as h, it as i, getHooks as j, getFn as k, suite as s, test as t, withTimeout as w };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import require$$0 from 'tty';
|
|
2
2
|
import { isPackageExists } from 'local-pkg';
|
|
3
|
+
import path from 'path';
|
|
3
4
|
|
|
4
5
|
var picocolors = {exports: {}};
|
|
5
6
|
|
|
@@ -64,6 +65,189 @@ picocolors.exports.createColors = createColors;
|
|
|
64
65
|
|
|
65
66
|
var c = picocolors.exports;
|
|
66
67
|
|
|
68
|
+
function normalizeWindowsPath(input = "") {
|
|
69
|
+
if (!input.includes("\\")) {
|
|
70
|
+
return input;
|
|
71
|
+
}
|
|
72
|
+
return input.replace(/\\/g, "/");
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const _UNC_REGEX = /^[/][/]/;
|
|
76
|
+
const _UNC_DRIVE_REGEX = /^[/][/]([.]{1,2}[/])?([a-zA-Z]):[/]/;
|
|
77
|
+
const _IS_ABSOLUTE_RE = /^\/|^\\|^[a-zA-Z]:[/\\]/;
|
|
78
|
+
const sep = "/";
|
|
79
|
+
const delimiter = ":";
|
|
80
|
+
const normalize = function(path2) {
|
|
81
|
+
if (path2.length === 0) {
|
|
82
|
+
return ".";
|
|
83
|
+
}
|
|
84
|
+
path2 = normalizeWindowsPath(path2);
|
|
85
|
+
const isUNCPath = path2.match(_UNC_REGEX);
|
|
86
|
+
const hasUNCDrive = isUNCPath && path2.match(_UNC_DRIVE_REGEX);
|
|
87
|
+
const isPathAbsolute = isAbsolute(path2);
|
|
88
|
+
const trailingSeparator = path2[path2.length - 1] === "/";
|
|
89
|
+
path2 = normalizeString(path2, !isPathAbsolute);
|
|
90
|
+
if (path2.length === 0) {
|
|
91
|
+
if (isPathAbsolute) {
|
|
92
|
+
return "/";
|
|
93
|
+
}
|
|
94
|
+
return trailingSeparator ? "./" : ".";
|
|
95
|
+
}
|
|
96
|
+
if (trailingSeparator) {
|
|
97
|
+
path2 += "/";
|
|
98
|
+
}
|
|
99
|
+
if (isUNCPath) {
|
|
100
|
+
if (hasUNCDrive) {
|
|
101
|
+
return `//./${path2}`;
|
|
102
|
+
}
|
|
103
|
+
return `//${path2}`;
|
|
104
|
+
}
|
|
105
|
+
return isPathAbsolute && !isAbsolute(path2) ? `/${path2}` : path2;
|
|
106
|
+
};
|
|
107
|
+
const join = function(...args) {
|
|
108
|
+
if (args.length === 0) {
|
|
109
|
+
return ".";
|
|
110
|
+
}
|
|
111
|
+
let joined;
|
|
112
|
+
for (let i = 0; i < args.length; ++i) {
|
|
113
|
+
const arg = args[i];
|
|
114
|
+
if (arg.length > 0) {
|
|
115
|
+
if (joined === void 0) {
|
|
116
|
+
joined = arg;
|
|
117
|
+
} else {
|
|
118
|
+
joined += `/${arg}`;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
if (joined === void 0) {
|
|
123
|
+
return ".";
|
|
124
|
+
}
|
|
125
|
+
return normalize(joined);
|
|
126
|
+
};
|
|
127
|
+
const resolve = function(...args) {
|
|
128
|
+
args = args.map((arg) => normalizeWindowsPath(arg));
|
|
129
|
+
let resolvedPath = "";
|
|
130
|
+
let resolvedAbsolute = false;
|
|
131
|
+
for (let i = args.length - 1; i >= -1 && !resolvedAbsolute; i--) {
|
|
132
|
+
const path2 = i >= 0 ? args[i] : process.cwd();
|
|
133
|
+
if (path2.length === 0) {
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
resolvedPath = `${path2}/${resolvedPath}`;
|
|
137
|
+
resolvedAbsolute = isAbsolute(path2);
|
|
138
|
+
}
|
|
139
|
+
resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);
|
|
140
|
+
if (resolvedAbsolute && !isAbsolute(resolvedPath)) {
|
|
141
|
+
return `/${resolvedPath}`;
|
|
142
|
+
}
|
|
143
|
+
return resolvedPath.length > 0 ? resolvedPath : ".";
|
|
144
|
+
};
|
|
145
|
+
function normalizeString(path2, allowAboveRoot) {
|
|
146
|
+
let res = "";
|
|
147
|
+
let lastSegmentLength = 0;
|
|
148
|
+
let lastSlash = -1;
|
|
149
|
+
let dots = 0;
|
|
150
|
+
let char = null;
|
|
151
|
+
for (let i = 0; i <= path2.length; ++i) {
|
|
152
|
+
if (i < path2.length) {
|
|
153
|
+
char = path2[i];
|
|
154
|
+
} else if (char === "/") {
|
|
155
|
+
break;
|
|
156
|
+
} else {
|
|
157
|
+
char = "/";
|
|
158
|
+
}
|
|
159
|
+
if (char === "/") {
|
|
160
|
+
if (lastSlash === i - 1 || dots === 1) ; else if (dots === 2) {
|
|
161
|
+
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
|
|
162
|
+
if (res.length > 2) {
|
|
163
|
+
const lastSlashIndex = res.lastIndexOf("/");
|
|
164
|
+
if (lastSlashIndex === -1) {
|
|
165
|
+
res = "";
|
|
166
|
+
lastSegmentLength = 0;
|
|
167
|
+
} else {
|
|
168
|
+
res = res.slice(0, lastSlashIndex);
|
|
169
|
+
lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
|
|
170
|
+
}
|
|
171
|
+
lastSlash = i;
|
|
172
|
+
dots = 0;
|
|
173
|
+
continue;
|
|
174
|
+
} else if (res.length !== 0) {
|
|
175
|
+
res = "";
|
|
176
|
+
lastSegmentLength = 0;
|
|
177
|
+
lastSlash = i;
|
|
178
|
+
dots = 0;
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
if (allowAboveRoot) {
|
|
183
|
+
res += res.length > 0 ? "/.." : "..";
|
|
184
|
+
lastSegmentLength = 2;
|
|
185
|
+
}
|
|
186
|
+
} else {
|
|
187
|
+
if (res.length > 0) {
|
|
188
|
+
res += `/${path2.slice(lastSlash + 1, i)}`;
|
|
189
|
+
} else {
|
|
190
|
+
res = path2.slice(lastSlash + 1, i);
|
|
191
|
+
}
|
|
192
|
+
lastSegmentLength = i - lastSlash - 1;
|
|
193
|
+
}
|
|
194
|
+
lastSlash = i;
|
|
195
|
+
dots = 0;
|
|
196
|
+
} else if (char === "." && dots !== -1) {
|
|
197
|
+
++dots;
|
|
198
|
+
} else {
|
|
199
|
+
dots = -1;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
return res;
|
|
203
|
+
}
|
|
204
|
+
const isAbsolute = function(p) {
|
|
205
|
+
return _IS_ABSOLUTE_RE.test(p);
|
|
206
|
+
};
|
|
207
|
+
const toNamespacedPath = function(p) {
|
|
208
|
+
return normalizeWindowsPath(p);
|
|
209
|
+
};
|
|
210
|
+
const extname = function(p) {
|
|
211
|
+
return path.posix.extname(normalizeWindowsPath(p));
|
|
212
|
+
};
|
|
213
|
+
const relative = function(from, to) {
|
|
214
|
+
return path.posix.relative(normalizeWindowsPath(from), normalizeWindowsPath(to));
|
|
215
|
+
};
|
|
216
|
+
const dirname = function(p) {
|
|
217
|
+
return path.posix.dirname(normalizeWindowsPath(p));
|
|
218
|
+
};
|
|
219
|
+
const format = function(p) {
|
|
220
|
+
return normalizeWindowsPath(path.posix.format(p));
|
|
221
|
+
};
|
|
222
|
+
const basename = function(p, ext) {
|
|
223
|
+
return path.posix.basename(normalizeWindowsPath(p), ext);
|
|
224
|
+
};
|
|
225
|
+
const parse = function(p) {
|
|
226
|
+
return path.posix.parse(normalizeWindowsPath(p));
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
const _path = /*#__PURE__*/Object.freeze({
|
|
230
|
+
__proto__: null,
|
|
231
|
+
sep: sep,
|
|
232
|
+
delimiter: delimiter,
|
|
233
|
+
normalize: normalize,
|
|
234
|
+
join: join,
|
|
235
|
+
resolve: resolve,
|
|
236
|
+
normalizeString: normalizeString,
|
|
237
|
+
isAbsolute: isAbsolute,
|
|
238
|
+
toNamespacedPath: toNamespacedPath,
|
|
239
|
+
extname: extname,
|
|
240
|
+
relative: relative,
|
|
241
|
+
dirname: dirname,
|
|
242
|
+
format: format,
|
|
243
|
+
basename: basename,
|
|
244
|
+
parse: parse
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
const index = {
|
|
248
|
+
..._path
|
|
249
|
+
};
|
|
250
|
+
|
|
67
251
|
function toArray(array) {
|
|
68
252
|
array = array || [];
|
|
69
253
|
if (Array.isArray(array))
|
|
@@ -139,7 +323,7 @@ function getNames(task) {
|
|
|
139
323
|
}
|
|
140
324
|
return names;
|
|
141
325
|
}
|
|
142
|
-
async function ensurePackageInstalled(dependency, promptInstall = !process.env.CI) {
|
|
326
|
+
async function ensurePackageInstalled(dependency, promptInstall = !process.env.CI && process.stdout.isTTY) {
|
|
143
327
|
if (isPackageExists(dependency))
|
|
144
328
|
return true;
|
|
145
329
|
console.log(c.red(`${c.inverse(c.red(" MISSING DEP "))} Can not find dependency '${dependency}'
|
|
@@ -153,10 +337,10 @@ async function ensurePackageInstalled(dependency, promptInstall = !process.env.C
|
|
|
153
337
|
message: c.reset(`Do you want to install ${c.green(dependency)}?`)
|
|
154
338
|
});
|
|
155
339
|
if (install) {
|
|
156
|
-
await (await import('./index-
|
|
340
|
+
await (await import('./index-0c3a317d.js')).installPackage(dependency, { dev: true });
|
|
157
341
|
return true;
|
|
158
342
|
}
|
|
159
343
|
return false;
|
|
160
344
|
}
|
|
161
345
|
|
|
162
|
-
export { getTests as a,
|
|
346
|
+
export { getTests as a, basename as b, c, dirname as d, ensurePackageInstalled as e, getSuites as f, getNames as g, resolve as h, isAbsolute as i, hasFailed as j, notNullish as k, index as l, interpretOnlyMode as m, noop as n, hasTests as o, partitionSuiteChildren as p, getTasks as q, relative as r, slash as s, toArray as t };
|