testeranto 0.47.11 → 0.47.13
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/dist/common/Features.js +85 -0
- package/dist/common/Node.js +82 -0
- package/dist/common/NodeWriter.js +56 -0
- package/dist/common/Project.js +648 -0
- package/dist/common/Types.js +2 -0
- package/dist/common/Web.js +70 -0
- package/dist/common/core.js +392 -0
- package/dist/common/electron.js +40 -0
- package/dist/common/preload.js +8 -0
- package/dist/common/subPackages/react/component.js +2 -0
- package/dist/common/subPackages/react/node.js +57 -0
- package/dist/common/subPackages/react/web.js +57 -0
- package/dist/common/subPackages/react-test-render/component.js +2 -0
- package/dist/common/subPackages/react-test-render/node.js +46 -0
- package/dist/common/subPackages/react-test-render/web.js +46 -0
- package/dist/common/tsconfig.common.tsbuildinfo +1 -0
- package/dist/module/Features.js +74 -0
- package/dist/module/Node.js +77 -0
- package/dist/module/NodeWriter.js +50 -0
- package/dist/module/Project.js +618 -0
- package/dist/module/Report.js +186 -0
- package/dist/module/Types.js +1 -0
- package/dist/module/Web.js +65 -0
- package/dist/module/core.js +383 -0
- package/dist/module/electron.js +35 -0
- package/dist/module/preload.js +6 -0
- package/dist/module/subPackages/react/component.js +1 -0
- package/dist/module/subPackages/react/node.js +52 -0
- package/dist/module/subPackages/react/web.js +52 -0
- package/dist/module/subPackages/react-test-render/component.js +1 -0
- package/dist/module/subPackages/react-test-render/node.js +16 -0
- package/dist/module/subPackages/react-test-render/web.js +16 -0
- package/dist/module/tsconfig.module.tsbuildinfo +1 -0
- package/dist/types/Features.d.ts +68 -0
- package/dist/types/Node.d.ts +12 -0
- package/dist/types/NodeWriter.d.ts +2 -0
- package/dist/types/Project.d.ts +32 -0
- package/dist/types/Types.d.ts +17 -0
- package/dist/types/Web.d.ts +12 -0
- package/dist/types/core.d.ts +219 -0
- package/dist/types/electron.d.ts +1 -0
- package/dist/types/preload.d.ts +1 -0
- package/dist/types/subPackages/react/component.d.ts +17 -0
- package/dist/types/subPackages/react/node.d.ts +4 -0
- package/dist/types/subPackages/react/web.d.ts +4 -0
- package/dist/types/subPackages/react-test-render/component.d.ts +17 -0
- package/dist/types/subPackages/react-test-render/node.d.ts +4 -0
- package/dist/types/subPackages/react-test-render/web.d.ts +4 -0
- package/dist/types/tsconfig.types.tsbuildinfo +1 -0
- package/package.json +9 -5
- package/src/subPackages/react/component.ts +1 -0
- package/src/subPackages/react-test-render/component.ts +21 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const core_1 = require("./core");
|
|
7
|
+
const core_2 = __importDefault(require("./core"));
|
|
8
|
+
// import { ipcRenderer } from "electron";
|
|
9
|
+
const webSocket = new WebSocket("ws://localhost:8080");
|
|
10
|
+
const receiveTestResourceConfig = async (t, testresource) => {
|
|
11
|
+
const { failed, artifacts, logPromise } = await t.receiveTestResourceConfig(testresource);
|
|
12
|
+
webSocket.send(JSON.stringify({
|
|
13
|
+
type: "testeranto:adios",
|
|
14
|
+
data: {
|
|
15
|
+
failed,
|
|
16
|
+
testResourceConfiguration: t.test.testResourceConfiguration,
|
|
17
|
+
results: t.toObj(),
|
|
18
|
+
},
|
|
19
|
+
}));
|
|
20
|
+
Promise.all([...artifacts, logPromise]).then(async () => {
|
|
21
|
+
// ipcRenderer.invoke('quit-app', failed);
|
|
22
|
+
window.exit(failed);
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
exports.default = async (input, testSpecification, testImplementation, testInterface, testResourceRequirement = core_1.defaultTestResourceRequirement) => {
|
|
26
|
+
const mrt = new core_2.default(input, testSpecification, testImplementation, testInterface, testResourceRequirement, testInterface.assertioner || (async (t) => t), testInterface.beforeEach ||
|
|
27
|
+
async function (subject, initialValues, testResource) {
|
|
28
|
+
return subject;
|
|
29
|
+
}, testInterface.afterEach || (async (s) => s), testInterface.afterAll || ((store) => undefined), testInterface.butThen || (async (a) => a), testInterface.andWhen, testInterface.actionHandler ||
|
|
30
|
+
function (b) {
|
|
31
|
+
return b;
|
|
32
|
+
}, window.NodeWriter);
|
|
33
|
+
const tl2 = mrt;
|
|
34
|
+
const t = tl2.testJobs[0];
|
|
35
|
+
const testResourceArg = decodeURIComponent(new URLSearchParams(location.search).get('requesting') || '');
|
|
36
|
+
try {
|
|
37
|
+
const partialTestResource = JSON.parse(testResourceArg);
|
|
38
|
+
if (partialTestResource.fs && partialTestResource.ports) {
|
|
39
|
+
receiveTestResourceConfig(t, partialTestResource);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
console.log("test configuration is incomplete", partialTestResource);
|
|
43
|
+
console.log("requesting test resources via ws", testResourceRequirement);
|
|
44
|
+
webSocket.addEventListener("open", (event) => {
|
|
45
|
+
webSocket.addEventListener("message", (event) => {
|
|
46
|
+
console.log("Message from server ", event.data);
|
|
47
|
+
});
|
|
48
|
+
const r = JSON.stringify({
|
|
49
|
+
type: "testeranto:hola",
|
|
50
|
+
data: {
|
|
51
|
+
testResourceRequirement,
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
webSocket.send(r);
|
|
55
|
+
console.log("awaiting test resources via websocket...", r);
|
|
56
|
+
webSocket.onmessage = (async (msg) => {
|
|
57
|
+
console.log("message: ", msg);
|
|
58
|
+
const resourcesFromPm2 = msg.data.testResourceConfiguration;
|
|
59
|
+
const secondTestResource = Object.assign(Object.assign({ fs: "." }, JSON.parse(JSON.stringify(partialTestResource))), JSON.parse(JSON.stringify(resourcesFromPm2)));
|
|
60
|
+
console.log("secondTestResource", secondTestResource);
|
|
61
|
+
receiveTestResourceConfig(t, secondTestResource);
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
catch (e) {
|
|
67
|
+
console.error(e);
|
|
68
|
+
// process.exit(-1);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseCheck = exports.BaseThen = exports.BaseWhen = exports.BaseGiven = exports.BaseSuite = exports.defaultTestResourceRequirement = void 0;
|
|
4
|
+
const defaultTestResource = { name: "", fs: ".", ports: [] };
|
|
5
|
+
exports.defaultTestResourceRequirement = {
|
|
6
|
+
ports: 0
|
|
7
|
+
};
|
|
8
|
+
class BaseSuite {
|
|
9
|
+
constructor(name, index, givens = {}, checks = []) {
|
|
10
|
+
this.name = name;
|
|
11
|
+
this.index = index;
|
|
12
|
+
this.givens = givens;
|
|
13
|
+
this.checks = checks;
|
|
14
|
+
this.fails = [];
|
|
15
|
+
}
|
|
16
|
+
toObj() {
|
|
17
|
+
return {
|
|
18
|
+
name: this.name,
|
|
19
|
+
givens: Object.keys(this.givens).map((k) => this.givens[k].toObj()),
|
|
20
|
+
fails: this.fails,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
setup(s, artifactory) {
|
|
24
|
+
return new Promise((res) => res(s));
|
|
25
|
+
}
|
|
26
|
+
test(t) {
|
|
27
|
+
return t;
|
|
28
|
+
}
|
|
29
|
+
async run(input, testResourceConfiguration, artifactory, tLog) {
|
|
30
|
+
this.testResourceConfiguration = testResourceConfiguration;
|
|
31
|
+
const suiteArtifactory = (fPath, value) => artifactory(`suite-${this.index}-${this.name}/${fPath}`, value);
|
|
32
|
+
const subject = await this.setup(input, suiteArtifactory);
|
|
33
|
+
tLog("\nSuite:", this.index, this.name);
|
|
34
|
+
for (const k of Object.keys(this.givens)) {
|
|
35
|
+
const giver = this.givens[k];
|
|
36
|
+
try {
|
|
37
|
+
this.store = await giver.give(subject, k, testResourceConfiguration, this.test, suiteArtifactory, tLog);
|
|
38
|
+
}
|
|
39
|
+
catch (e) {
|
|
40
|
+
console.error(e);
|
|
41
|
+
this.fails.push(giver);
|
|
42
|
+
return this;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
for (const [ndx, thater] of this.checks.entries()) {
|
|
46
|
+
await thater.check(subject, thater.name, testResourceConfiguration, this.test, suiteArtifactory, tLog);
|
|
47
|
+
}
|
|
48
|
+
// @TODO fix me
|
|
49
|
+
for (const k of Object.keys(this.givens)) {
|
|
50
|
+
const giver = this.givens[k];
|
|
51
|
+
giver.afterAll(this.store, artifactory);
|
|
52
|
+
}
|
|
53
|
+
////////////////
|
|
54
|
+
return this;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.BaseSuite = BaseSuite;
|
|
58
|
+
///////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
59
|
+
class BaseGiven {
|
|
60
|
+
constructor(name, features, whens, thens) {
|
|
61
|
+
this.name = name;
|
|
62
|
+
this.features = features;
|
|
63
|
+
this.whens = whens;
|
|
64
|
+
this.thens = thens;
|
|
65
|
+
}
|
|
66
|
+
beforeAll(store, artifactory) {
|
|
67
|
+
return store;
|
|
68
|
+
}
|
|
69
|
+
afterAll(store, artifactory) {
|
|
70
|
+
return store;
|
|
71
|
+
}
|
|
72
|
+
toObj() {
|
|
73
|
+
return {
|
|
74
|
+
name: this.name,
|
|
75
|
+
whens: this.whens.map((w) => w.toObj()),
|
|
76
|
+
thens: this.thens.map((t) => t.toObj()),
|
|
77
|
+
error: this.error ? [this.error, this.error.stack] : null,
|
|
78
|
+
features: this.features,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
async afterEach(store, key, artifactory) {
|
|
82
|
+
return store;
|
|
83
|
+
}
|
|
84
|
+
async give(subject, key, testResourceConfiguration, tester, artifactory, tLog) {
|
|
85
|
+
tLog(`\n Given: ${this.name}`);
|
|
86
|
+
const givenArtifactory = (fPath, value) => artifactory(`given-${key}/${fPath}`, value);
|
|
87
|
+
try {
|
|
88
|
+
this.store = await this.givenThat(subject, testResourceConfiguration, givenArtifactory);
|
|
89
|
+
// tLog(`\n Given this.store`, this.store);
|
|
90
|
+
for (const whenStep of this.whens) {
|
|
91
|
+
await whenStep.test(this.store, testResourceConfiguration, tLog);
|
|
92
|
+
}
|
|
93
|
+
for (const thenStep of this.thens) {
|
|
94
|
+
const t = await thenStep.test(this.store, testResourceConfiguration, tLog);
|
|
95
|
+
tester(t);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
catch (e) {
|
|
99
|
+
this.error = e;
|
|
100
|
+
tLog(e);
|
|
101
|
+
tLog("\u0007"); // bell
|
|
102
|
+
// throw e;
|
|
103
|
+
}
|
|
104
|
+
finally {
|
|
105
|
+
try {
|
|
106
|
+
await this.afterEach(this.store, key, givenArtifactory);
|
|
107
|
+
}
|
|
108
|
+
catch (e) {
|
|
109
|
+
console.error("afterEach failed! no error will be recorded!", e);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return this.store;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
exports.BaseGiven = BaseGiven;
|
|
116
|
+
class BaseWhen {
|
|
117
|
+
constructor(name, actioner) {
|
|
118
|
+
this.name = name;
|
|
119
|
+
this.actioner = actioner;
|
|
120
|
+
}
|
|
121
|
+
toObj() {
|
|
122
|
+
return {
|
|
123
|
+
name: this.name,
|
|
124
|
+
error: this.error,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
async test(store, testResourceConfiguration, tLog) {
|
|
128
|
+
tLog(" When:", this.name);
|
|
129
|
+
try {
|
|
130
|
+
return await this.andWhen(store, this.actioner, testResourceConfiguration);
|
|
131
|
+
}
|
|
132
|
+
catch (e) {
|
|
133
|
+
this.error = true;
|
|
134
|
+
throw e;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
exports.BaseWhen = BaseWhen;
|
|
139
|
+
class BaseThen {
|
|
140
|
+
constructor(name, thenCB) {
|
|
141
|
+
this.name = name;
|
|
142
|
+
this.thenCB = thenCB;
|
|
143
|
+
}
|
|
144
|
+
toObj() {
|
|
145
|
+
return {
|
|
146
|
+
name: this.name,
|
|
147
|
+
error: this.error,
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
async test(store, testResourceConfiguration, tLog) {
|
|
151
|
+
tLog(" Then:", this.name);
|
|
152
|
+
try {
|
|
153
|
+
return this.thenCB(await this.butThen(store, testResourceConfiguration));
|
|
154
|
+
}
|
|
155
|
+
catch (e) {
|
|
156
|
+
console.log("test failed", e);
|
|
157
|
+
this.error = true;
|
|
158
|
+
throw e;
|
|
159
|
+
}
|
|
160
|
+
// try {
|
|
161
|
+
// return await (this.thenCB(
|
|
162
|
+
// await (async () => {
|
|
163
|
+
// try {
|
|
164
|
+
// return await (
|
|
165
|
+
// (() => {
|
|
166
|
+
// try {
|
|
167
|
+
// return this.butThen(store, testResourceConfiguration)
|
|
168
|
+
// } catch (e) {
|
|
169
|
+
// this.error = true;
|
|
170
|
+
// throw e
|
|
171
|
+
// }
|
|
172
|
+
// })()
|
|
173
|
+
// );
|
|
174
|
+
// } catch (e) {
|
|
175
|
+
// this.error = true;
|
|
176
|
+
// throw e
|
|
177
|
+
// }
|
|
178
|
+
// })()
|
|
179
|
+
// ));
|
|
180
|
+
// } catch (e) {
|
|
181
|
+
// this.error = true;
|
|
182
|
+
// throw e
|
|
183
|
+
// }
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
exports.BaseThen = BaseThen;
|
|
187
|
+
class BaseCheck {
|
|
188
|
+
constructor(name, features, checkCB, whens, thens) {
|
|
189
|
+
this.name = name;
|
|
190
|
+
this.features = features;
|
|
191
|
+
this.checkCB = checkCB;
|
|
192
|
+
this.whens = whens;
|
|
193
|
+
this.thens = thens;
|
|
194
|
+
}
|
|
195
|
+
async afterEach(store, key, cb) {
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
async check(subject, key, testResourceConfiguration, tester, artifactory, tLog) {
|
|
199
|
+
tLog(`\n Check: ${this.name}`);
|
|
200
|
+
const store = await this.checkThat(subject, testResourceConfiguration, artifactory);
|
|
201
|
+
await this.checkCB(Object.entries(this.whens).reduce((a, [key, when]) => {
|
|
202
|
+
a[key] = async (payload) => {
|
|
203
|
+
return await when(payload, testResourceConfiguration).test(store, testResourceConfiguration, tLog);
|
|
204
|
+
};
|
|
205
|
+
return a;
|
|
206
|
+
}, {}), Object.entries(this.thens).reduce((a, [key, then]) => {
|
|
207
|
+
a[key] = async (payload) => {
|
|
208
|
+
const t = await then(payload, testResourceConfiguration).test(store, testResourceConfiguration, tLog);
|
|
209
|
+
tester(t);
|
|
210
|
+
};
|
|
211
|
+
return a;
|
|
212
|
+
}, {}));
|
|
213
|
+
await this.afterEach(store, key);
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
exports.BaseCheck = BaseCheck;
|
|
218
|
+
///////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
219
|
+
class TesterantoLevelZero {
|
|
220
|
+
constructor(cc, suitesOverrides, givenOverides, whenOverides, thenOverides, checkOverides) {
|
|
221
|
+
this.cc = cc;
|
|
222
|
+
this.constructorator = cc;
|
|
223
|
+
this.suitesOverrides = suitesOverrides;
|
|
224
|
+
this.givenOverides = givenOverides;
|
|
225
|
+
this.whenOverides = whenOverides;
|
|
226
|
+
this.thenOverides = thenOverides;
|
|
227
|
+
this.checkOverides = checkOverides;
|
|
228
|
+
}
|
|
229
|
+
Suites() {
|
|
230
|
+
return this.suitesOverrides;
|
|
231
|
+
}
|
|
232
|
+
Given() {
|
|
233
|
+
return this.givenOverides;
|
|
234
|
+
}
|
|
235
|
+
When() {
|
|
236
|
+
return this.whenOverides;
|
|
237
|
+
}
|
|
238
|
+
Then() {
|
|
239
|
+
return this.thenOverides;
|
|
240
|
+
}
|
|
241
|
+
Check() {
|
|
242
|
+
return this.checkOverides;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
///////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
246
|
+
class TesterantoLevelOne {
|
|
247
|
+
constructor(testImplementation, testSpecification, input, suiteKlasser, givenKlasser, whenKlasser, thenKlasser, checkKlasser, testResourceRequirement, logWriter) {
|
|
248
|
+
this.artifacts = [];
|
|
249
|
+
const classySuites = Object.entries(testImplementation.Suites).reduce((a, [key], index) => {
|
|
250
|
+
a[key] = (somestring, givens, checks) => {
|
|
251
|
+
return new suiteKlasser.prototype.constructor(somestring, index, givens, checks);
|
|
252
|
+
};
|
|
253
|
+
return a;
|
|
254
|
+
}, {});
|
|
255
|
+
const classyGivens = Object.keys(testImplementation.Givens)
|
|
256
|
+
.reduce((a, key) => {
|
|
257
|
+
a[key] = (features, whens, thens, ...xtrasW) => {
|
|
258
|
+
return new givenKlasser.prototype.constructor(key, features, whens, thens, testImplementation.Givens[key](...xtrasW));
|
|
259
|
+
};
|
|
260
|
+
return a;
|
|
261
|
+
}, {});
|
|
262
|
+
const classyWhens = Object.entries(testImplementation.Whens).reduce((a, [key, whEn]) => {
|
|
263
|
+
a[key] = (payload) => {
|
|
264
|
+
return new whenKlasser.prototype.constructor(`${whEn.name}: ${payload && payload.toString()}`, whEn(payload));
|
|
265
|
+
};
|
|
266
|
+
return a;
|
|
267
|
+
}, {});
|
|
268
|
+
const classyThens = Object.entries(testImplementation.Thens).reduce((a, [key, thEn]) => {
|
|
269
|
+
a[key] = (expected, x) => {
|
|
270
|
+
return new thenKlasser.prototype.constructor(`${thEn.name}: ${expected && expected.toString()}`, thEn(expected));
|
|
271
|
+
};
|
|
272
|
+
return a;
|
|
273
|
+
}, {});
|
|
274
|
+
const classyChecks = Object.entries(testImplementation.Checks).reduce((a, [key, z]) => {
|
|
275
|
+
a[key] = (somestring, features, callback) => {
|
|
276
|
+
return new checkKlasser.prototype.constructor(somestring, features, callback, classyWhens, classyThens);
|
|
277
|
+
};
|
|
278
|
+
return a;
|
|
279
|
+
}, {});
|
|
280
|
+
const classyTesteranto = new (class extends TesterantoLevelZero {
|
|
281
|
+
})(input, classySuites, classyGivens, classyWhens, classyThens, classyChecks);
|
|
282
|
+
const suites = testSpecification(
|
|
283
|
+
/* @ts-ignore:next-line */
|
|
284
|
+
classyTesteranto.Suites(), classyTesteranto.Given(), classyTesteranto.When(), classyTesteranto.Then(), classyTesteranto.Check(), logWriter);
|
|
285
|
+
const suiteRunner = (suite) => async (testResourceConfiguration, tLog) => {
|
|
286
|
+
return await suite.run(input, testResourceConfiguration, (fPath, value) => logWriter.testArtiFactoryfileWriter(tLog, (p) => {
|
|
287
|
+
artifacts.push(p);
|
|
288
|
+
})(testResourceConfiguration.fs + "/" + fPath, value), tLog);
|
|
289
|
+
};
|
|
290
|
+
const artifacts = this.artifacts;
|
|
291
|
+
this.testJobs = suites.map((suite) => {
|
|
292
|
+
const runner = suiteRunner(suite);
|
|
293
|
+
return {
|
|
294
|
+
test: suite,
|
|
295
|
+
testResourceRequirement,
|
|
296
|
+
toObj: () => {
|
|
297
|
+
return suite.toObj();
|
|
298
|
+
},
|
|
299
|
+
runner,
|
|
300
|
+
receiveTestResourceConfig: async function (testResourceConfiguration = defaultTestResource) {
|
|
301
|
+
console.log(`testResourceConfiguration ${JSON.stringify(testResourceConfiguration, null, 2)}`);
|
|
302
|
+
await logWriter.mkdirSync(testResourceConfiguration.fs);
|
|
303
|
+
const logFilePath = (`${testResourceConfiguration.fs}/log.txt`);
|
|
304
|
+
const access = await logWriter.createWriteStream(logFilePath);
|
|
305
|
+
const tLog = (...l) => {
|
|
306
|
+
console.log(...l);
|
|
307
|
+
access.write(`${l.toString()}\n`);
|
|
308
|
+
};
|
|
309
|
+
const suiteDone = await runner(testResourceConfiguration, tLog);
|
|
310
|
+
const resultsFilePath = (`${testResourceConfiguration.fs}/results.json`);
|
|
311
|
+
logWriter.writeFileSync(resultsFilePath, JSON.stringify(suiteDone.toObj(), null, 2));
|
|
312
|
+
const logPromise = new Promise((res, rej) => {
|
|
313
|
+
access.on("finish", () => { res(true); });
|
|
314
|
+
});
|
|
315
|
+
access.end();
|
|
316
|
+
const numberOfFailures = Object.keys(suiteDone.givens).filter((k) => {
|
|
317
|
+
// console.log(`suiteDone.givens[k].error`, suiteDone.givens[k].error);
|
|
318
|
+
return suiteDone.givens[k].error;
|
|
319
|
+
}).length;
|
|
320
|
+
console.log(`exiting gracefully with ${numberOfFailures} failures.`);
|
|
321
|
+
return {
|
|
322
|
+
failed: numberOfFailures,
|
|
323
|
+
artifacts,
|
|
324
|
+
logPromise
|
|
325
|
+
};
|
|
326
|
+
},
|
|
327
|
+
};
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
////////////////////////////////////////////////////////////////////////////////////////////////
|
|
332
|
+
class TesterantoLevelTwo extends TesterantoLevelOne {
|
|
333
|
+
constructor(input, testSpecification, testImplementation, testInterface, testResourceRequirement = exports.defaultTestResourceRequirement, assertioner, beforeEach, afterEach, afterAll, butThen, andWhen, actionHandler, logWriter) {
|
|
334
|
+
super(testImplementation, testSpecification, input, class extends BaseSuite {
|
|
335
|
+
async setup(s, artifactory) {
|
|
336
|
+
return (testInterface.beforeAll || (async (input, artificer) => input))(s, artifactory, this.testResourceConfiguration);
|
|
337
|
+
}
|
|
338
|
+
test(t) {
|
|
339
|
+
return assertioner(t);
|
|
340
|
+
}
|
|
341
|
+
}, class Given extends BaseGiven {
|
|
342
|
+
constructor(name, features, whens, thens, initialValues) {
|
|
343
|
+
super(name, features, whens, thens);
|
|
344
|
+
this.initialValues = initialValues;
|
|
345
|
+
}
|
|
346
|
+
async givenThat(subject, testResource, artifactory) {
|
|
347
|
+
return beforeEach(subject, this.initialValues, testResource, (fPath, value) =>
|
|
348
|
+
// TODO does not work?
|
|
349
|
+
artifactory(`beforeEach/${fPath}`, value));
|
|
350
|
+
}
|
|
351
|
+
afterEach(store, key, artifactory) {
|
|
352
|
+
return new Promise((res) => res(afterEach(store, key, (fPath, value) => artifactory(`after/${fPath}`, value))));
|
|
353
|
+
}
|
|
354
|
+
afterAll(store, artifactory) {
|
|
355
|
+
return afterAll(store, (fPath, value) =>
|
|
356
|
+
// TODO does not work?
|
|
357
|
+
artifactory(`afterAll4-${this.name}/${fPath}`, value));
|
|
358
|
+
}
|
|
359
|
+
}, class When extends BaseWhen {
|
|
360
|
+
constructor(name, actioner, payload) {
|
|
361
|
+
super(name, (store) => {
|
|
362
|
+
return actionHandler(actioner);
|
|
363
|
+
});
|
|
364
|
+
this.payload = payload;
|
|
365
|
+
}
|
|
366
|
+
async andWhen(store, actioner, testResource) {
|
|
367
|
+
return await andWhen(store, actioner, testResource);
|
|
368
|
+
}
|
|
369
|
+
}, class Then extends BaseThen {
|
|
370
|
+
constructor(name, callback) {
|
|
371
|
+
super(name, callback);
|
|
372
|
+
}
|
|
373
|
+
async butThen(store, testResourceConfiguration) {
|
|
374
|
+
return await butThen(store, this.thenCB, testResourceConfiguration);
|
|
375
|
+
}
|
|
376
|
+
}, class Check extends BaseCheck {
|
|
377
|
+
constructor(name, features, checkCallback, whens, thens, initialValues) {
|
|
378
|
+
super(name, features, checkCallback, whens, thens);
|
|
379
|
+
this.initialValues = initialValues;
|
|
380
|
+
}
|
|
381
|
+
async checkThat(subject, testResourceConfiguration, artifactory) {
|
|
382
|
+
return beforeEach(subject, this.initialValues, testResourceConfiguration, (fPath, value) => artifactory(`before/${fPath}`, value));
|
|
383
|
+
}
|
|
384
|
+
afterEach(store, key, artifactory) {
|
|
385
|
+
return new Promise((res) => res(afterEach(store, key, (fPath, value) =>
|
|
386
|
+
// TODO does not work?
|
|
387
|
+
artifactory(`afterEach2-${this.name}/${fPath}`, value))));
|
|
388
|
+
}
|
|
389
|
+
}, testResourceRequirement, logWriter);
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
exports.default = TesterantoLevelTwo;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const electron_1 = require("electron");
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const url_1 = __importDefault(require("url"));
|
|
9
|
+
let win;
|
|
10
|
+
function createWindow() {
|
|
11
|
+
win = new electron_1.BrowserWindow({
|
|
12
|
+
webPreferences: {
|
|
13
|
+
devTools: true,
|
|
14
|
+
nodeIntegration: true,
|
|
15
|
+
nodeIntegrationInWorker: true,
|
|
16
|
+
contextIsolation: false,
|
|
17
|
+
preload: path_1.default.join(electron_1.app.getAppPath(), 'preload.js'),
|
|
18
|
+
sandbox: false
|
|
19
|
+
},
|
|
20
|
+
width: 800,
|
|
21
|
+
height: 600,
|
|
22
|
+
// show: false,
|
|
23
|
+
});
|
|
24
|
+
const u = url_1.default.format({
|
|
25
|
+
pathname: path_1.default.join(process.cwd(), process.argv[2]),
|
|
26
|
+
protocol: "file:",
|
|
27
|
+
slashes: true,
|
|
28
|
+
query: {
|
|
29
|
+
requesting: encodeURIComponent(process.argv[3]),
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
console.log("loading", u);
|
|
33
|
+
win.loadURL(u);
|
|
34
|
+
win.webContents.openDevTools();
|
|
35
|
+
}
|
|
36
|
+
electron_1.app.on("ready", createWindow);
|
|
37
|
+
electron_1.ipcMain.handle('quit-app', (x, failed) => {
|
|
38
|
+
console.log("quit-app", failed);
|
|
39
|
+
// app.exit(failed);
|
|
40
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const NodeWriter_1 = require("./NodeWriter");
|
|
4
|
+
const electron_1 = require("electron");
|
|
5
|
+
window.NodeWriter = NodeWriter_1.NodeWriter;
|
|
6
|
+
window.exit = (x) => {
|
|
7
|
+
electron_1.ipcRenderer.invoke('quit-app', x);
|
|
8
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const react_1 = __importDefault(require("react"));
|
|
7
|
+
const client_1 = __importDefault(require("react-dom/client"));
|
|
8
|
+
const Node_1 = __importDefault(require("../../Node"));
|
|
9
|
+
exports.default = (testImplementations, testSpecifications, testInput) => {
|
|
10
|
+
class TesterantoComponent extends testInput {
|
|
11
|
+
constructor(props) {
|
|
12
|
+
super(props);
|
|
13
|
+
this.done = props.done;
|
|
14
|
+
}
|
|
15
|
+
componentDidMount() {
|
|
16
|
+
super.componentDidMount && super.componentDidMount();
|
|
17
|
+
return this.done(this);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return (0, Node_1.default)(testInput, testSpecifications, testImplementations, {
|
|
21
|
+
beforeAll: async (prototype, artificer) => {
|
|
22
|
+
return await new Promise((resolve, rej) => {
|
|
23
|
+
document.addEventListener("DOMContentLoaded", function () {
|
|
24
|
+
const elem = document.getElementById("root");
|
|
25
|
+
if (elem) {
|
|
26
|
+
resolve({ htmlElement: elem });
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
},
|
|
31
|
+
beforeEach: async ({ htmlElement }, ndx, testRsource, artificer) => {
|
|
32
|
+
return new Promise((resolve, rej) => {
|
|
33
|
+
const reactElement = react_1.default.createElement(TesterantoComponent, {
|
|
34
|
+
done: (reactElement) => {
|
|
35
|
+
resolve({
|
|
36
|
+
htmlElement,
|
|
37
|
+
reactElement,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}, []);
|
|
41
|
+
client_1.default.createRoot(htmlElement).render(reactElement);
|
|
42
|
+
});
|
|
43
|
+
},
|
|
44
|
+
andWhen: function (s, actioner) {
|
|
45
|
+
return actioner()(s);
|
|
46
|
+
},
|
|
47
|
+
butThen: async function (s) {
|
|
48
|
+
return s;
|
|
49
|
+
},
|
|
50
|
+
afterEach: async function (store, ndx, artificer) {
|
|
51
|
+
return {};
|
|
52
|
+
},
|
|
53
|
+
afterAll: (store, artificer) => {
|
|
54
|
+
return;
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const react_1 = __importDefault(require("react"));
|
|
7
|
+
const client_1 = __importDefault(require("react-dom/client"));
|
|
8
|
+
const Web_1 = __importDefault(require("../../Web"));
|
|
9
|
+
exports.default = (testImplementations, testSpecifications, testInput) => {
|
|
10
|
+
class TesterantoComponent extends testInput {
|
|
11
|
+
constructor(props) {
|
|
12
|
+
super(props);
|
|
13
|
+
this.done = props.done;
|
|
14
|
+
}
|
|
15
|
+
componentDidMount() {
|
|
16
|
+
super.componentDidMount && super.componentDidMount();
|
|
17
|
+
return this.done(this);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return (0, Web_1.default)(testInput, testSpecifications, testImplementations, {
|
|
21
|
+
beforeAll: async (prototype, artificer) => {
|
|
22
|
+
return await new Promise((resolve, rej) => {
|
|
23
|
+
document.addEventListener("DOMContentLoaded", function () {
|
|
24
|
+
const elem = document.getElementById("root");
|
|
25
|
+
if (elem) {
|
|
26
|
+
resolve({ htmlElement: elem });
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
},
|
|
31
|
+
beforeEach: async ({ htmlElement }, ndx, testRsource, artificer) => {
|
|
32
|
+
return new Promise((resolve, rej) => {
|
|
33
|
+
const reactElement = react_1.default.createElement(TesterantoComponent, {
|
|
34
|
+
done: (reactElement) => {
|
|
35
|
+
resolve({
|
|
36
|
+
htmlElement,
|
|
37
|
+
reactElement,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}, []);
|
|
41
|
+
client_1.default.createRoot(htmlElement).render(reactElement);
|
|
42
|
+
});
|
|
43
|
+
},
|
|
44
|
+
andWhen: function (s, actioner) {
|
|
45
|
+
return actioner()(s);
|
|
46
|
+
},
|
|
47
|
+
butThen: async function (s) {
|
|
48
|
+
return s;
|
|
49
|
+
},
|
|
50
|
+
afterEach: async function (store, ndx, artificer) {
|
|
51
|
+
return {};
|
|
52
|
+
},
|
|
53
|
+
afterAll: (store, artificer) => {
|
|
54
|
+
return;
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.ReactTestRendererTesteranto = void 0;
|
|
30
|
+
const react_1 = __importDefault(require("react"));
|
|
31
|
+
const react_test_renderer_1 = __importStar(require("react-test-renderer"));
|
|
32
|
+
const Web_1 = __importDefault(require("../../Web"));
|
|
33
|
+
const ReactTestRendererTesteranto = (testImplementations, testSpecifications, testInput) => (0, Web_1.default)(testInput, testSpecifications, testImplementations, {
|
|
34
|
+
beforeEach: function (CComponent, props) {
|
|
35
|
+
let component;
|
|
36
|
+
(0, react_test_renderer_1.act)(() => {
|
|
37
|
+
component = react_test_renderer_1.default.create(react_1.default.createElement(CComponent, props, []));
|
|
38
|
+
});
|
|
39
|
+
return component;
|
|
40
|
+
},
|
|
41
|
+
andWhen: async function (renderer, actioner) {
|
|
42
|
+
await (0, react_test_renderer_1.act)(() => actioner()(renderer));
|
|
43
|
+
return renderer;
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
exports.ReactTestRendererTesteranto = ReactTestRendererTesteranto;
|