@nsshunt/stsrunnerframework 1.0.68 → 1.0.69
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/README.md +149 -1
- package/package.json +1 -1
- package/types/{mockedWorkerTestRunner01.d.ts → testing/mockedWorkerTestRunner01.d.ts} +1 -2
- package/types/testing/mockedWorkerTestRunner01.d.ts.map +1 -0
- package/types/{testCase01.d.ts → testing/testCase01.d.ts} +1 -2
- package/types/testing/testCase01.d.ts.map +1 -0
- package/types/testing/wmwokerProcess.test.d.ts.map +1 -0
- package/types/index.test.d.ts +0 -2
- package/types/index.test.d.ts.map +0 -1
- package/types/mockedWorkerTestRunner01.d.ts.map +0 -1
- package/types/testCase01.d.ts.map +0 -1
- package/types/wmwokerProcess.test.d.ts.map +0 -1
- package/types/workerWorkerTestRunner01.d.ts +0 -7
- package/types/workerWorkerTestRunner01.d.ts.map +0 -1
- package/types/workerWorkerTestRunner01Agent.d.ts +0 -7
- package/types/workerWorkerTestRunner01Agent.d.ts.map +0 -1
- /package/types/{wmwokerProcess.test.d.ts → testing/wmwokerProcess.test.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ terminated - this means the process has been terminated and no end-of-process st
|
|
|
4
4
|
|
|
5
5
|
stopped - end the test and report as if completed normnally
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
# State Machine
|
|
8
8
|
```mermaid
|
|
9
9
|
---
|
|
10
10
|
config:
|
|
@@ -32,3 +32,151 @@ stateDiagram
|
|
|
32
32
|
Error --> [*]
|
|
33
33
|
Stopped --> [*]
|
|
34
34
|
```
|
|
35
|
+
|
|
36
|
+
# Nodejs Factory Instance Example
|
|
37
|
+
```typescript
|
|
38
|
+
/* eslint @typescript-eslint/no-unused-vars: 0, @typescript-eslint/no-explicit-any: 0 */ // --> OFF
|
|
39
|
+
import { IRunnerInstance, ITestRunnerTelemetryPayload, eIWMessageCommands, WorkerInstance } from './../index'
|
|
40
|
+
import { TestCase01 } from './testCase01'
|
|
41
|
+
|
|
42
|
+
import isNode from 'detect-node'
|
|
43
|
+
|
|
44
|
+
import { parentPort } from 'worker_threads';
|
|
45
|
+
|
|
46
|
+
export class WorkerTestCases extends WorkerInstance {
|
|
47
|
+
constructor() {
|
|
48
|
+
super()
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
override CreateAsyncRunner = (testRunnerTelemetryPayload: ITestRunnerTelemetryPayload): IRunnerInstance | null => {
|
|
52
|
+
const { runner } = testRunnerTelemetryPayload;
|
|
53
|
+
switch (runner.options.testType) {
|
|
54
|
+
case 'TestCase01' :
|
|
55
|
+
return new TestCase01(this, runner)
|
|
56
|
+
}
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const worker = new WorkerTestCases();
|
|
62
|
+
|
|
63
|
+
parentPort?.on('message', (data: any) => {
|
|
64
|
+
if (isNode) {
|
|
65
|
+
const { command, payload } = data;
|
|
66
|
+
if (command === eIWMessageCommands.MessagePort) {
|
|
67
|
+
payload.port.on('message', (data: any) => {
|
|
68
|
+
worker.ProcessMessage(data);
|
|
69
|
+
});
|
|
70
|
+
worker.ProcessMessage(data);
|
|
71
|
+
} else {
|
|
72
|
+
throw new Error(`Invalid command: [${command}]`)
|
|
73
|
+
}
|
|
74
|
+
} else {
|
|
75
|
+
const { command, payload } = data.data;
|
|
76
|
+
if (command === eIWMessageCommands.MessagePort) {
|
|
77
|
+
payload.port.on('message', (data: any) => {
|
|
78
|
+
// const payloadMessage: IIWMessagePayload = data.data as IIWMessagePayload; // browser version
|
|
79
|
+
worker.ProcessMessage(data.data); // browser version
|
|
80
|
+
});
|
|
81
|
+
worker.ProcessMessage(data.data);
|
|
82
|
+
} else {
|
|
83
|
+
throw new Error(`Invalid command: [${command}]`)
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
# Agent Factory Instance Example
|
|
90
|
+
```typescript
|
|
91
|
+
/* eslint @typescript-eslint/no-unused-vars: 0, @typescript-eslint/no-explicit-any: 0 */ // --> OFF
|
|
92
|
+
import { IRunnerInstance, ITestRunnerTelemetryPayload, WorkerInstance, eIWMessageCommands } from './../index'
|
|
93
|
+
import { TestCase01 } from './testCase01'
|
|
94
|
+
|
|
95
|
+
import isNode from 'detect-node'
|
|
96
|
+
|
|
97
|
+
export class WorkerTestCases extends WorkerInstance {
|
|
98
|
+
constructor() {
|
|
99
|
+
super()
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
override CreateAsyncRunner = (testRunnerTelemetryPayload: ITestRunnerTelemetryPayload): IRunnerInstance | null => {
|
|
103
|
+
const { runner } = testRunnerTelemetryPayload;
|
|
104
|
+
switch (runner.options.testType) {
|
|
105
|
+
case 'TestCase01' :
|
|
106
|
+
return new TestCase01(this, runner)
|
|
107
|
+
}
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const worker = new WorkerTestCases();
|
|
113
|
+
|
|
114
|
+
onmessage = async function(data: any) {
|
|
115
|
+
if (isNode) {
|
|
116
|
+
const { command, payload } = data;
|
|
117
|
+
if (command === eIWMessageCommands.MessagePort) {
|
|
118
|
+
payload.port.on('message', (data: any) => {
|
|
119
|
+
worker.ProcessMessage(data);
|
|
120
|
+
});
|
|
121
|
+
worker.ProcessMessage(data);
|
|
122
|
+
} else {
|
|
123
|
+
throw new Error(`Invalid command: [${command}]`)
|
|
124
|
+
}
|
|
125
|
+
} else {
|
|
126
|
+
const { command, payload } = data.data;
|
|
127
|
+
if (command === eIWMessageCommands.MessagePort) {
|
|
128
|
+
payload.port.on('message', (data: any) => {
|
|
129
|
+
// const payloadMessage: IIWMessagePayload = data.data as IIWMessagePayload; // browser version
|
|
130
|
+
worker.ProcessMessage(data.data); // browser version
|
|
131
|
+
});
|
|
132
|
+
worker.ProcessMessage(data.data);
|
|
133
|
+
} else {
|
|
134
|
+
throw new Error(`Invalid command: [${command}]`)
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
# Mocked Factory Instance Example (for testing only)
|
|
141
|
+
```typescript
|
|
142
|
+
/* eslint @typescript-eslint/no-unused-vars: 0, @typescript-eslint/no-explicit-any: 0 */ // --> OFF
|
|
143
|
+
import { IRunnerInstance, ITestRunnerTelemetryPayload, WorkerInstance } from './../index'
|
|
144
|
+
import { TestCase01 } from './testCase01'
|
|
145
|
+
|
|
146
|
+
import { MessagePort } from 'worker_threads';
|
|
147
|
+
|
|
148
|
+
import isNode from 'detect-node'
|
|
149
|
+
import { JSONObject } from '@nsshunt/stsutils';
|
|
150
|
+
|
|
151
|
+
export class WorkerTestCases extends WorkerInstance {
|
|
152
|
+
#port: MessagePort | null = null;
|
|
153
|
+
|
|
154
|
+
constructor() {
|
|
155
|
+
super()
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
SetPort = (message: JSONObject) => {
|
|
159
|
+
this.#port = message.payload.port as MessagePort;
|
|
160
|
+
|
|
161
|
+
this.#port.on('message', (data: any) => {
|
|
162
|
+
if (isNode) {
|
|
163
|
+
this.ProcessMessage(data);
|
|
164
|
+
} else {
|
|
165
|
+
// const payloadMessage: IIWMessagePayload = data.data as IIWMessagePayload; // browser version
|
|
166
|
+
this.ProcessMessage(data.data); // browser version
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
this.ProcessMessage(message);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
override CreateAsyncRunner = (testRunnerTelemetryPayload: ITestRunnerTelemetryPayload): IRunnerInstance | null => {
|
|
174
|
+
const { runner } = testRunnerTelemetryPayload;
|
|
175
|
+
switch (runner.options.testType) {
|
|
176
|
+
case 'TestCase01' :
|
|
177
|
+
return new TestCase01(this, runner)
|
|
178
|
+
}
|
|
179
|
+
return null;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
```
|
package/package.json
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { IRunnerInstance, ITestRunnerTelemetryPayload } from '
|
|
2
|
-
import { WorkerInstance } from './workerInstance';
|
|
1
|
+
import { IRunnerInstance, ITestRunnerTelemetryPayload, WorkerInstance } from './../index';
|
|
3
2
|
import { JSONObject } from '@nsshunt/stsutils';
|
|
4
3
|
export declare class WorkerTestCases extends WorkerInstance {
|
|
5
4
|
#private;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mockedWorkerTestRunner01.d.ts","sourceRoot":"","sources":["../../src/testing/mockedWorkerTestRunner01.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,2BAA2B,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAMzF,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,qBAAa,eAAgB,SAAQ,cAAc;;;IAO/C,OAAO,GAAI,SAAS,UAAU,UAa7B;IAEQ,iBAAiB,GAAI,4BAA4B,2BAA2B,KAAG,eAAe,GAAG,IAAI,CAO7G;CACJ"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { IRunnerInstance, IRunnerOptions, IRunner } from '
|
|
2
|
-
import { WorkerInstance } from './workerInstance';
|
|
1
|
+
import { IRunnerInstance, IRunnerOptions, IRunner, WorkerInstance } from './../index';
|
|
3
2
|
export interface IRunnerOptionsEx extends IRunnerOptions {
|
|
4
3
|
sleepDuration: number;
|
|
5
4
|
logMessageMod: number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testCase01.d.ts","sourceRoot":"","sources":["../../src/testing/testCase01.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAcrF,MAAM,WAAW,gBAAiB,SAAQ,cAAc;IACpD,aAAa,EAAE,MAAM,CAAA;IACrB,aAAa,EAAE,MAAM,CAAA;IACrB,WAAW,EAAE,MAAM,CAAA;CACtB;AAED,qBAAa,UAAW,YAAW,eAAe;;gBASlC,cAAc,EAAE,cAAc,EAAE,MAAM,EAAE,OAAO;IAmG3D,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;IAM/B,OAAO,GAAU,WAAW,MAAM,KAAG,OAAO,CAAC,OAAO,CAAC,CAkCpD;IASD,WAAW,QAAa,OAAO,CAAC,OAAO,CAAC,CAIvC;IAED,UAAU,QAAa,OAAO,CAAC,OAAO,CAAC,CAItC;IAED,eAAe,QAAa,OAAO,CAAC,OAAO,CAAC,CAI3C;IAED,SAAS,QAAa,OAAO,CAAC,OAAO,CAAC,CAIrC;IAED,WAAW,QAAa,OAAO,CAAC,OAAO,CAAC,CAIvC;IAED,YAAY,QAAa,OAAO,CAAC,OAAO,CAAC,CAIxC;IAED,WAAW,QAAa,OAAO,CAAC,OAAO,CAAC,CAKvC;IAED,aAAa,QAAa,OAAO,CAAC,OAAO,CAAC,CAIzC;CACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wmwokerProcess.test.d.ts","sourceRoot":"","sources":["../../src/testing/wmwokerProcess.test.ts"],"names":[],"mappings":""}
|
package/types/index.test.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../src/index.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mockedWorkerTestRunner01.d.ts","sourceRoot":"","sources":["../src/mockedWorkerTestRunner01.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,2BAA2B,EAAE,MAAM,eAAe,CAAA;AAC5E,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAMjD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,qBAAa,eAAgB,SAAQ,cAAc;;;IAO/C,OAAO,GAAI,SAAS,UAAU,UAa7B;IAEQ,iBAAiB,GAAI,4BAA4B,2BAA2B,KAAG,eAAe,GAAG,IAAI,CAO7G;CACJ"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"testCase01.d.ts","sourceRoot":"","sources":["../src/testCase01.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAIxE,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAYjD,MAAM,WAAW,gBAAiB,SAAQ,cAAc;IACpD,aAAa,EAAE,MAAM,CAAA;IACrB,aAAa,EAAE,MAAM,CAAA;IACrB,WAAW,EAAE,MAAM,CAAA;CACtB;AAED,qBAAa,UAAW,YAAW,eAAe;;gBASlC,cAAc,EAAE,cAAc,EAAE,MAAM,EAAE,OAAO;IAmG3D,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;IAM/B,OAAO,GAAU,WAAW,MAAM,KAAG,OAAO,CAAC,OAAO,CAAC,CAkCpD;IASD,WAAW,QAAa,OAAO,CAAC,OAAO,CAAC,CAIvC;IAED,UAAU,QAAa,OAAO,CAAC,OAAO,CAAC,CAItC;IAED,eAAe,QAAa,OAAO,CAAC,OAAO,CAAC,CAI3C;IAED,SAAS,QAAa,OAAO,CAAC,OAAO,CAAC,CAIrC;IAED,WAAW,QAAa,OAAO,CAAC,OAAO,CAAC,CAIvC;IAED,YAAY,QAAa,OAAO,CAAC,OAAO,CAAC,CAIxC;IAED,WAAW,QAAa,OAAO,CAAC,OAAO,CAAC,CAKvC;IAED,aAAa,QAAa,OAAO,CAAC,OAAO,CAAC,CAIzC;CACJ"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"wmwokerProcess.test.d.ts","sourceRoot":"","sources":["../src/wmwokerProcess.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { IRunnerInstance, ITestRunnerTelemetryPayload } from './commonTypes';
|
|
2
|
-
import { WorkerInstance } from './workerInstance';
|
|
3
|
-
export declare class WorkerTestCases extends WorkerInstance {
|
|
4
|
-
constructor();
|
|
5
|
-
CreateAsyncRunner: (testRunnerTelemetryPayload: ITestRunnerTelemetryPayload) => IRunnerInstance | null;
|
|
6
|
-
}
|
|
7
|
-
//# sourceMappingURL=workerWorkerTestRunner01.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"workerWorkerTestRunner01.d.ts","sourceRoot":"","sources":["../src/workerWorkerTestRunner01.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,2BAA2B,EAAsB,MAAM,eAAe,CAAA;AAChG,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAQjD,qBAAa,eAAgB,SAAQ,cAAc;;IAKtC,iBAAiB,GAAI,4BAA4B,2BAA2B,KAAG,eAAe,GAAG,IAAI,CAO7G;CACJ"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { IRunnerInstance, ITestRunnerTelemetryPayload } from './commonTypes';
|
|
2
|
-
import { WorkerInstance } from './workerInstance';
|
|
3
|
-
export declare class WorkerTestCases extends WorkerInstance {
|
|
4
|
-
constructor();
|
|
5
|
-
CreateAsyncRunner: (testRunnerTelemetryPayload: ITestRunnerTelemetryPayload) => IRunnerInstance | null;
|
|
6
|
-
}
|
|
7
|
-
//# sourceMappingURL=workerWorkerTestRunner01Agent.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"workerWorkerTestRunner01Agent.d.ts","sourceRoot":"","sources":["../src/workerWorkerTestRunner01Agent.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,2BAA2B,EAAE,MAAM,eAAe,CAAA;AAC5E,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAKjD,qBAAa,eAAgB,SAAQ,cAAc;;IAKtC,iBAAiB,GAAI,4BAA4B,2BAA2B,KAAG,eAAe,GAAG,IAAI,CAO7G;CACJ"}
|
|
File without changes
|