New:Introducing Socket Scanning for VS Code Marketplace Extensions.Learn more →
Get Started

@software-hardware-integration-lab/vitest-integration-test-harness

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@software-hardware-integration-lab/vitest-integration-test-harness

Test harness built on top of vitest for creating integration tests with predictable setup and teardown behavior

latest
Source
npmnpm
Version
0.0.2
Version published
Weekly downloads
29
-85.28%
Maintainers
1
Weekly downloads
 
Created
Source

Vitest Integration Test Harness

Reusable Vitest fixtures for integration tests that call external services or mutate real resources. The harness provides readiness gating, resource cleanup, and failure diagnostics without imposing a cloud provider or test-suite structure.

Provider-Agnostic by Design

The package supplies mechanisms. Your application supplies everything specific to it: the profiles describing your dependencies, the credentials and how they are obtained, the clients that talk to your services, and any policy about which environments may be tested against. Nothing in this package names a vendor, and nothing in it ships a credential.

That boundary is what keeps the harness reusable across applications with completely different dependencies. See Ownership Boundary for where the line falls and how to decide which side a change belongs on.

Installation

Install this package and Vitest in the project containing your integration tests:

npm install --save-dev @software-hardware-integration-lab/vitest-integration-test-harness vitest

Usage

Use integrationTest in place of Vitest's test. The supplied fixtures are active for every test.

import { expect } from 'vitest';
import { integrationTest } from '@software-hardware-integration-lab/vitest-integration-test-harness';

integrationTest('creates and reads a widget', async ({ resources }) => {
    const widget = await resources.track(
        'example widget',
        (): Promise<Widget> => createWidget('example'),
        async (created): Promise<void> => { await deleteWidget(created.id); }
    );

    expect(await getWidget(widget.id)).toEqual(widget);
});

track creates the resource, registers its cleanup before resolving, and hands the resource back to the test body. Cleanup actions can be synchronous or asynchronous and should tolerate a resource that has already been removed.

Every test declares what it does. A test that creates nothing calls resources.markNoResources() instead; a test that does neither fails after its body passes.

That test runs with no configuration, because every environment is considered ready until a suite says otherwise.

Documentation

Full documentation lives in the wiki.

Public API

Import everything from the package root. Paths under src are not a supported entry point.

ExportKindPurpose
integrationTestFunctionVitest test API with automatic resource cleanup, failure diagnostics, and readiness gating.
integrationSuiteFunctionCreates a test API with paired file-scoped setup and cleanup.
createSuiteRunnerFunctionAttaches the file-scoped setup and cleanup lifecycle to a test API you supply.
createEnvironmentProfileFunctionBundles environment variables, readiness checks, fixtures, and metadata into a reusable profile.
evaluateReadinessFunctionRuns readiness checks in order and returns a result containing the first failure reason, if any.
evaluateEnvironmentVariablesFunctionValidates required environment variables and aggregates every failure into one reason.
retryFunctionRepeats a signal-aware operation until it succeeds, times out, hits the attempt limit, is cancelled, or shouldRetry rejects an error.
pollUntilFunctionUses retry to repeat a signal-aware check until its value satisfies a predicate.
ResourceTrackerClassRuns paired resource setup and cleanup, returns each resource, and cleans up in LIFO order.
ResourceCleanupErrorError classAggregates cleanup failures after every tracked callback has been attempted.
ResourceSetupErrorError classReports a failed resource setup and aborts the tracker's remaining setups.
RetryTimeoutErrorError classReports a retry or poll timeout with the attempt count and most recent error.
MaxRetryAttemptsReachedErrorError classReports that the retry attempt limit was reached before the timeout.
PollPredicateMismatchErrorError classHolds the most recent value that did not satisfy a polling predicate.
EnvironmentReadinessTypeA readiness result containing a boolean state and optional failure reason.
ReadinessCheckTypeA named synchronous or asynchronous verification that returns true, false, or throws.
TestableEnvironmentVariableTypeA required environment variable key with an optional value check.
EnvironmentVariableCheckResultTypeThe success flag and optional reason returned by a variable's check.
EnvironmentProfileTypeA profile definition: metadata, readiness checks, variables, fixtures, tags, and readiness scope.
EnvironmentProfileResultTypeThe integrationTest, integrationSuite, and frozen profile returned by createEnvironmentProfile.
ProfileFixturesTypeCustom fixture definitions for a profile, typed from Vitest's fixture extension API.
DependencyTypeTypeOpen union classifying a dependency, such as Database or BlobStorage.
RiskLevelTypeOpen union describing how a dependency's setup and teardown can affect other tests.
RetryOptionsTypeConfigures retry timeout, intervals, backoff, jitter, cancellation, attempt limit, retry eligibility, and operation context.
PollResult<T>TypeContains a successful value of type T, attempt count, and elapsed time.
ResourceCleanupFailureTypeA failed cleanup's resource description and error.
FailureDiagnosticsPayloadTypeFailure messages and recorded diagnostic entries emitted after a test fails.
DiagnosticsTypeRecords diagnostic context, redaction rules, and failure reporters.
DiagnosticEntryTypeA labeled diagnostic detail value.
DiagnosticRedactionRuleTypeA string or regular expression that identifies sensitive property names.
DiagnosticReporterTypeReceives the diagnostic payload for a failed test.
IntegrationTestFixturesTypeFixtures supplied by integrationTest: environment, readiness gate, resources, and diagnostics.
IntegrationSuiteContextTypeFile-scoped resources available during integration suite setup.
IntegrationSuiteOptionsTypeConfigures an integration suite's name and paired setup/cleanup.

ResourceTracker and createSuiteRunner are available for custom fixture composition. If you pass an external AbortSignal to the tracker's constructor, call detachAbortSignal() once the fixture lifecycle completes to remove the listener; it neither runs cleanup nor cancels tracked setup actions. Most suites should use the automatic resources and diagnostics fixtures provided by integrationTest.

Scripts

npm test
npm run lint
npm run build:Dev
npm run build:Prod

build:Dev emits JavaScript to bin. build:Prod emits JavaScript and declaration files to bin.

Keywords

vitest

FAQs

Package last updated on 27 Aug 2026

Related posts