Socket
Socket
Sign inDemoInstall

@vitest/runner

Package Overview
Dependencies
12
Maintainers
3
Versions
75
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.34.4 to 0.34.5

76

./dist/index.js

@@ -8,2 +8,3 @@ import limit from 'p-limit';

const fnMap = /* @__PURE__ */ new WeakMap();
const fixtureMap = /* @__PURE__ */ new WeakMap();
const hooksMap = /* @__PURE__ */ new WeakMap();

@@ -16,2 +17,8 @@ function setFn(key, fn) {

}
function setFixture(key, fixture) {
fixtureMap.set(key, fixture);
}
function getFixture(key) {
return fixtureMap.get(key);
}
function setHooks(key, hooks) {

@@ -108,24 +115,30 @@ hooksMap.set(key, hooks);

}
function withFixtures(fn, fixtures, context) {
if (!fixtures.length)
return () => fn(context);
const usedProps = getUsedProps(fn);
if (!usedProps.length)
return () => fn(context);
const usedFixtures = fixtures.filter(({ prop }) => usedProps.includes(prop));
const pendingFixtures = resolveDeps(usedFixtures);
let cursor = 0;
async function use(fixtureValue) {
const { prop } = pendingFixtures[cursor++];
context[prop] = fixtureValue;
if (cursor < pendingFixtures.length)
await next();
else
await fn(context);
}
async function next() {
const { value } = pendingFixtures[cursor];
typeof value === "function" ? await value(context, use) : await use(value);
}
return () => next();
function withFixtures(fn, testContext) {
return (hookContext) => {
const context = hookContext || testContext;
if (!context)
return fn({});
const fixtures = getFixture(context);
if (!(fixtures == null ? void 0 : fixtures.length))
return fn(context);
const usedProps = getUsedProps(fn);
if (!usedProps.length)
return fn(context);
const usedFixtures = fixtures.filter(({ prop }) => usedProps.includes(prop));
const pendingFixtures = resolveDeps(usedFixtures);
let cursor = 0;
async function use(fixtureValue) {
const { prop } = pendingFixtures[cursor++];
context[prop] = fixtureValue;
if (cursor < pendingFixtures.length)
await next();
else
await fn(context);
}
async function next() {
const { value } = pendingFixtures[cursor];
typeof value === "function" ? await value(context, use) : await use(value);
}
return next();
};
}

@@ -258,4 +271,5 @@ function resolveDeps(fixtures, depSet = /* @__PURE__ */ new Set(), pendingFixtures = []) {

});
setFixture(context, this.fixtures);
setFn(test3, withTimeout(
this.fixtures ? withFixtures(fn, this.fixtures, context) : () => fn(context),
withFixtures(fn, context),
(options == null ? void 0 : options.timeout) ?? runner.config.testTimeout

@@ -633,3 +647,3 @@ ));

} catch (e) {
failTask(test.result, e);
failTask(test.result, e, runner.config.diffOptions);
}

@@ -646,3 +660,3 @@ if (test.pending || ((_e = test.result) == null ? void 0 : _e.state) === "skip") {

} catch (e) {
failTask(test.result, e);
failTask(test.result, e, runner.config.diffOptions);
}

