.agents/skills/serverless-integrations/references/testing-guide.md
Serverless integration tests need both local behavioral coverage and deployed verification when a platform integration is added or materially changed.
Cover the runtime lifecycle, not only the happy path:
Assert that the invocation span has:
.invoke or the established local pattern;type = 'serverless';span.kind = 'server' where the plugin framework sets it;Plugin tests in dd-trace-js must run with OpenTelemetry exporter environment variables unset:
unset OTEL_TRACES_EXPORTER OTEL_LOGS_EXPORTER OTEL_METRICS_EXPORTER
PLUGINS="<plugin-name>" npm run test:plugins
For a single spec:
unset OTEL_TRACES_EXPORTER OTEL_LOGS_EXPORTER OTEL_METRICS_EXPORTER
./node_modules/.bin/mocha packages/datadog-plugin-<name>/test/index.spec.js
Use targeted --grep when verifying a specific failing case. Do not run the full root test suite.
Prefer blackbox tests that exercise the runtime-facing API or fixture app. Avoid production exports that exist only for tests. When a fake runtime is needed, keep it faithful to the real runtime's handler registration and completion semantics.
Use fake timers for timeout logic. Do not wait for real time to pass in unit tests.
Every bug fix should include:
Local tests cannot prove that a serverless integration works in the real provider lifecycle. When a platform integration is added or materially changed, include a deployed verification plan.
In this guide, a probe is a temporary deployed sample function or app used to verify provider behavior and Datadog ingestion. It is not a dd-trace-js runtime feature.
Use the narrowest mode that answers the risk:
Do not require permanent infrastructure for deployed verification unless the project already has that pattern.
The deployed app should:
dd.apm.probe_id:<uuid>;The verification must confirm traces reached Datadog, not only that invocation logs exist. Query by the unique probe id and assert:
type:serverless and the expected service/resource;If Datadog trace search is eventually consistent, poll with a bounded timeout and report the query window used.
Record the provider, region, runtime version, deployed app commit or package version, invocation ids, probe id, and Datadog query used. When the verification is manual, include the expected trace shape and cleanup command in the workflow output or PR description.
Classify deployed verification failures by layer: