@vitest/runner 1.0.0-beta.2 → 1.0.0-beta.3
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 +2 -2
- package/dist/index.js +13 -17
- package/dist/{tasks-54dc134a.d.ts → tasks-3ea70b32.d.ts} +0 -4
- package/dist/types.d.ts +2 -2
- package/dist/utils.d.ts +2 -2
- package/dist/utils.js +2 -3
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import { VitestRunner } from './types.js';
|
2
2
|
export { CancelReason, VitestRunnerConfig, VitestRunnerConstructor, VitestRunnerImportSource } from './types.js';
|
3
|
-
import { T as Task, F as File, d as SuiteAPI, e as TestAPI, f as SuiteCollector, g as CustomAPI, h as SuiteHooks, O as OnTestFailedHandler, a as Test, C as Custom } from './tasks-
|
4
|
-
export { D as DoneCallback, E as ExtendedContext, q as Fixture, r as Fixtures, s as HookCleanupCallback, H as HookListener, I as InferFixturesTypes, R as RunMode, v as RuntimeContext, y as SequenceHooks, z as SequenceSetupFiles, S as Suite, u as SuiteFactory, j as TaskBase, x as TaskContext, t as TaskCustomOptions, l as TaskMeta, k as TaskPopulated, m as TaskResult, n as TaskResultPack, i as TaskState, w as TestContext, o as TestFunction, p as TestOptions } from './tasks-
|
3
|
+
import { T as Task, F as File, d as SuiteAPI, e as TestAPI, f as SuiteCollector, g as CustomAPI, h as SuiteHooks, O as OnTestFailedHandler, a as Test, C as Custom } from './tasks-3ea70b32.js';
|
4
|
+
export { D as DoneCallback, E as ExtendedContext, q as Fixture, r as Fixtures, s as HookCleanupCallback, H as HookListener, I as InferFixturesTypes, R as RunMode, v as RuntimeContext, y as SequenceHooks, z as SequenceSetupFiles, S as Suite, u as SuiteFactory, j as TaskBase, x as TaskContext, t as TaskCustomOptions, l as TaskMeta, k as TaskPopulated, m as TaskResult, n as TaskResultPack, i as TaskState, w as TestContext, o as TestFunction, p as TestOptions } from './tasks-3ea70b32.js';
|
5
5
|
import { Awaitable } from '@vitest/utils';
|
6
6
|
export { processError } from '@vitest/utils/error';
|
7
7
|
|
package/dist/index.js
CHANGED
@@ -225,9 +225,19 @@ function splitByComma(s) {
|
|
225
225
|
return result;
|
226
226
|
}
|
227
227
|
|
228
|
+
let _test;
|
229
|
+
function setCurrentTest(test) {
|
230
|
+
_test = test;
|
231
|
+
}
|
232
|
+
function getCurrentTest() {
|
233
|
+
return _test;
|
234
|
+
}
|
235
|
+
|
228
236
|
const suite = createSuite();
|
229
237
|
const test = createTest(
|
230
238
|
function(name, fn, options) {
|
239
|
+
if (getCurrentTest())
|
240
|
+
throw new Error("Nested tests are not allowed");
|
231
241
|
getCurrentSuite().test.fn.call(this, formatName(name), fn, options);
|
232
242
|
}
|
233
243
|
);
|
@@ -523,7 +533,6 @@ async function collectTests(paths, runner) {
|
|
523
533
|
const error = processError(e);
|
524
534
|
file.result = {
|
525
535
|
state: "fail",
|
526
|
-
error,
|
527
536
|
errors: [error]
|
528
537
|
};
|
529
538
|
}
|
@@ -535,14 +544,6 @@ async function collectTests(paths, runner) {
|
|
535
544
|
return files;
|
536
545
|
}
|
537
546
|
|
538
|
-
let _test;
|
539
|
-
function setCurrentTest(test) {
|
540
|
-
_test = test;
|
541
|
-
}
|
542
|
-
function getCurrentTest() {
|
543
|
-
return _test;
|
544
|
-
}
|
545
|
-
|
546
547
|
const now = Date.now;
|
547
548
|
function updateSuiteHookState(suite, name, state, runner) {
|
548
549
|
var _a;
|
@@ -700,11 +701,9 @@ async function runTest(test, runner) {
|
|
700
701
|
if (test.result.state === "pass") {
|
701
702
|
const error = processError(new Error("Expect test to fail"));
|
702
703
|
test.result.state = "fail";
|
703
|
-
test.result.error = error;
|
704
704
|
test.result.errors = [error];
|
705
705
|
} else {
|
706
706
|
test.result.state = "pass";
|
707
|
-
test.result.error = void 0;
|
708
707
|
test.result.errors = void 0;
|
709
708
|
}
|
710
709
|
}
|
@@ -722,7 +721,6 @@ function failTask(result, err, diffOptions) {
|
|
722
721
|
const errors = Array.isArray(err) ? err : [err];
|
723
722
|
for (const e of errors) {
|
724
723
|
const error = processError(e, diffOptions);
|
725
|
-
result.error ?? (result.error = error);
|
726
724
|
result.errors ?? (result.errors = []);
|
727
725
|
result.errors.push(error);
|
728
726
|
}
|
@@ -737,7 +735,7 @@ function markTasksAsSkipped(suite, runner) {
|
|
737
735
|
});
|
738
736
|
}
|
739
737
|
async function runSuite(suite, runner) {
|
740
|
-
var _a, _b, _c;
|
738
|
+
var _a, _b, _c, _d;
|
741
739
|
await ((_a = runner.onBeforeRunSuite) == null ? void 0 : _a.call(runner, suite));
|
742
740
|
if (((_b = suite.result) == null ? void 0 : _b.state) === "fail") {
|
743
741
|
markTasksAsSkipped(suite, runner);
|
@@ -790,9 +788,8 @@ async function runSuite(suite, runner) {
|
|
790
788
|
if (suite.mode === "run") {
|
791
789
|
if (!hasTests(suite)) {
|
792
790
|
suite.result.state = "fail";
|
793
|
-
if (!suite.result.
|
791
|
+
if (!((_c = suite.result.errors) == null ? void 0 : _c.length)) {
|
794
792
|
const error = processError(new Error(`No test found in suite ${suite.name}`));
|
795
|
-
suite.result.error = error;
|
796
793
|
suite.result.errors = [error];
|
797
794
|
}
|
798
795
|
} else if (hasFailed(suite)) {
|
@@ -803,7 +800,7 @@ async function runSuite(suite, runner) {
|
|
803
800
|
}
|
804
801
|
updateTask(suite, runner);
|
805
802
|
suite.result.duration = now() - start;
|
806
|
-
await ((
|
803
|
+
await ((_d = runner.onAfterRunSuite) == null ? void 0 : _d.call(runner, suite));
|
807
804
|
}
|
808
805
|
}
|
809
806
|
async function runSuiteChild(c, runner) {
|
@@ -820,7 +817,6 @@ async function runFiles(files, runner) {
|
|
820
817
|
const error = processError(new Error(`No test suite found in file ${file.filepath}`));
|
821
818
|
file.result = {
|
822
819
|
state: "fail",
|
823
|
-
error,
|
824
820
|
errors: [error]
|
825
821
|
};
|
826
822
|
}
|
@@ -57,10 +57,6 @@ interface TaskResult {
|
|
57
57
|
duration?: number;
|
58
58
|
startTime?: number;
|
59
59
|
heap?: number;
|
60
|
-
/**
|
61
|
-
* @deprecated Use "errors" instead
|
62
|
-
*/
|
63
|
-
error?: ErrorWithDiff;
|
64
60
|
errors?: ErrorWithDiff[];
|
65
61
|
htmlError?: string;
|
66
62
|
hooks?: Partial<Record<keyof SuiteHooks, TaskState>>;
|
package/dist/types.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
import { y as SequenceHooks, z as SequenceSetupFiles, F as File, k as TaskPopulated, S as Suite, n as TaskResultPack, a as Test, C as Custom, x as TaskContext, E as ExtendedContext } from './tasks-
|
2
|
-
export { g as CustomAPI, D as DoneCallback, q as Fixture, r as Fixtures, s as HookCleanupCallback, H as HookListener, I as InferFixturesTypes, O as OnTestFailedHandler, R as RunMode, v as RuntimeContext, d as SuiteAPI, f as SuiteCollector, u as SuiteFactory, h as SuiteHooks, T as Task, j as TaskBase, t as TaskCustomOptions, l as TaskMeta, m as TaskResult, i as TaskState, e as TestAPI, w as TestContext, o as TestFunction, p as TestOptions } from './tasks-
|
1
|
+
import { y as SequenceHooks, z as SequenceSetupFiles, F as File, k as TaskPopulated, S as Suite, n as TaskResultPack, a as Test, C as Custom, x as TaskContext, E as ExtendedContext } from './tasks-3ea70b32.js';
|
2
|
+
export { g as CustomAPI, D as DoneCallback, q as Fixture, r as Fixtures, s as HookCleanupCallback, H as HookListener, I as InferFixturesTypes, O as OnTestFailedHandler, R as RunMode, v as RuntimeContext, d as SuiteAPI, f as SuiteCollector, u as SuiteFactory, h as SuiteHooks, T as Task, j as TaskBase, t as TaskCustomOptions, l as TaskMeta, m as TaskResult, i as TaskState, e as TestAPI, w as TestContext, o as TestFunction, p as TestOptions } from './tasks-3ea70b32.js';
|
3
3
|
import '@vitest/utils';
|
4
4
|
|
5
5
|
/**
|
package/dist/utils.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
import { S as Suite, T as Task, a as Test, C as Custom } from './tasks-
|
2
|
-
export { b as ChainableFunction, c as createChainable } from './tasks-
|
1
|
+
import { S as Suite, T as Task, a as Test, C as Custom } from './tasks-3ea70b32.js';
|
2
|
+
export { b as ChainableFunction, c as createChainable } from './tasks-3ea70b32.js';
|
3
3
|
import { Arrayable } from '@vitest/utils';
|
4
4
|
|
5
5
|
/**
|
package/dist/utils.js
CHANGED
@@ -70,7 +70,6 @@ function checkAllowOnly(task, allowOnly) {
|
|
70
70
|
const error = processError(new Error("[Vitest] Unexpected .only modifier. Remove it or pass --allowOnly argument to bypass this error"));
|
71
71
|
task.result = {
|
72
72
|
state: "fail",
|
73
|
-
error,
|
74
73
|
errors: [error]
|
75
74
|
};
|
76
75
|
}
|
@@ -125,8 +124,8 @@ function isAtomTest(s) {
|
|
125
124
|
}
|
126
125
|
function getTests(suite) {
|
127
126
|
const tests = [];
|
128
|
-
const
|
129
|
-
for (const s of
|
127
|
+
const arraySuites = toArray(suite);
|
128
|
+
for (const s of arraySuites) {
|
130
129
|
if (isAtomTest(s)) {
|
131
130
|
tests.push(s);
|
132
131
|
} else {
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@vitest/runner",
|
3
3
|
"type": "module",
|
4
|
-
"version": "1.0.0-beta.
|
4
|
+
"version": "1.0.0-beta.3",
|
5
5
|
"description": "Vitest test runner",
|
6
6
|
"license": "MIT",
|
7
7
|
"funding": "https://opencollective.com/vitest",
|
@@ -40,7 +40,7 @@
|
|
40
40
|
"dependencies": {
|
41
41
|
"p-limit": "^4.0.0",
|
42
42
|
"pathe": "^1.1.1",
|
43
|
-
"@vitest/utils": "1.0.0-beta.
|
43
|
+
"@vitest/utils": "1.0.0-beta.3"
|
44
44
|
},
|
45
45
|
"scripts": {
|
46
46
|
"build": "rimraf dist && rollup -c",
|