testeranto 0.166.0 → 0.167.0
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/src/Pure.js +2 -2
- package/dist/common/src/lib/baseBuilder.test/baseBuilder.test.mock.js +1 -1
- package/dist/common/src/lib/basebuilder.js +9 -7
- package/dist/common/src/lib/core.test/MockCore.js +17 -15
- package/dist/common/tsconfig.common.tsbuildinfo +1 -1
- package/dist/module/src/Pure.js +2 -2
- package/dist/module/src/lib/baseBuilder.test/baseBuilder.test.mock.js +1 -1
- package/dist/module/src/lib/basebuilder.js +9 -7
- package/dist/module/src/lib/core.test/MockCore.js +17 -15
- package/dist/module/tsconfig.module.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types/src/lib/index.d.ts +0 -1
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/Pure.ts +2 -2
- package/src/lib/baseBuilder.test/baseBuilder.test.mock.ts +1 -1
- package/src/lib/basebuilder.ts +9 -9
- package/src/lib/core.test/MockCore.ts +26 -19
- package/src/lib/index.ts +1 -1
- package/testeranto/bundles/node/allTests/chunk-H2IBV7SY.mjs +113 -0
- package/testeranto/bundles/node/allTests/chunk-IDCUSTSM.mjs +669 -0
- package/testeranto/bundles/node/allTests/chunk-ZHOULXPN.mjs +252 -0
- package/testeranto/bundles/node/allTests/metafile.json +28 -28
- package/testeranto/bundles/node/allTests/src/lib/BaseSuite.test/node.test.mjs +3 -3
- package/testeranto/bundles/node/allTests/src/lib/baseBuilder.test/baseBuilder.test.node.mjs +3 -3
- package/testeranto/bundles/node/allTests/src/lib/classBuilder.test/classBuilder.test.mjs +3 -3
- package/testeranto/bundles/node/allTests/src/lib/core.test/core.test.mjs +11 -8
- package/testeranto/bundles/node/allTests/src/lib/pmProxy.test/index.mjs +2 -2
- package/testeranto/bundles/pure/allTests/chunk-4ULDTZFU.mjs +666 -0
- package/testeranto/bundles/pure/allTests/chunk-5SBJWHSZ.mjs +200 -0
- package/testeranto/bundles/pure/allTests/metafile.json +33 -33
- package/testeranto/bundles/pure/allTests/src/Pure.test.mjs +2 -2
- package/testeranto/bundles/pure/allTests/src/lib/BaseSuite.test/pure.test.mjs +2 -2
- package/testeranto/bundles/pure/allTests/src/lib/baseBuilder.test/baseBuilder.test.pure.mjs +2 -2
- package/testeranto/bundles/web/allTests/chunk-46E6YGGN.mjs +847 -0
- package/testeranto/bundles/web/allTests/metafile.json +10 -10
- package/testeranto/bundles/web/allTests/src/lib/BaseSuite.test/web.test.mjs +1 -1
- package/testeranto/bundles/web/allTests/src/lib/baseBuilder.test/baseBuilder.test.web.mjs +2 -2
- package/testeranto/reports/allTests/src/lib/BaseSuite.test/node.test/node/logs.txt +0 -0
- package/testeranto/reports/allTests/src/lib/BaseSuite.test/web.test/web/logs.txt +0 -0
- package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.node/node/logs.txt +0 -0
- package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.web/web/logs.txt +0 -0
- package/testeranto/reports/allTests/src/lib/classBuilder.test/classBuilder.test/node/logs.txt +0 -0
- package/testeranto/reports/allTests/src/lib/core.test/core.test/node/lint_errors.txt +0 -12
- package/testeranto/reports/allTests/src/lib/core.test/core.test/node/type_errors.txt +2 -5
- package/testeranto/reports/allTests/src/lib/pmProxy.test/index/node/logs.txt +0 -0
- package/testeranto/reports/allTests/summary.json +2 -2
- package/tsc.log +236 -234
|
@@ -0,0 +1,666 @@
|
|
|
1
|
+
import { createRequire } from 'module';const require = createRequire(import.meta.url);
|
|
2
|
+
|
|
3
|
+
// src/lib/pmProxy.ts
|
|
4
|
+
var baseProxy = function(pm, mappings) {
|
|
5
|
+
return new Proxy(pm, {
|
|
6
|
+
get: (target, prop, receiver) => {
|
|
7
|
+
for (const mapping of mappings) {
|
|
8
|
+
const method = mapping[0];
|
|
9
|
+
const arger = mapping[1];
|
|
10
|
+
if (prop === method) {
|
|
11
|
+
return (...x) => target[prop](arger(...x));
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return (...x) => target[prop](...x);
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
var butThenProxy = (pm, filepath) => baseProxy(pm, [
|
|
19
|
+
[
|
|
20
|
+
"screencast",
|
|
21
|
+
(opts, p) => [
|
|
22
|
+
{
|
|
23
|
+
...opts,
|
|
24
|
+
path: `${filepath}/butThen/${opts.path}`
|
|
25
|
+
},
|
|
26
|
+
p
|
|
27
|
+
]
|
|
28
|
+
],
|
|
29
|
+
["createWriteStream", (fp) => [`${filepath}/butThen/${fp}`]],
|
|
30
|
+
[
|
|
31
|
+
"writeFileSync",
|
|
32
|
+
(fp, contents) => [`${filepath}/butThen/${fp}`, contents]
|
|
33
|
+
],
|
|
34
|
+
[
|
|
35
|
+
"customScreenShot",
|
|
36
|
+
(opts, p) => [
|
|
37
|
+
{
|
|
38
|
+
...opts,
|
|
39
|
+
path: `${filepath}/butThen/${opts.path}`
|
|
40
|
+
},
|
|
41
|
+
p
|
|
42
|
+
]
|
|
43
|
+
]
|
|
44
|
+
]);
|
|
45
|
+
var andWhenProxy = (pm, filepath) => baseProxy(pm, [
|
|
46
|
+
[
|
|
47
|
+
"screencast",
|
|
48
|
+
(opts, p) => [
|
|
49
|
+
{
|
|
50
|
+
...opts,
|
|
51
|
+
path: `${filepath}/andWhen/${opts.path}`
|
|
52
|
+
},
|
|
53
|
+
p
|
|
54
|
+
]
|
|
55
|
+
],
|
|
56
|
+
["createWriteStream", (fp) => [`${filepath}/andWhen/${fp}`]],
|
|
57
|
+
["writeFileSync", (fp, contents) => [`${filepath}/andWhen${fp}`, contents]],
|
|
58
|
+
[
|
|
59
|
+
"customScreenShot",
|
|
60
|
+
(opts, p) => [
|
|
61
|
+
{
|
|
62
|
+
...opts,
|
|
63
|
+
path: `${filepath}/andWhen${opts.path}`
|
|
64
|
+
},
|
|
65
|
+
p
|
|
66
|
+
]
|
|
67
|
+
]
|
|
68
|
+
]);
|
|
69
|
+
var afterEachProxy = (pm, suite, given) => baseProxy(pm, [
|
|
70
|
+
[
|
|
71
|
+
"screencast",
|
|
72
|
+
(opts, p) => [
|
|
73
|
+
{
|
|
74
|
+
...opts,
|
|
75
|
+
path: `suite-${suite}/given-${given}/afterEach/${opts.path}`
|
|
76
|
+
},
|
|
77
|
+
p
|
|
78
|
+
]
|
|
79
|
+
],
|
|
80
|
+
["createWriteStream", (fp) => [`suite-${suite}/afterEach/${fp}`]],
|
|
81
|
+
[
|
|
82
|
+
"writeFileSync",
|
|
83
|
+
(fp, contents) => [
|
|
84
|
+
`suite-${suite}/given-${given}/afterEach/${fp}`,
|
|
85
|
+
contents
|
|
86
|
+
]
|
|
87
|
+
],
|
|
88
|
+
[
|
|
89
|
+
"customScreenShot",
|
|
90
|
+
(opts, p) => [
|
|
91
|
+
{
|
|
92
|
+
...opts,
|
|
93
|
+
path: `suite-${suite}/given-${given}/afterEach/${opts.path}`
|
|
94
|
+
},
|
|
95
|
+
p
|
|
96
|
+
]
|
|
97
|
+
]
|
|
98
|
+
]);
|
|
99
|
+
var beforeEachProxy = (pm, suite) => baseProxy(pm, [
|
|
100
|
+
[
|
|
101
|
+
"screencast",
|
|
102
|
+
(opts, p) => [
|
|
103
|
+
{
|
|
104
|
+
...opts,
|
|
105
|
+
path: `suite-${suite}/beforeEach/${opts.path}`
|
|
106
|
+
},
|
|
107
|
+
p
|
|
108
|
+
]
|
|
109
|
+
],
|
|
110
|
+
[
|
|
111
|
+
"writeFileSync",
|
|
112
|
+
(fp, contents) => [`suite-${suite}/beforeEach/${fp}`, contents]
|
|
113
|
+
],
|
|
114
|
+
[
|
|
115
|
+
"customScreenShot",
|
|
116
|
+
(opts, p) => [
|
|
117
|
+
{
|
|
118
|
+
...opts,
|
|
119
|
+
path: `suite-${suite}/beforeEach/${opts.path}`
|
|
120
|
+
},
|
|
121
|
+
p
|
|
122
|
+
]
|
|
123
|
+
],
|
|
124
|
+
["createWriteStream", (fp) => [`suite-${suite}/beforeEach/${fp}`]]
|
|
125
|
+
]);
|
|
126
|
+
var beforeAllProxy = (pm, suite) => baseProxy(pm, [
|
|
127
|
+
[
|
|
128
|
+
"writeFileSync",
|
|
129
|
+
(fp, contents) => [`suite-${suite}/beforeAll/${fp}`, contents]
|
|
130
|
+
],
|
|
131
|
+
[
|
|
132
|
+
"customScreenShot",
|
|
133
|
+
(opts, p) => [
|
|
134
|
+
{
|
|
135
|
+
...opts,
|
|
136
|
+
path: `suite-${suite}/beforeAll/${opts.path}`
|
|
137
|
+
},
|
|
138
|
+
p
|
|
139
|
+
]
|
|
140
|
+
],
|
|
141
|
+
["createWriteStream", (fp) => [`suite-${suite}/beforeAll/${fp}`]]
|
|
142
|
+
]);
|
|
143
|
+
var afterAllProxy = (pm, suite) => baseProxy(pm, [
|
|
144
|
+
["createWriteStream", (fp) => [`suite-${suite}/afterAll/${fp}`]],
|
|
145
|
+
[
|
|
146
|
+
"writeFileSync",
|
|
147
|
+
(fp, contents) => [`suite-${suite}/afterAll/${fp}`, contents]
|
|
148
|
+
],
|
|
149
|
+
[
|
|
150
|
+
"customScreenShot",
|
|
151
|
+
(opts, p) => [
|
|
152
|
+
{
|
|
153
|
+
...opts,
|
|
154
|
+
path: `suite-${suite}/afterAll/${opts.path}`
|
|
155
|
+
},
|
|
156
|
+
p
|
|
157
|
+
]
|
|
158
|
+
]
|
|
159
|
+
]);
|
|
160
|
+
|
|
161
|
+
// src/lib/BaseSuite.ts
|
|
162
|
+
var BaseSuite = class {
|
|
163
|
+
constructor(name, index, givens = {}) {
|
|
164
|
+
const suiteName = name || "testSuite";
|
|
165
|
+
if (!suiteName) {
|
|
166
|
+
throw new Error("BaseSuite requires a non-empty name");
|
|
167
|
+
}
|
|
168
|
+
console.log("[DEBUG] BaseSuite constructor - name:", suiteName, "index:", index);
|
|
169
|
+
this.name = suiteName;
|
|
170
|
+
this.index = index;
|
|
171
|
+
this.givens = givens;
|
|
172
|
+
this.fails = 0;
|
|
173
|
+
console.log("[DEBUG] BaseSuite initialized:", this.name, this.index);
|
|
174
|
+
console.log("[DEBUG] BaseSuite givens:", Object.keys(givens));
|
|
175
|
+
}
|
|
176
|
+
features() {
|
|
177
|
+
try {
|
|
178
|
+
const features = Object.keys(this.givens).map((k) => this.givens[k].features).flat().filter((value, index, array) => {
|
|
179
|
+
return array.indexOf(value) === index;
|
|
180
|
+
});
|
|
181
|
+
console.debug("[DEBUG] Features extracted:", features);
|
|
182
|
+
return features || [];
|
|
183
|
+
} catch (e) {
|
|
184
|
+
console.error("[ERROR] Failed to extract features:", e);
|
|
185
|
+
return [];
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
toObj() {
|
|
189
|
+
const givens = Object.keys(this.givens).map((k) => this.givens[k].toObj());
|
|
190
|
+
return {
|
|
191
|
+
name: this.name,
|
|
192
|
+
givens,
|
|
193
|
+
fails: this.fails,
|
|
194
|
+
failed: this.failed,
|
|
195
|
+
features: this.features()
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
setup(s, artifactory, tr, pm) {
|
|
199
|
+
return new Promise((res) => res(s));
|
|
200
|
+
}
|
|
201
|
+
assertThat(t) {
|
|
202
|
+
return !!t;
|
|
203
|
+
}
|
|
204
|
+
afterAll(store, artifactory, pm) {
|
|
205
|
+
return store;
|
|
206
|
+
}
|
|
207
|
+
async run(input, testResourceConfiguration, artifactory, tLog, pm) {
|
|
208
|
+
this.testResourceConfiguration = testResourceConfiguration;
|
|
209
|
+
const suiteArtifactory = (fPath, value) => artifactory(`suite-${this.index}-${this.name}/${fPath}`, value);
|
|
210
|
+
tLog("\nSuite:", this.index, this.name);
|
|
211
|
+
const sNdx = this.index;
|
|
212
|
+
const subject = await this.setup(
|
|
213
|
+
input,
|
|
214
|
+
suiteArtifactory,
|
|
215
|
+
testResourceConfiguration,
|
|
216
|
+
beforeAllProxy(pm, sNdx.toString())
|
|
217
|
+
);
|
|
218
|
+
for (const [gKey, g] of Object.entries(this.givens)) {
|
|
219
|
+
const giver = this.givens[gKey];
|
|
220
|
+
this.store = await giver.give(
|
|
221
|
+
subject,
|
|
222
|
+
gKey,
|
|
223
|
+
testResourceConfiguration,
|
|
224
|
+
this.assertThat,
|
|
225
|
+
suiteArtifactory,
|
|
226
|
+
tLog,
|
|
227
|
+
pm,
|
|
228
|
+
sNdx
|
|
229
|
+
).catch((e) => {
|
|
230
|
+
this.failed = true;
|
|
231
|
+
this.fails = this.fails + 1;
|
|
232
|
+
console.error("Given error 1:", e);
|
|
233
|
+
throw e;
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
try {
|
|
237
|
+
this.afterAll(
|
|
238
|
+
this.store,
|
|
239
|
+
artifactory,
|
|
240
|
+
afterAllProxy(pm, sNdx.toString())
|
|
241
|
+
);
|
|
242
|
+
} catch (e) {
|
|
243
|
+
console.error(e);
|
|
244
|
+
}
|
|
245
|
+
return this;
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
// src/lib/index.ts
|
|
250
|
+
var BaseAdapter = () => ({
|
|
251
|
+
beforeAll: async (s) => s,
|
|
252
|
+
beforeEach: async function(subject, initialValues, x, testResource, pm) {
|
|
253
|
+
return subject;
|
|
254
|
+
},
|
|
255
|
+
afterEach: async (s) => s,
|
|
256
|
+
afterAll: (store) => void 0,
|
|
257
|
+
butThen: async (store, thenCb) => {
|
|
258
|
+
return thenCb(store);
|
|
259
|
+
},
|
|
260
|
+
andWhen: async (store, whenCB, testResource, pm) => {
|
|
261
|
+
try {
|
|
262
|
+
await whenCB(store, testResource, pm);
|
|
263
|
+
} catch (error) {
|
|
264
|
+
console.error("Error in andWhen:", error);
|
|
265
|
+
throw error;
|
|
266
|
+
}
|
|
267
|
+
},
|
|
268
|
+
assertThis: (x) => x
|
|
269
|
+
});
|
|
270
|
+
var DefaultAdapter = (p) => {
|
|
271
|
+
return {
|
|
272
|
+
...BaseAdapter,
|
|
273
|
+
...p
|
|
274
|
+
};
|
|
275
|
+
};
|
|
276
|
+
var defaultTestResourceRequirement = {
|
|
277
|
+
ports: 0
|
|
278
|
+
};
|
|
279
|
+
|
|
280
|
+
// src/lib/basebuilder.ts
|
|
281
|
+
var BaseBuilder = class {
|
|
282
|
+
constructor(input, suitesOverrides, givenOverides, whenOverides, thenOverides, testResourceRequirement, testSpecification) {
|
|
283
|
+
this.artifacts = [];
|
|
284
|
+
this.artifacts = [];
|
|
285
|
+
this.testResourceRequirement = testResourceRequirement;
|
|
286
|
+
this.suitesOverrides = suitesOverrides;
|
|
287
|
+
this.givenOverides = givenOverides;
|
|
288
|
+
this.whenOverides = whenOverides;
|
|
289
|
+
this.thenOverides = thenOverides;
|
|
290
|
+
this.testSpecification = testSpecification;
|
|
291
|
+
this.specs = testSpecification(
|
|
292
|
+
this.Suites(),
|
|
293
|
+
this.Given(),
|
|
294
|
+
this.When(),
|
|
295
|
+
this.Then()
|
|
296
|
+
);
|
|
297
|
+
this.testJobs = this.specs.map((suite) => {
|
|
298
|
+
const suiteRunner = (suite2) => async (puppetMaster, tLog) => {
|
|
299
|
+
const x = await suite2.run(
|
|
300
|
+
input,
|
|
301
|
+
puppetMaster.testResourceConfiguration,
|
|
302
|
+
(fPath, value) => puppetMaster.testArtiFactoryfileWriter(
|
|
303
|
+
tLog,
|
|
304
|
+
(p) => {
|
|
305
|
+
this.artifacts.push(p);
|
|
306
|
+
}
|
|
307
|
+
)(puppetMaster.testResourceConfiguration.fs + "/" + fPath, value),
|
|
308
|
+
tLog,
|
|
309
|
+
puppetMaster
|
|
310
|
+
);
|
|
311
|
+
return x;
|
|
312
|
+
};
|
|
313
|
+
const runner = suiteRunner(suite);
|
|
314
|
+
return {
|
|
315
|
+
test: suite,
|
|
316
|
+
toObj: () => {
|
|
317
|
+
return suite.toObj();
|
|
318
|
+
},
|
|
319
|
+
runner,
|
|
320
|
+
receiveTestResourceConfig: async function(puppetMaster) {
|
|
321
|
+
const tLog = async (...l) => {
|
|
322
|
+
};
|
|
323
|
+
const suiteDone = await runner(puppetMaster, tLog);
|
|
324
|
+
const fails = suiteDone.fails;
|
|
325
|
+
await puppetMaster.writeFileSync(`bdd_errors.txt`, fails.toString());
|
|
326
|
+
await puppetMaster.writeFileSync(
|
|
327
|
+
`tests.json`,
|
|
328
|
+
JSON.stringify(this.toObj(), null, 2)
|
|
329
|
+
);
|
|
330
|
+
return {
|
|
331
|
+
failed: fails > 0,
|
|
332
|
+
fails,
|
|
333
|
+
artifacts: this.artifacts || [],
|
|
334
|
+
// logPromise,
|
|
335
|
+
features: suiteDone.features()
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
};
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
// testsJson() {
|
|
342
|
+
// puppetMaster.writeFileSync(
|
|
343
|
+
// `tests.json`,
|
|
344
|
+
// JSON.stringify({ features: suiteDone.features() }, null, 2)
|
|
345
|
+
// );
|
|
346
|
+
// }
|
|
347
|
+
Specs() {
|
|
348
|
+
return this.specs;
|
|
349
|
+
}
|
|
350
|
+
Suites() {
|
|
351
|
+
return this.suitesOverrides;
|
|
352
|
+
}
|
|
353
|
+
Given() {
|
|
354
|
+
return this.givenOverides;
|
|
355
|
+
}
|
|
356
|
+
When() {
|
|
357
|
+
return this.whenOverides;
|
|
358
|
+
}
|
|
359
|
+
Then() {
|
|
360
|
+
return this.thenOverides;
|
|
361
|
+
}
|
|
362
|
+
};
|
|
363
|
+
|
|
364
|
+
// src/lib/abstractBase.ts
|
|
365
|
+
var BaseGiven = class {
|
|
366
|
+
constructor(name, features, whens, thens, givenCB, initialValues) {
|
|
367
|
+
this.name = name;
|
|
368
|
+
this.features = features;
|
|
369
|
+
this.whens = whens;
|
|
370
|
+
this.thens = thens;
|
|
371
|
+
this.givenCB = givenCB;
|
|
372
|
+
this.initialValues = initialValues;
|
|
373
|
+
}
|
|
374
|
+
beforeAll(store) {
|
|
375
|
+
return store;
|
|
376
|
+
}
|
|
377
|
+
toObj() {
|
|
378
|
+
return {
|
|
379
|
+
key: this.key,
|
|
380
|
+
name: this.name,
|
|
381
|
+
whens: this.whens.map((w) => {
|
|
382
|
+
if (w && w.toObj)
|
|
383
|
+
return w.toObj();
|
|
384
|
+
console.error("w is not as expected!", w);
|
|
385
|
+
return {};
|
|
386
|
+
}),
|
|
387
|
+
thens: this.thens.map((t) => t.toObj()),
|
|
388
|
+
error: this.error ? [this.error, this.error.stack] : null,
|
|
389
|
+
failed: this.failed,
|
|
390
|
+
features: this.features
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
async afterEach(store, key, artifactory, pm) {
|
|
394
|
+
return store;
|
|
395
|
+
}
|
|
396
|
+
async give(subject, key, testResourceConfiguration, tester, artifactory, tLog, pm, suiteNdx) {
|
|
397
|
+
this.key = key;
|
|
398
|
+
tLog(`
|
|
399
|
+
${this.key}`);
|
|
400
|
+
tLog(`
|
|
401
|
+
Given: ${this.name}`);
|
|
402
|
+
const givenArtifactory = (fPath, value) => artifactory(`given-${key}/${fPath}`, value);
|
|
403
|
+
this.uberCatcher((e) => {
|
|
404
|
+
console.error(e);
|
|
405
|
+
this.error = e.error;
|
|
406
|
+
tLog(e.stack);
|
|
407
|
+
});
|
|
408
|
+
try {
|
|
409
|
+
this.store = await this.givenThat(
|
|
410
|
+
subject,
|
|
411
|
+
testResourceConfiguration,
|
|
412
|
+
givenArtifactory,
|
|
413
|
+
this.givenCB,
|
|
414
|
+
this.initialValues,
|
|
415
|
+
beforeEachProxy(pm, suiteNdx.toString())
|
|
416
|
+
);
|
|
417
|
+
} catch (e) {
|
|
418
|
+
console.error("failure 4 ", e);
|
|
419
|
+
this.error = e;
|
|
420
|
+
throw e;
|
|
421
|
+
}
|
|
422
|
+
try {
|
|
423
|
+
for (const [whenNdx, whenStep] of this.whens.entries()) {
|
|
424
|
+
await whenStep.test(
|
|
425
|
+
this.store,
|
|
426
|
+
testResourceConfiguration,
|
|
427
|
+
tLog,
|
|
428
|
+
pm,
|
|
429
|
+
`suite-${suiteNdx}/given-${key}/when/${whenNdx}`
|
|
430
|
+
);
|
|
431
|
+
}
|
|
432
|
+
for (const [thenNdx, thenStep] of this.thens.entries()) {
|
|
433
|
+
const t = await thenStep.test(
|
|
434
|
+
this.store,
|
|
435
|
+
testResourceConfiguration,
|
|
436
|
+
tLog,
|
|
437
|
+
pm,
|
|
438
|
+
`suite-${suiteNdx}/given-${key}/then-${thenNdx}`
|
|
439
|
+
);
|
|
440
|
+
tester(t);
|
|
441
|
+
}
|
|
442
|
+
} catch (e) {
|
|
443
|
+
this.failed = true;
|
|
444
|
+
tLog(e.stack);
|
|
445
|
+
throw e;
|
|
446
|
+
} finally {
|
|
447
|
+
try {
|
|
448
|
+
await this.afterEach(
|
|
449
|
+
this.store,
|
|
450
|
+
this.key,
|
|
451
|
+
givenArtifactory,
|
|
452
|
+
afterEachProxy(pm, suiteNdx.toString(), key)
|
|
453
|
+
);
|
|
454
|
+
} catch (e) {
|
|
455
|
+
console.error("afterEach failed!", e);
|
|
456
|
+
this.failed = e;
|
|
457
|
+
throw e;
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
return this.store;
|
|
461
|
+
}
|
|
462
|
+
};
|
|
463
|
+
var BaseWhen = class {
|
|
464
|
+
constructor(name, whenCB) {
|
|
465
|
+
this.name = name;
|
|
466
|
+
this.whenCB = whenCB;
|
|
467
|
+
}
|
|
468
|
+
toObj() {
|
|
469
|
+
console.log("toObj error", this.error);
|
|
470
|
+
return {
|
|
471
|
+
name: this.name,
|
|
472
|
+
error: this.error && this.error.name + this.error.stack
|
|
473
|
+
};
|
|
474
|
+
}
|
|
475
|
+
async test(store, testResourceConfiguration, tLog, pm, filepath) {
|
|
476
|
+
try {
|
|
477
|
+
tLog(" When:", this.name);
|
|
478
|
+
console.debug("[DEBUG] Executing When step:", this.name);
|
|
479
|
+
const result = await this.andWhen(
|
|
480
|
+
store,
|
|
481
|
+
this.whenCB,
|
|
482
|
+
testResourceConfiguration,
|
|
483
|
+
andWhenProxy(pm, filepath)
|
|
484
|
+
);
|
|
485
|
+
console.debug("[DEBUG] When step completed:", this.name);
|
|
486
|
+
return result;
|
|
487
|
+
} catch (e) {
|
|
488
|
+
console.error("[ERROR] When step failed:", this.name, e);
|
|
489
|
+
this.error = e;
|
|
490
|
+
throw e;
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
};
|
|
494
|
+
var BaseThen = class {
|
|
495
|
+
constructor(name, thenCB) {
|
|
496
|
+
this.name = name;
|
|
497
|
+
this.thenCB = thenCB;
|
|
498
|
+
this.error = false;
|
|
499
|
+
}
|
|
500
|
+
toObj() {
|
|
501
|
+
return {
|
|
502
|
+
name: this.name,
|
|
503
|
+
error: this.error
|
|
504
|
+
};
|
|
505
|
+
}
|
|
506
|
+
async test(store, testResourceConfiguration, tLog, pm, filepath) {
|
|
507
|
+
return this.butThen(
|
|
508
|
+
store,
|
|
509
|
+
async (s) => {
|
|
510
|
+
if (typeof this.thenCB === "function") {
|
|
511
|
+
return await this.thenCB(s);
|
|
512
|
+
} else {
|
|
513
|
+
return this.thenCB;
|
|
514
|
+
}
|
|
515
|
+
},
|
|
516
|
+
testResourceConfiguration,
|
|
517
|
+
butThenProxy(pm, filepath)
|
|
518
|
+
).catch((e) => {
|
|
519
|
+
this.error = e.toString();
|
|
520
|
+
});
|
|
521
|
+
}
|
|
522
|
+
};
|
|
523
|
+
|
|
524
|
+
// src/lib/classBuilder.ts
|
|
525
|
+
var ClassBuilder = class extends BaseBuilder {
|
|
526
|
+
constructor(testImplementation, testSpecification, input, suiteKlasser, givenKlasser, whenKlasser, thenKlasser, testResourceRequirement) {
|
|
527
|
+
const classySuites = Object.entries(testImplementation.suites).reduce(
|
|
528
|
+
(a, [key], index) => {
|
|
529
|
+
a[key] = (somestring, givens) => {
|
|
530
|
+
return new suiteKlasser.prototype.constructor(
|
|
531
|
+
somestring,
|
|
532
|
+
index,
|
|
533
|
+
givens
|
|
534
|
+
);
|
|
535
|
+
};
|
|
536
|
+
return a;
|
|
537
|
+
},
|
|
538
|
+
{}
|
|
539
|
+
);
|
|
540
|
+
const classyGivens = Object.entries(testImplementation.givens).reduce(
|
|
541
|
+
(a, [key, g]) => {
|
|
542
|
+
a[key] = (features, whens, thens, ...initialValues) => {
|
|
543
|
+
return new givenKlasser.prototype.constructor(
|
|
544
|
+
key,
|
|
545
|
+
features,
|
|
546
|
+
whens,
|
|
547
|
+
thens,
|
|
548
|
+
testImplementation.givens[key],
|
|
549
|
+
initialValues
|
|
550
|
+
);
|
|
551
|
+
};
|
|
552
|
+
return a;
|
|
553
|
+
},
|
|
554
|
+
{}
|
|
555
|
+
);
|
|
556
|
+
const classyWhens = Object.entries(testImplementation.whens).reduce(
|
|
557
|
+
(a, [key, whEn]) => {
|
|
558
|
+
a[key] = (...payload) => {
|
|
559
|
+
return new whenKlasser.prototype.constructor(
|
|
560
|
+
`${whEn.name}: ${payload && payload.toString()}`,
|
|
561
|
+
whEn(...payload)
|
|
562
|
+
);
|
|
563
|
+
};
|
|
564
|
+
return a;
|
|
565
|
+
},
|
|
566
|
+
{}
|
|
567
|
+
);
|
|
568
|
+
const classyThens = Object.entries(
|
|
569
|
+
testImplementation.thens
|
|
570
|
+
).reduce(
|
|
571
|
+
(a, [key, thEn]) => {
|
|
572
|
+
a[key] = (expected, ...x) => {
|
|
573
|
+
return new thenKlasser.prototype.constructor(
|
|
574
|
+
`${thEn.name}: ${expected && expected.toString()}`,
|
|
575
|
+
thEn(expected, ...x)
|
|
576
|
+
);
|
|
577
|
+
};
|
|
578
|
+
return a;
|
|
579
|
+
},
|
|
580
|
+
{}
|
|
581
|
+
);
|
|
582
|
+
super(
|
|
583
|
+
input,
|
|
584
|
+
classySuites,
|
|
585
|
+
classyGivens,
|
|
586
|
+
classyWhens,
|
|
587
|
+
classyThens,
|
|
588
|
+
testResourceRequirement,
|
|
589
|
+
testSpecification
|
|
590
|
+
);
|
|
591
|
+
}
|
|
592
|
+
};
|
|
593
|
+
|
|
594
|
+
// src/lib/core.ts
|
|
595
|
+
var TesterantoCore = class extends ClassBuilder {
|
|
596
|
+
constructor(input, testSpecification, testImplementation, testResourceRequirement = defaultTestResourceRequirement, testAdapter, uberCatcher) {
|
|
597
|
+
const fullAdapter = DefaultAdapter(testAdapter);
|
|
598
|
+
super(
|
|
599
|
+
testImplementation,
|
|
600
|
+
testSpecification,
|
|
601
|
+
input,
|
|
602
|
+
class extends BaseSuite {
|
|
603
|
+
afterAll(store, artifactory, pm) {
|
|
604
|
+
return fullAdapter.afterAll(store, pm);
|
|
605
|
+
}
|
|
606
|
+
assertThat(t) {
|
|
607
|
+
return fullAdapter.assertThis(t);
|
|
608
|
+
}
|
|
609
|
+
async setup(s, artifactory, tr, pm) {
|
|
610
|
+
return (fullAdapter.beforeAll || (async (input2, artifactory2, tr2, pm2) => input2))(
|
|
611
|
+
s,
|
|
612
|
+
this.testResourceConfiguration,
|
|
613
|
+
// artifactory,
|
|
614
|
+
pm
|
|
615
|
+
);
|
|
616
|
+
}
|
|
617
|
+
},
|
|
618
|
+
class Given extends BaseGiven {
|
|
619
|
+
constructor() {
|
|
620
|
+
super(...arguments);
|
|
621
|
+
this.uberCatcher = uberCatcher;
|
|
622
|
+
}
|
|
623
|
+
async givenThat(subject, testResource, artifactory, initializer, initialValues, pm) {
|
|
624
|
+
return fullAdapter.beforeEach(
|
|
625
|
+
subject,
|
|
626
|
+
initializer,
|
|
627
|
+
testResource,
|
|
628
|
+
initialValues,
|
|
629
|
+
pm
|
|
630
|
+
);
|
|
631
|
+
}
|
|
632
|
+
afterEach(store, key, artifactory, pm) {
|
|
633
|
+
return new Promise(
|
|
634
|
+
(res) => res(fullAdapter.afterEach(store, key, pm))
|
|
635
|
+
);
|
|
636
|
+
}
|
|
637
|
+
},
|
|
638
|
+
class When extends BaseWhen {
|
|
639
|
+
async andWhen(store, whenCB, testResource, pm) {
|
|
640
|
+
return await fullAdapter.andWhen(store, whenCB, testResource, pm);
|
|
641
|
+
}
|
|
642
|
+
},
|
|
643
|
+
class Then extends BaseThen {
|
|
644
|
+
async butThen(store, thenCB, testResource, pm) {
|
|
645
|
+
return await fullAdapter.butThen(store, thenCB, testResource, pm);
|
|
646
|
+
}
|
|
647
|
+
},
|
|
648
|
+
testResourceRequirement
|
|
649
|
+
);
|
|
650
|
+
}
|
|
651
|
+
};
|
|
652
|
+
|
|
653
|
+
// src/PM/index.ts
|
|
654
|
+
var PM = class {
|
|
655
|
+
};
|
|
656
|
+
|
|
657
|
+
export {
|
|
658
|
+
defaultTestResourceRequirement,
|
|
659
|
+
BaseGiven,
|
|
660
|
+
BaseWhen,
|
|
661
|
+
BaseThen,
|
|
662
|
+
BaseBuilder,
|
|
663
|
+
BaseSuite,
|
|
664
|
+
TesterantoCore,
|
|
665
|
+
PM
|
|
666
|
+
};
|