@@ -677,3 +691,3 @@ if (test.result.state === "pass")

}
function failTask(result, err) {
function failTask(result, err, diffOptions) {
if (err instanceof PendingError) {

@@ -686,3 +700,3 @@ result.state = "skip";

for (const e of errors) {
const error = processError(e);
const error = processError(e, diffOptions);
result.error ?? (result.error = error);

@@ -745,3 +759,3 @@ result.errors ?? (result.errors = []);

} catch (e) {
failTask(suite.result, e);
failTask(suite.result, e, runner.config.diffOptions);
}

@@ -752,3 +766,3 @@ try {

} catch (e) {
failTask(suite.result, e);
failTask(suite.result, e, runner.config.diffOptions);
}

@@ -818,6 +832,6 @@ if (suite.mode === "run") {

function beforeEach(fn, timeout) {
return getCurrentSuite().on("beforeEach", withTimeout(fn, timeout ?? getDefaultHookTimeout(), true));
return getCurrentSuite().on("beforeEach", withTimeout(withFixtures(fn), timeout ?? getDefaultHookTimeout(), true));
}
function afterEach(fn, timeout) {
return getCurrentSuite().on("afterEach", withTimeout(fn, timeout ?? getDefaultHookTimeout(), true));
return getCurrentSuite().on("afterEach", withTimeout(withFixtures(fn), timeout ?? getDefaultHookTimeout(), true));
}

@@ -824,0 +838,0 @@ const onTestFailed = createTestHook("onTestFailed", (test, handler) => {

@@ -8,2 +8,3 @@ import limit from 'p-limit';

const fnMap = /* @__PURE__ */ new WeakMap();
const fixtureMap = /* @__PURE__ */ new WeakMap();
const hooksMap = /* @__PURE__ */ new WeakMap();

@@ -16,2 +17,8 @@ function setFn(key, fn) {

}
function setFixture(key, fixture) {
fixtureMap.set(key, fixture);
}
function getFixture(key) {
return fixtureMap.get(key);
}
function setHooks(key, hooks) {

@@ -108,24 +115,30 @@ hooksMap.set(key, hooks);

}
function withFixtures(fn, fixtures, context) {
if (!fixtures.length)
return () => fn(context);
const usedProps = getUsedProps(fn);
if (!usedProps.length)
return () => fn(context);
const usedFixtures = fixtures.filter(({ prop }) => usedProps.includes(prop));
const pendingFixtures = resolveDeps(usedFixtures);
let cursor = 0;
async function use(fixtureValue) {
const { prop } = pendingFixtures[cursor++];
context[prop] = fixtureValue;
if (cursor < pendingFixtures.length)
await next();
else
await fn(context);
}
async function next() {
const { value } = pendingFixtures[cursor];
typeof value === "function" ? await value(context, use) : await use(value);
}
return () => next();
function withFixtures(fn, testContext) {
return (hookContext) => {
const context = hookContext || testContext;
if (!context)
return fn({});
const fixtures = getFixture(context);
if (!(fixtures == null ? void 0 : fixtures.length))
return fn(context);
const usedProps = getUsedProps(fn);
if (!usedProps.length)
return fn(context);
const usedFixtures = fixtures.filter(({ prop }) => usedProps.includes(prop));
const pendingFixtures = resolveDeps(usedFixtures);
let cursor = 0;
async function use(fixtureValue) {
const { prop } = pendingFixtures[cursor++];
context[prop] = fixtureValue;
if (cursor < pendingFixtures.length)
await next();
else
await fn(context);
}
async function next() {
const { value } = pendingFixtures[cursor];
typeof value === "function" ? await value(context, use) : await use(value);
}
return next();
};
}

@@ -258,4 +271,5 @@ function resolveDeps(fixtures, depSet = /* @__PURE__ */ new Set(), pendingFixtures = []) {

});
setFixture(context, this.fixtures);
setFn(test3, withTimeout(
this.fixtures ? withFixtures(fn, this.fixtures, context) : () => fn(context),
withFixtures(fn, context),
(options == null ? void 0 : options.timeout) ?? runner.config.testTimeout

@@ -633,3 +647,3 @@ ));

} catch (e) {
failTask(test.result, e);
failTask(test.result, e, runner.config.diffOptions);
}

@@ -646,3 +660,3 @@ if (test.pending || ((_e = test.result) == null ? void 0 : _e.state) === "skip") {

} catch (e) {
failTask(test.result, e);
failTask(test.result, e, runner.config.diffOptions);
}

@@ -677,3 +691,3 @@ if (test.result.state === "pass")

}
function failTask(result, err) {
function failTask(result, err, diffOptions) {
if (err instanceof PendingError) {

@@ -686,3 +700,3 @@ result.state = "skip";

for (const e of errors) {
const error = processError(e);
const error = processError(e, diffOptions);
result.error ?? (result.error = error);

@@ -745,3 +759,3 @@ result.errors ?? (result.errors = []);

} catch (e) {
failTask(suite.result, e);
failTask(suite.result, e, runner.config.diffOptions);
}

@@ -752,3 +766,3 @@ try {

} catch (e) {
failTask(suite.result, e);
failTask(suite.result, e, runner.config.diffOptions);
}

@@ -818,6 +832,6 @@ if (suite.mode === "run") {

function beforeEach(fn, timeout) {
return getCurrentSuite().on("beforeEach", withTimeout(fn, timeout ?? getDefaultHookTimeout(), true));
return getCurrentSuite().on("beforeEach", withTimeout(withFixtures(fn), timeout ?? getDefaultHookTimeout(), true));
}
function afterEach(fn, timeout) {
return getCurrentSuite().on("afterEach", withTimeout(fn, timeout ?? getDefaultHookTimeout(), true));
return getCurrentSuite().on("afterEach", withTimeout(withFixtures(fn), timeout ?? getDefaultHookTimeout(), true));
}

@@ -824,0 +838,0 @@ const onTestFailed = createTestHook("onTestFailed", (test, handler) => {

@@ -5,2 +5,44 @@ import { t as SequenceHooks, u as SequenceSetupFiles, F as File, a as Test, S as Suite, l as TaskResultPack, s as TestContext } from './tasks-e594cd24.js';

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
declare type CompareKeys =
| ((a: string, b: string) => number)
| null
| undefined;
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
type DiffOptionsColor = (arg: string) => string;
interface DiffOptions {
aAnnotation?: string;
aColor?: DiffOptionsColor;
aIndicator?: string;
bAnnotation?: string;
bColor?: DiffOptionsColor;
bIndicator?: string;
changeColor?: DiffOptionsColor;
changeLineTrailingSpaceColor?: DiffOptionsColor;
commonColor?: DiffOptionsColor;
commonIndicator?: string;
commonLineTrailingSpaceColor?: DiffOptionsColor;
contextLines?: number;
emptyFirstOrLastLinePlaceholder?: string;
expand?: boolean;
includeChangeCounts?: boolean;
omitAnnotationLines?: boolean;
patchColor?: DiffOptionsColor;
compareKeys?: CompareKeys;
}
interface VitestRunnerConfig {

@@ -27,2 +69,3 @@ root: string;

retry: number;
diffOptions?: DiffOptions;
}

@@ -29,0 +72,0 @@ type VitestRunnerImportSource = 'collect' | 'setup';

@@ -53,4 +53,3 @@ import { processError } from '@vitest/utils/error';

function getTaskFullName(task) {
const fullName = task.suite ? getTaskFullName(task.suite) : null;
return fullName ? `${fullName} ${task.name}` : task.name;
return `${task.suite ? `${getTaskFullName(task.suite)} ` : ""}${task.name}`;
}

@@ -57,0 +56,0 @@ function someTasksAreOnly(suite) {

{
"name": "@vitest/runner",
"type": "module",
"version": "0.34.4",
"version": "0.34.5",
"description": "Vitest test runner",

@@ -43,3 +43,3 @@ "license": "MIT",

"pathe": "^1.1.1",
"@vitest/utils": "0.34.4"
"@vitest/utils": "0.34.5"
},

@@ -46,0 +46,0 @@ "scripts": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc