Socket
Socket
Sign inDemoInstall

@vitest/runner

Package Overview
Dependencies
Maintainers
3
Versions
91
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vitest/runner - npm Package Compare versions

Comparing version 0.34.5 to 0.34.6

63

./dist/index.js

@@ -113,2 +113,12 @@ import limit from 'p-limit';

}
const fixtureValueMap = /* @__PURE__ */ new Map();
const fixtureCleanupFnMap = /* @__PURE__ */ new Map();
async function callFixtureCleanup(id) {
const cleanupFnArray = fixtureCleanupFnMap.get(id);
if (!cleanupFnArray)
return;
for (const cleanup of cleanupFnArray.reverse())
await cleanup();
fixtureCleanupFnMap.delete(id);
}
function withFixtures(fn, testContext) {

@@ -119,2 +129,7 @@ return (hookContext) => {

return fn({});
let cleanupFnArray = fixtureCleanupFnMap.get(context.task.suite.id);
if (!cleanupFnArray) {
cleanupFnArray = [];
fixtureCleanupFnMap.set(context.task.suite.id, cleanupFnArray);
}
const fixtures = getFixture(context);

@@ -129,15 +144,36 @@ if (!(fixtures == null ? void 0 : fixtures.length))

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();
return new Promise((resolve, reject) => {
async function use(fixtureValue) {
const fixture = pendingFixtures[cursor++];
context[fixture.prop] = fixtureValue;
if (!fixtureValueMap.has(fixture)) {
fixtureValueMap.set(fixture, fixtureValue);
cleanupFnArray.unshift(() => {
fixtureValueMap.delete(fixture);
});
}
if (cursor < pendingFixtures.length) {
await next();
} else {
try {
resolve(await fn(context));
} catch (err) {
reject(err);
}
return new Promise((resolve2) => {
cleanupFnArray.push(resolve2);
});
}
}
async function next() {
const fixture = pendingFixtures[cursor];
const { isFn, value } = fixture;
if (fixtureValueMap.has(fixture))
return use(fixtureValueMap.get(fixture));
else
return isFn ? value(context, use) : use(value);
}
const setupFixturePromise = next();
cleanupFnArray.unshift(() => setupFixturePromise);
});
};

@@ -757,2 +793,3 @@ }

try {
await callFixtureCleanup(suite.id);
await callSuiteHook(suite, suite, "afterAll", runner, [suite]);

@@ -759,0 +796,0 @@ await callCleanupHooks(beforeAllCleanups);

@@ -113,2 +113,12 @@ import limit from 'p-limit';

}
const fixtureValueMap = /* @__PURE__ */ new Map();
const fixtureCleanupFnMap = /* @__PURE__ */ new Map();
async function callFixtureCleanup(id) {
const cleanupFnArray = fixtureCleanupFnMap.get(id);
if (!cleanupFnArray)
return;
for (const cleanup of cleanupFnArray.reverse())
await cleanup();
fixtureCleanupFnMap.delete(id);
}
function withFixtures(fn, testContext) {

@@ -119,2 +129,7 @@ return (hookContext) => {

return fn({});
let cleanupFnArray = fixtureCleanupFnMap.get(context.task.suite.id);
if (!cleanupFnArray) {
cleanupFnArray = [];
fixtureCleanupFnMap.set(context.task.suite.id, cleanupFnArray);
}
const fixtures = getFixture(context);

@@ -129,15 +144,36 @@ if (!(fixtures == null ? void 0 : fixtures.length))

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();
return new Promise((resolve, reject) => {
async function use(fixtureValue) {
const fixture = pendingFixtures[cursor++];
context[fixture.prop] = fixtureValue;
if (!fixtureValueMap.has(fixture)) {
fixtureValueMap.set(fixture, fixtureValue);
cleanupFnArray.unshift(() => {
fixtureValueMap.delete(fixture);
});
}
if (cursor < pendingFixtures.length) {
await next();
} else {
try {
resolve(await fn(context));
} catch (err) {
reject(err);
}
return new Promise((resolve2) => {
cleanupFnArray.push(resolve2);
});
}
}
async function next() {
const fixture = pendingFixtures[cursor];
const { isFn, value } = fixture;
if (fixtureValueMap.has(fixture))
return use(fixtureValueMap.get(fixture));
else
return isFn ? value(context, use) : use(value);
}
const setupFixturePromise = next();
cleanupFnArray.unshift(() => setupFixturePromise);
});
};

@@ -757,2 +793,3 @@ }

try {
await callFixtureCleanup(suite.id);
await callSuiteHook(suite, suite, "afterAll", runner, [suite]);

@@ -759,0 +796,0 @@ await callCleanupHooks(beforeAllCleanups);

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

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

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

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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc