@vitest/runner 1.0.0-beta.3 → 1.0.0-beta.4
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
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,
|
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-0309a91e.js';
|
4
|
+
export { D as DoneCallback, E as ExtendedContext, r as Fixture, q as FixtureFn, s as Fixtures, t as HookCleanupCallback, H as HookListener, I as InferFixturesTypes, R as RunMode, w as RuntimeContext, z as SequenceHooks, A as SequenceSetupFiles, S as Suite, v as SuiteFactory, j as TaskBase, y as TaskContext, u as TaskCustomOptions, l as TaskMeta, k as TaskPopulated, m as TaskResult, n as TaskResultPack, i as TaskState, x as TestContext, o as TestFunction, p as TestOptions, U as Use } from './tasks-0309a91e.js';
|
5
5
|
import { Awaitable } from '@vitest/utils';
|
6
6
|
export { processError } from '@vitest/utils/error';
|
7
7
|
|
package/dist/index.js
CHANGED
@@ -105,12 +105,12 @@ function mergeContextFixtures(fixtures, context = {}) {
|
|
105
105
|
if (fixture.isFn) {
|
106
106
|
const usedProps = getUsedProps(fixture.value);
|
107
107
|
if (usedProps.length)
|
108
|
-
fixture.deps = context.fixtures.filter(({
|
108
|
+
fixture.deps = context.fixtures.filter(({ prop }) => prop !== fixture.prop && usedProps.includes(prop));
|
109
109
|
}
|
110
110
|
});
|
111
111
|
return context;
|
112
112
|
}
|
113
|
-
const
|
113
|
+
const fixtureValueMaps = /* @__PURE__ */ new Map();
|
114
114
|
let cleanupFnArray = new Array();
|
115
115
|
async function callFixtureCleanup() {
|
116
116
|
for (const cleanup of cleanupFnArray.reverse())
|
@@ -128,8 +128,13 @@ function withFixtures(fn, testContext) {
|
|
128
128
|
const usedProps = getUsedProps(fn);
|
129
129
|
if (!usedProps.length)
|
130
130
|
return fn(context);
|
131
|
+
if (!fixtureValueMaps.get(context))
|
132
|
+
fixtureValueMaps.set(context, /* @__PURE__ */ new Map());
|
133
|
+
const fixtureValueMap = fixtureValueMaps.get(context);
|
131
134
|
const usedFixtures = fixtures.filter(({ prop }) => usedProps.includes(prop));
|
132
135
|
const pendingFixtures = resolveDeps(usedFixtures);
|
136
|
+
if (!pendingFixtures.length)
|
137
|
+
return fn(context);
|
133
138
|
let cursor = 0;
|
134
139
|
return new Promise((resolve, reject) => {
|
135
140
|
async function use(fixtureValue) {
|
@@ -153,14 +153,11 @@ type TestAPI<ExtraContext = {}> = ChainableTestAPI<ExtraContext> & ExtendedAPI<E
|
|
153
153
|
[K in keyof T | keyof ExtraContext]: K extends keyof T ? T[K] : K extends keyof ExtraContext ? ExtraContext[K] : never;
|
154
154
|
}>;
|
155
155
|
};
|
156
|
-
type
|
157
|
-
type
|
158
|
-
|
159
|
-
} & TestContext, use: (fixture: V) => Promise<void>) => Promise<void>> = OnlyFunction extends true ? FN : (FN | V);
|
156
|
+
type Use<T> = (value: T) => Promise<void>;
|
157
|
+
type FixtureFn<T, K extends keyof T, ExtraContext> = (context: Omit<T, K> & ExtraContext, use: Use<T[K]>) => Promise<void>;
|
158
|
+
type Fixture<T, K extends keyof T, ExtraContext = {}> = ((...args: any) => any) extends T[K] ? (T[K] extends any ? FixtureFn<T, K, Omit<ExtraContext, Exclude<keyof T, K>>> : never) : T[K] | (T[K] extends any ? FixtureFn<T, K, Omit<ExtraContext, Exclude<keyof T, K>>> : never);
|
160
159
|
type Fixtures<T extends Record<string, any>, ExtraContext = {}> = {
|
161
|
-
[K in keyof T]: Fixture<T, K,
|
162
|
-
} | {
|
163
|
-
[K in keyof T]: Fixture<T, K, true, ExtraContext>;
|
160
|
+
[K in keyof T]: Fixture<T, K, ExtraContext & ExtendedContext<Test>>;
|
164
161
|
};
|
165
162
|
type InferFixturesTypes<T> = T extends TestAPI<infer C> ? C : T;
|
166
163
|
type ChainableSuiteAPI<ExtraContext = {}> = ChainableFunction<'concurrent' | 'sequential' | 'only' | 'skip' | 'todo' | 'shuffle', [
|
@@ -234,4 +231,4 @@ type OnTestFailedHandler = (result: TaskResult) => Awaitable<void>;
|
|
234
231
|
type SequenceHooks = 'stack' | 'list' | 'parallel';
|
235
232
|
type SequenceSetupFiles = 'list' | 'parallel';
|
236
233
|
|
237
|
-
export { type Custom as C, type DoneCallback as D, type ExtendedContext as E, type File as F, type HookListener as H, type InferFixturesTypes as I, type OnTestFailedHandler as O, type RunMode as R, type Suite as S, type Task as T, type Test as a, type ChainableFunction as b, createChainable as c, type SuiteAPI as d, type TestAPI as e, type SuiteCollector as f, type CustomAPI as g, type SuiteHooks as h, type TaskState as i, type TaskBase as j, type TaskPopulated as k, type TaskMeta as l, type TaskResult as m, type TaskResultPack as n, type TestFunction as o, type TestOptions as p, type
|
234
|
+
export { type SequenceSetupFiles as A, type Custom as C, type DoneCallback as D, type ExtendedContext as E, type File as F, type HookListener as H, type InferFixturesTypes as I, type OnTestFailedHandler as O, type RunMode as R, type Suite as S, type Task as T, type Use as U, type Test as a, type ChainableFunction as b, createChainable as c, type SuiteAPI as d, type TestAPI as e, type SuiteCollector as f, type CustomAPI as g, type SuiteHooks as h, type TaskState as i, type TaskBase as j, type TaskPopulated as k, type TaskMeta as l, type TaskResult as m, type TaskResultPack as n, type TestFunction as o, type TestOptions as p, type FixtureFn as q, type Fixture as r, type Fixtures as s, type HookCleanupCallback as t, type TaskCustomOptions as u, type SuiteFactory as v, type RuntimeContext as w, type TestContext as x, type TaskContext as y, type SequenceHooks as z };
|
package/dist/types.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
import {
|
2
|
-
export { g as CustomAPI, D as DoneCallback,
|
1
|
+
import { z as SequenceHooks, A as SequenceSetupFiles, F as File, k as TaskPopulated, S as Suite, n as TaskResultPack, a as Test, C as Custom, y as TaskContext, E as ExtendedContext } from './tasks-0309a91e.js';
|
2
|
+
export { g as CustomAPI, D as DoneCallback, r as Fixture, q as FixtureFn, s as Fixtures, t as HookCleanupCallback, H as HookListener, I as InferFixturesTypes, O as OnTestFailedHandler, R as RunMode, w as RuntimeContext, d as SuiteAPI, f as SuiteCollector, v as SuiteFactory, h as SuiteHooks, T as Task, j as TaskBase, u as TaskCustomOptions, l as TaskMeta, m as TaskResult, i as TaskState, e as TestAPI, x as TestContext, o as TestFunction, p as TestOptions, U as Use } from './tasks-0309a91e.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-0309a91e.js';
|
2
|
+
export { b as ChainableFunction, c as createChainable } from './tasks-0309a91e.js';
|
3
3
|
import { Arrayable } from '@vitest/utils';
|
4
4
|
|
5
5
|
/**
|
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.4",
|
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.4"
|
44
44
|
},
|
45
45
|
"scripts": {
|
46
46
|
"build": "rimraf dist && rollup -c",
|