Socket
Socket
Sign inDemoInstall

vitest

Package Overview
Dependencies
15
Maintainers
1
Versions
357
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.18 to 0.0.19

1

dist/index.d.ts

@@ -25,2 +25,3 @@ export * from './types';

toBeCalled(): void;
toHaveBeenCalled(): void;
}

@@ -27,0 +28,0 @@ interface ExpectStatic {

@@ -51,3 +51,6 @@ // Jest Expect Compact

});
utils.addMethod(proto, 'toHaveBeenCalled', function () {
return this.called;
});
};
}

@@ -74,4 +74,6 @@ import { performance } from 'perf_hooks';

this.end = performance.now();
const suites = files.reduce((acc, file) => acc.concat(file.suites), []);
const tasks = files.reduce((acc, file) => acc.concat(file.suites.flatMap(i => i.tasks)), []);
const failedFiles = files.filter(i => i.error);
const tasks = files.reduce((acc, file) => acc.concat(file.suites.flatMap(i => i.tasks)), []);
const failedSuites = suites.filter(i => i.error);
const runable = tasks.filter(i => i.state === 'pass' || i.state === 'fail');

@@ -91,2 +93,11 @@ const passed = tasks.filter(i => i.state === 'pass');

}
if (failedSuites.length) {
this.error(c.bold(`\nFailed to run ${failedSuites.length} suites:`));
failedSuites.forEach((i) => {
var _a;
this.error(`\n- ${(_a = i.file) === null || _a === void 0 ? void 0 : _a.filepath} > ${i.name}`);
console.error(i.error || 'Unknown error');
this.log();
});
}
if (failed.length) {

@@ -93,0 +104,0 @@ this.error(c.bold(`\nFailed Tests (${failed.length})`));

3

dist/run.d.ts

@@ -1,5 +0,6 @@

import { File, Config, Task, RunnerContext } from './types';
import { File, Config, Task, RunnerContext, Suite } from './types';
export declare function runTask(task: Task, ctx: RunnerContext): Promise<void>;
export declare function collectFiles(paths: string[]): Promise<File[]>;
export declare function runSite(suite: Suite, ctx: RunnerContext): Promise<void>;
export declare function runFile(file: File, ctx: RunnerContext): Promise<void>;
export declare function run(config: Config): Promise<void>;

@@ -17,4 +17,4 @@ import fg from 'fast-glob';

if (task.mode === 'run') {
await callHook(task.suite, 'afterEach', [task, task.suite]);
try {
await callHook(task.suite, 'beforeEach', [task, task.suite]);
await task.fn();

@@ -26,4 +26,12 @@ task.state = 'pass';

task.error = e;
process.exitCode = 1;
}
await callHook(task.suite, 'afterEach', [task, task.suite]);
try {
await callHook(task.suite, 'afterEach', [task, task.suite]);
}
catch (e) {
task.state = 'fail';
task.error = e;
process.exitCode = 1;
}
}

@@ -80,2 +88,28 @@ await ((_c = reporter.onTaskEnd) === null || _c === void 0 ? void 0 : _c.call(reporter, task, ctx));

}
export async function runSite(suite, ctx) {
var _a, _b;
const { reporter } = ctx;
await ((_a = reporter.onSuiteBegin) === null || _a === void 0 ? void 0 : _a.call(reporter, suite, ctx));
if (suite.mode === 'skip') {
suite.status = 'skip';
}
else if (suite.mode === 'todo') {
suite.status = 'todo';
}
else {
try {
await callHook(suite, 'beforeAll', [suite]);
await Promise.all(suite.tasks.map(i => runTask(i, ctx)));
// for (const t of suite.tasks)
// await runTask(t, ctx)
await callHook(suite, 'afterAll', [suite]);
}
catch (e) {
suite.error = e;
suite.status = 'fail';
process.exitCode = 1;
}
}
await ((_b = reporter.onSuiteEnd) === null || _b === void 0 ? void 0 : _b.call(reporter, suite, ctx));
}
export async function runFile(file, ctx) {

@@ -88,13 +122,9 @@ var _a, _b;

await ((_a = reporter.onFileBegin) === null || _a === void 0 ? void 0 : _a.call(reporter, file, ctx));
// TODO: support toggling parallel or serial
await Promise.all(file.suites.map(async (suite) => {
var _a, _b;
await ((_a = reporter.onSuiteBegin) === null || _a === void 0 ? void 0 : _a.call(reporter, suite, ctx));
await callHook(suite, 'beforeAll', [suite]);
await Promise.all(suite.tasks.map(i => runTask(i, ctx)));
// for (const t of suite.tasks)
// await runTask(t, ctx)
await callHook(suite, 'afterAll', [suite]);
await ((_b = reporter.onSuiteEnd) === null || _b === void 0 ? void 0 : _b.call(reporter, suite, ctx));
}));
if (ctx.config.parallel) {
await Promise.all(file.suites.map(suite => runSite(suite, ctx)));
}
else {
for (const suite of file.suites)
await runSite(suite, ctx);
}
await ((_b = reporter.onFileEnd) === null || _b === void 0 ? void 0 : _b.call(reporter, file, ctx));

@@ -101,0 +131,0 @@ }

@@ -18,2 +18,8 @@ import { ViteDevServer } from 'vite';

jsdom?: boolean;
/**
* Run tests files in parallel
*
* @default false
*/
parallel?: boolean;
}

@@ -51,2 +57,4 @@ export interface Config extends UserOptions {

file?: File;
error?: unknown;
status?: TaskState;
hooks: {

@@ -53,0 +61,0 @@ beforeAll: HookListener<[Suite]>[];

{
"name": "vitest",
"version": "0.0.18",
"version": "0.0.19",
"description": "",

@@ -5,0 +5,0 @@ "keywords": [],

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc