@temporalio/nyc-test-coverage 1.4.2 → 1.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.d.ts +1 -0
- package/lib/index.js +10 -8
- package/lib/index.js.map +1 -1
- package/package.json +4 -4
- package/src/index.ts +11 -9
package/lib/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import libCoverage from 'istanbul-lib-coverage';
|
|
|
4
4
|
declare type WebpackConfigType = ReturnType<NonNullable<BundleOptions['webpackConfigHook']>>;
|
|
5
5
|
export declare class WorkflowCoverage {
|
|
6
6
|
coverageMap: libCoverage.CoverageMap;
|
|
7
|
+
private hasCoverageGlobal;
|
|
7
8
|
/**
|
|
8
9
|
* Add all necessary coverage-specific logic to Worker config:
|
|
9
10
|
* interceptors, sinks, and Webpack config hook.
|
package/lib/index.js
CHANGED
|
@@ -5,13 +5,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.WorkflowCoverage = void 0;
|
|
7
7
|
const istanbul_lib_coverage_1 = __importDefault(require("istanbul-lib-coverage"));
|
|
8
|
-
// Check if running through nyc or some other Istanbul-based tool.
|
|
9
|
-
// If not, any `workflowCoverage()` tools are a no-op.
|
|
10
|
-
const hasCoverageGlobal = '__coverage__' in global;
|
|
11
8
|
class WorkflowCoverage {
|
|
12
9
|
constructor() {
|
|
13
10
|
this.coverageMap = istanbul_lib_coverage_1.default.createCoverageMap();
|
|
14
11
|
}
|
|
12
|
+
// Check if running through nyc or some other Istanbul-based tool.
|
|
13
|
+
// If not, any `workflowCoverage()` tools are a no-op.
|
|
14
|
+
hasCoverageGlobal() {
|
|
15
|
+
return '__coverage__' in global;
|
|
16
|
+
}
|
|
15
17
|
/**
|
|
16
18
|
* Add all necessary coverage-specific logic to Worker config:
|
|
17
19
|
* interceptors, sinks, and Webpack config hook.
|
|
@@ -20,7 +22,7 @@ class WorkflowCoverage {
|
|
|
20
22
|
if (!workerOptions.workflowsPath) {
|
|
21
23
|
throw new TypeError('Cannot automatically instrument coverage without specifying `workflowsPath`');
|
|
22
24
|
}
|
|
23
|
-
if (!hasCoverageGlobal) {
|
|
25
|
+
if (!this.hasCoverageGlobal()) {
|
|
24
26
|
return workerOptions;
|
|
25
27
|
}
|
|
26
28
|
const workflowsPath = workerOptions.workflowsPath;
|
|
@@ -56,7 +58,7 @@ class WorkflowCoverage {
|
|
|
56
58
|
if (!bundleOptions.workflowsPath) {
|
|
57
59
|
throw new TypeError('Cannot automatically instrument coverage without specifying `workflowsPath`');
|
|
58
60
|
}
|
|
59
|
-
if (!hasCoverageGlobal) {
|
|
61
|
+
if (!this.hasCoverageGlobal()) {
|
|
60
62
|
return bundleOptions;
|
|
61
63
|
}
|
|
62
64
|
const workflowsPath = bundleOptions.workflowsPath;
|
|
@@ -81,7 +83,7 @@ class WorkflowCoverage {
|
|
|
81
83
|
if (!workerOptions.workflowBundle) {
|
|
82
84
|
throw new TypeError('Cannot call `augmentWorkerOptionsWithBundle()` unless you specify a `workflowBundle`. Perhaps you meant to use `augmentBundleOptions()` instead?');
|
|
83
85
|
}
|
|
84
|
-
if (!hasCoverageGlobal) {
|
|
86
|
+
if (!this.hasCoverageGlobal()) {
|
|
85
87
|
return workerOptions;
|
|
86
88
|
}
|
|
87
89
|
return {
|
|
@@ -118,7 +120,7 @@ class WorkflowCoverage {
|
|
|
118
120
|
* code using istanbul-instrumenter-loader
|
|
119
121
|
*/
|
|
120
122
|
addInstrumenterRule(workflowsPath, config) {
|
|
121
|
-
if (!hasCoverageGlobal) {
|
|
123
|
+
if (!this.hasCoverageGlobal()) {
|
|
122
124
|
return config;
|
|
123
125
|
}
|
|
124
126
|
const newRule = {
|
|
@@ -142,7 +144,7 @@ class WorkflowCoverage {
|
|
|
142
144
|
* map data `global.__coverage__`.
|
|
143
145
|
*/
|
|
144
146
|
mergeIntoGlobalCoverage() {
|
|
145
|
-
if (!hasCoverageGlobal) {
|
|
147
|
+
if (!this.hasCoverageGlobal()) {
|
|
146
148
|
return;
|
|
147
149
|
}
|
|
148
150
|
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAEA,kFAAgD;AAKhD,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAEA,kFAAgD;AAKhD,MAAa,gBAAgB;IAA7B;QACE,gBAAW,GAAG,+BAAW,CAAC,iBAAiB,EAAE,CAAC;IA0LhD,CAAC;IAxLC,kEAAkE;IAClE,sDAAsD;IAC9C,iBAAiB;QACvB,OAAO,cAAc,IAAI,MAAM,CAAC;IAClC,CAAC;IAED;;;OAGG;IACH,oBAAoB,CAClB,aAA6F;QAE7F,IAAI,CAAC,aAAa,CAAC,aAAa,EAAE;YAChC,MAAM,IAAI,SAAS,CAAC,6EAA6E,CAAC,CAAC;SACpG;QAED,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE,EAAE;YAC7B,OAAO,aAAa,CAAC;SACtB;QAED,MAAM,aAAa,GAAG,aAAa,CAAC,aAAa,CAAC;QAElD,OAAO;YACL,GAAG,aAAa;YAChB,YAAY,EAAE;gBACZ,GAAG,aAAa,CAAC,YAAY;gBAC7B,eAAe,EAAE,CAAC,GAAG,CAAC,aAAa,EAAE,YAAY,EAAE,eAAe,IAAI,EAAE,CAAC,EAAE,IAAI,CAAC,iBAAiB,CAAC;aACnG;YACD,KAAK,EAAE;gBACL,GAAG,aAAa,CAAC,KAAK;gBACtB,GAAG,IAAI,CAAC,KAAK;aACd;YACD,cAAc,EAAE;gBACd,GAAG,aAAa,CAAC,cAAc;gBAC/B,iBAAiB,EAAE,CAAC,MAAyB,EAAE,EAAE;oBAC/C,MAAM,GAAG,IAAI,CAAC,mB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Y,CAAC,CAAC;QAE5C,MAAM,eAAe,GAAgC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,MAAM,CAC5F,CAAC,GAAgC,EAAE,IAAI,EAAE,EAAE;YACzC,MAAM,YAAY,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAA6B,CAAC;YAE7E,GAAG,CAAC,IAAI,CAAC,GAAG,YAAY,CAAC,IAAI,CAAC;YAC9B,OAAO,GAAG,CAAC;QACb,CAAC,EACD,EAAE,CACH,CAAC;QAEF,aAAa;QACb,MAAM,CAAC,YAAY,GAAG,eAAe,CAAC;IACxC,CAAC;CACF;AA3LD,4CA2LC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@temporalio/nyc-test-coverage",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.4",
|
|
4
4
|
"description": "Temporal.io SDK code coverage integration",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"temporal",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"src"
|
|
22
22
|
],
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@temporalio/worker": "
|
|
25
|
-
"@temporalio/workflow": "
|
|
24
|
+
"@temporalio/worker": "~1.4.4",
|
|
25
|
+
"@temporalio/workflow": "~1.4.4",
|
|
26
26
|
"istanbul-instrumenter-loader": "^3.0.1",
|
|
27
27
|
"istanbul-lib-coverage": "^3.2.0"
|
|
28
28
|
},
|
|
@@ -32,5 +32,5 @@
|
|
|
32
32
|
"publishConfig": {
|
|
33
33
|
"access": "public"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "7ae3fba6332000b35d521411404c11e32052f282"
|
|
36
36
|
}
|
package/src/index.ts
CHANGED
|
@@ -5,13 +5,15 @@ import libCoverage from 'istanbul-lib-coverage';
|
|
|
5
5
|
// Pull `webpack.Configuration` type without needing to import Webpack
|
|
6
6
|
type WebpackConfigType = ReturnType<NonNullable<BundleOptions['webpackConfigHook']>>;
|
|
7
7
|
|
|
8
|
-
// Check if running through nyc or some other Istanbul-based tool.
|
|
9
|
-
// If not, any `workflowCoverage()` tools are a no-op.
|
|
10
|
-
const hasCoverageGlobal = '__coverage__' in global;
|
|
11
|
-
|
|
12
8
|
export class WorkflowCoverage {
|
|
13
9
|
coverageMap = libCoverage.createCoverageMap();
|
|
14
10
|
|
|
11
|
+
// Check if running through nyc or some other Istanbul-based tool.
|
|
12
|
+
// If not, any `workflowCoverage()` tools are a no-op.
|
|
13
|
+
private hasCoverageGlobal() {
|
|
14
|
+
return '__coverage__' in global;
|
|
15
|
+
}
|
|
16
|
+
|
|
15
17
|
/**
|
|
16
18
|
* Add all necessary coverage-specific logic to Worker config:
|
|
17
19
|
* interceptors, sinks, and Webpack config hook.
|
|
@@ -23,7 +25,7 @@ export class WorkflowCoverage {
|
|
|
23
25
|
throw new TypeError('Cannot automatically instrument coverage without specifying `workflowsPath`');
|
|
24
26
|
}
|
|
25
27
|
|
|
26
|
-
if (!hasCoverageGlobal) {
|
|
28
|
+
if (!this.hasCoverageGlobal()) {
|
|
27
29
|
return workerOptions;
|
|
28
30
|
}
|
|
29
31
|
|
|
@@ -67,7 +69,7 @@ export class WorkflowCoverage {
|
|
|
67
69
|
throw new TypeError('Cannot automatically instrument coverage without specifying `workflowsPath`');
|
|
68
70
|
}
|
|
69
71
|
|
|
70
|
-
if (!hasCoverageGlobal) {
|
|
72
|
+
if (!this.hasCoverageGlobal()) {
|
|
71
73
|
return bundleOptions;
|
|
72
74
|
}
|
|
73
75
|
|
|
@@ -101,7 +103,7 @@ export class WorkflowCoverage {
|
|
|
101
103
|
);
|
|
102
104
|
}
|
|
103
105
|
|
|
104
|
-
if (!hasCoverageGlobal) {
|
|
106
|
+
if (!this.hasCoverageGlobal()) {
|
|
105
107
|
return workerOptions;
|
|
106
108
|
}
|
|
107
109
|
|
|
@@ -142,7 +144,7 @@ export class WorkflowCoverage {
|
|
|
142
144
|
* code using istanbul-instrumenter-loader
|
|
143
145
|
*/
|
|
144
146
|
addInstrumenterRule(workflowsPath: string, config: WebpackConfigType): WebpackConfigType {
|
|
145
|
-
if (!hasCoverageGlobal) {
|
|
147
|
+
if (!this.hasCoverageGlobal()) {
|
|
146
148
|
return config;
|
|
147
149
|
}
|
|
148
150
|
|
|
@@ -169,7 +171,7 @@ export class WorkflowCoverage {
|
|
|
169
171
|
* map data `global.__coverage__`.
|
|
170
172
|
*/
|
|
171
173
|
mergeIntoGlobalCoverage(): void {
|
|
172
|
-
if (!hasCoverageGlobal) {
|
|
174
|
+
if (!this.hasCoverageGlobal()) {
|
|
173
175
|
return;
|
|
174
176
|
}
|
|
175
177
|
|