🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

@temporalio/nyc-test-coverage

Package Overview
Dependencies
Maintainers
7
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@temporalio/nyc-test-coverage

Temporal.io SDK code coverage integration

1.1.0
Source
npm
Version published
Weekly downloads
51K
-7.05%
Maintainers
7
Weekly downloads
 
Created
Source

@temporalio/nyc-test-coverage

NPM

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 with tsc.
  • 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"
}

Keywords

temporal

FAQs

Package last updated on 20 Aug 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts