@opscotch/resource-testkit
v0.1.2
Published
Unit test runtime shim for Opscotch JavaScript resources.
Downloads
472
Keywords
Readme
@opscotch/resource-testkit
@opscotch/resource-testkit is the npm-distributed JavaScript unit test runtime for Opscotch resource files.
It provides the same best-effort runtime shim used by the Docker-based Opscotch resource testkit, but packaged for local IDE use and direct Vitest/Jest-style test authoring.
Scope
This package is intended for unit testing Opscotch JavaScript resources.
It is not the production Opscotch agent runtime.
Some features are fully implemented in-memory for test realism, such as:
docJavascriptContextandJavascriptStateContextcore flow- byte-buffer handling
- send/metric/log recording
Some complex features remain stubbed or mock-first, such as:
- parts of
crypto() - parts of
files() - parts of
queue()
Install
Install from npmjs:
npm install -D @opscotch/[email protected] vitest typescript @types/nodeExample
import { createJavascriptContext, runResource } from '@opscotch/resource-testkit';
const context = createJavascriptContext({
body: '{"hello":"world"}',
});
await runResource({
resource: '/path/to/resource.js',
context,
});Publishing
This package is intended to be published to npmjs as a public scoped package.
License
This package is free to use, but use is conditioned on agreement to the Opscotch legal terms:
- https://www.opscotch.co/legal
The packaged license notice is included in LICENSE.txt.
