Package Exports
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@temporalio/nyc-test-coverage) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
@temporalio/nyc-test-coverage
Temporal's TypeScript SDK interceptors and sinks for code coverage with nyc.
Getting Started
npm install mocha nyc
- Use nyc to manually instrument your Workflow code, for example
nyc instrument lib lib --in-place
. Make sure you instrument your Workflow code after compiling it withtsc
. - Add this package's sinks and interceptors to your test worker, for example:
import { WorkflowCoverage } from '@temporalio/nyc-test-coverage';
const workflowCoverage = new WorkflowCoverage();
worker = await Worker.create({
connection: nativeConnection,
taskQueue,
workflowsPath: require.resolve("./workflows"),
interceptors: {
workflowModules: [workflowCoverage.interceptorModule]
},
sinks: workflowCoverage.sinks,
});
- After your tests are done, call
mergeIntoGlobalCoverage()
to merge your Workflows' code coverage into nyc's global coverage.
after(() => {
workflowCoverage.mergeIntoGlobalCoverage();
});
For example, the following is a sample npm script that handles instrumenting and running tests.
The following assumes that npm run build
produces compiled JavaScript in the lib
directory.
{
"test.coverage": "npm run build && nyc instrument lib lib --in-place && nyc --reporter=lcov --reporter=text-summary mocha lib/*.test.js"
}