File tree Expand file tree Collapse file tree 3 files changed +12
-5
lines changed
packages/nyc-test-coverage Expand file tree Collapse file tree 3 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ worker = await Worker.create({
20
20
taskQueue ,
21
21
workflowsPath: require .resolve (" ./workflows" ),
22
22
interceptors: {
23
- workflowModules: [require . resolve ( " @temporalio/nyc-test-coverage/lib/interceptors " ) ]
23
+ workflowModules: [workflowCoverage . interceptorModule ]
24
24
},
25
25
sinks: workflowCoverage .sinks ,
26
26
});
@@ -41,4 +41,4 @@ The following assumes that `npm run build` produces compiled JavaScript in the `
41
41
{
42
42
"test.coverage": "npm run build && nyc instrument lib lib --in-place && nyc --reporter=lcov --reporter=text-summary mocha lib/*.test.js"
43
43
}
44
- ```
44
+ ```
Original file line number Diff line number Diff line change @@ -5,6 +5,13 @@ import libCoverage from 'istanbul-lib-coverage';
5
5
export class WorkflowCoverage {
6
6
coverageMap = libCoverage . createCoverageMap ( ) ;
7
7
8
+ /**
9
+ * Interceptor to inject into `WorkerOptions.interceptors.workflowModules`
10
+ */
11
+ public get interceptorModule ( ) : string {
12
+ return require . resolve ( './interceptors' ) ;
13
+ }
14
+
8
15
/**
9
16
* Contains sinks that allow Workflows to gather coverage data.
10
17
*/
Original file line number Diff line number Diff line change 1
1
import { proxySinks , WorkflowInterceptors } from '@temporalio/workflow' ;
2
2
import { CoverageSinks } from './sinks' ;
3
- import libCoverage from 'istanbul-lib-coverage' ;
3
+ import type { CoverageMapData } from 'istanbul-lib-coverage' ;
4
4
5
5
const { coverage } = proxySinks < CoverageSinks > ( ) ;
6
6
@@ -11,7 +11,7 @@ export const interceptors = (): WorkflowInterceptors => ({
11
11
concludeActivation ( input , next ) {
12
12
/* eslint-disable @typescript-eslint/ban-ts-comment */
13
13
// @ts -ignore
14
- const globalCoverage : libCoverage . CoverageMapData = global . __coverage__ ;
14
+ const globalCoverage : CoverageMapData = global . __coverage__ ;
15
15
16
16
coverage . merge ( JSON . parse ( JSON . stringify ( globalCoverage ) ) ) ;
17
17
clearCoverage ( globalCoverage ) ;
@@ -22,7 +22,7 @@ export const interceptors = (): WorkflowInterceptors => ({
22
22
] ,
23
23
} ) ;
24
24
25
- function clearCoverage ( coverage : libCoverage . CoverageMapData ) : void {
25
+ function clearCoverage ( coverage : CoverageMapData ) : void {
26
26
for ( const path of Object . keys ( coverage ) ) {
27
27
for ( const index of Object . keys ( coverage [ path ] . s ) ) {
28
28
coverage [ path ] . s [ index ] = 0 ;
You can’t perform that action at this time.
0 commit comments