testeranto 0.171.0 → 0.173.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/README.md +2 -4
- package/dist/common/src/PM/base.js +4 -0
- package/dist/common/src/PM/main.js +11 -4
- package/dist/common/src/PM/node.js +1 -1
- package/dist/common/src/PM/web.js +3 -3
- package/dist/common/src/ReportServer.js +2 -126
- package/dist/common/src/ReportServer.test.ts/index.js +78 -0
- package/dist/common/src/ReportServerLib.js +135 -0
- package/dist/common/src/components/pure/ProjectPageView.test/implementation.js +1 -1
- package/dist/common/src/lib/abstractBase.js +2 -0
- package/dist/common/src/lib/baseBuilder.test/baseBuilder.test.implementation.js +10 -9
- package/dist/common/src/lib/baseBuilder.test/baseBuilder.test.specification.js +7 -7
- package/dist/common/src/lib/basebuilder.js +8 -2
- package/dist/common/src/lib/pmProxy.js +54 -150
- package/dist/common/testeranto.config.js +35 -20
- package/dist/common/tsconfig.common.tsbuildinfo +1 -1
- package/dist/module/src/PM/base.js +4 -0
- package/dist/module/src/PM/main.js +11 -4
- package/dist/module/src/PM/node.js +1 -1
- package/dist/module/src/PM/web.js +3 -3
- package/dist/module/src/ReportServer.js +2 -123
- package/dist/module/src/ReportServer.test.ts/index.js +73 -0
- package/dist/module/src/ReportServerLib.js +128 -0
- package/dist/module/src/TestPage.js +29 -17
- package/dist/module/src/components/pure/ProjectPageView.test/implementation.js +1 -1
- package/dist/module/src/components/pure/TestPageView.js +29 -17
- package/dist/module/src/lib/abstractBase.js +2 -0
- package/dist/module/src/lib/baseBuilder.test/baseBuilder.test.implementation.js +10 -9
- package/dist/module/src/lib/baseBuilder.test/baseBuilder.test.specification.js +7 -7
- package/dist/module/src/lib/basebuilder.js +8 -2
- package/dist/module/src/lib/pmProxy.js +54 -150
- package/dist/module/testeranto.config.js +35 -20
- package/dist/module/tsconfig.module.tsbuildinfo +1 -1
- package/dist/prebuild/App.css +13 -9
- package/dist/prebuild/App.js +102 -99
- package/dist/prebuild/ReportServer.mjs +15 -9
- package/dist/prebuild/run.mjs +14 -4
- package/dist/types/src/PM/node.d.ts +1 -1
- package/dist/types/src/PM/web.d.ts +1 -1
- package/dist/types/src/ReportServer.test.ts/index.d.ts +29 -0
- package/dist/types/src/ReportServerLib.d.ts +2 -0
- package/dist/types/src/Types.d.ts +0 -1
- package/dist/types/src/components/pure/ProjectPageView.test/index.d.ts +1 -1
- package/dist/types/src/lib/abstractBase.d.ts +1 -1
- package/dist/types/src/lib/baseBuilder.test/baseBuilder.test.types.d.ts +7 -4
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/package.json +6 -5
- package/src/PM/base.ts +5 -0
- package/src/PM/main.ts +12 -4
- package/src/PM/node.ts +1 -1
- package/src/PM/web.ts +3 -3
- package/src/ReportServer.test.ts/index.ts +194 -0
- package/src/ReportServer.ts +2 -132
- package/src/ReportServerLib.ts +144 -0
- package/src/TestPage.tsx +65 -5
- package/src/Types.ts +0 -1
- package/src/components/pure/ProjectPageView.test/implementation.tsx +1 -1
- package/src/components/pure/TestPageView.tsx +65 -5
- package/src/lib/abstractBase.ts +4 -1
- package/src/lib/baseBuilder.test/baseBuilder.test.implementation.ts +22 -10
- package/src/lib/baseBuilder.test/baseBuilder.test.specification.ts +9 -9
- package/src/lib/baseBuilder.test/baseBuilder.test.types.ts +7 -4
- package/src/lib/basebuilder.ts +7 -4
- package/src/lib/pmProxy.ts +78 -155
- package/testeranto/App.css +13 -9
- package/testeranto/App.js +102 -99
- package/testeranto/bundles/node/allTests/metafile.json +38 -781
- package/testeranto/bundles/node/allTests/src/lib/baseBuilder.test/baseBuilder.test.node.mjs +983 -24
- package/testeranto/bundles/node/core/metafile.json +486 -0
- package/testeranto/bundles/{pure/allTests/chunk-VMUSFSZM.mjs → node/core/src/lib/baseBuilder.test/baseBuilder.test.node.mjs} +797 -412
- package/testeranto/bundles/node/staticSite/metafile.json +593 -0
- package/testeranto/bundles/node/staticSite/src/ReportServer.test.ts/index.mjs +1594 -0
- package/testeranto/bundles/pure/allTests/metafile.json +157 -585
- package/testeranto/bundles/pure/allTests/src/lib/baseBuilder.test/baseBuilder.test.pure.mjs +740 -27
- package/testeranto/bundles/pure/core/metafile.json +626 -0
- package/testeranto/bundles/{web/allTests/chunk-U7AW26HL.mjs → pure/core/src/lib/baseBuilder.test/baseBuilder.test.pure.mjs} +507 -410
- package/testeranto/bundles/pure/staticSite/metafile.json +8 -0
- package/testeranto/bundles/web/allTests/metafile.json +107 -15292
- package/testeranto/bundles/web/allTests/src/lib/baseBuilder.test/baseBuilder.test.web.mjs +893 -45
- package/testeranto/bundles/web/core/metafile.json +780 -0
- package/testeranto/bundles/web/core/src/lib/baseBuilder.test/baseBuilder.test.web.html +19 -0
- package/testeranto/bundles/web/{allTests/chunk-RLDR6LJN.mjs → core/src/lib/baseBuilder.test/baseBuilder.test.web.mjs} +580 -518
- package/testeranto/bundles/web/staticSite/metafile.json +8 -0
- package/testeranto/projects.json +2 -1
- package/testeranto/reports/allTests/config.json +0 -64
- package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.node/node/lint_errors.txt +2 -0
- package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.node/node/logs.txt +11 -13
- package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.node/node/prompt.txt +10 -0
- package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.node/node/suite-0/given-testInitialization/then-0/butThen/hello.txt +1 -0
- package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.node/node/tests.json +10 -18
- package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.node/node/type_errors.txt +25 -13
- package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.pure/pure/lint_errors.txt +2 -0
- package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.pure/pure/prompt.txt +8 -0
- package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.pure/pure/type_errors.txt +24 -12
- package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.web/web/lint_errors.txt +2 -0
- package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.web/web/logs.txt +49 -55
- package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.web/web/prompt.txt +12 -2
- package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.web/web/suite-0/given-testInitialization/then-0/butThen/hello.txt +1 -0
- package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.web/web/tests.json +10 -18
- package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.web/web/type_errors.txt +24 -12
- package/testeranto/reports/allTests/summary.json +6 -62
- package/testeranto/reports/core/config.json +24 -0
- package/testeranto/reports/core/src/lib/baseBuilder.test/baseBuilder.test.node/node/lint_errors.txt +2 -0
- package/testeranto/reports/core/src/lib/baseBuilder.test/baseBuilder.test.node/node/logs.txt +32 -0
- package/testeranto/reports/core/src/lib/baseBuilder.test/baseBuilder.test.node/node/message.txt +2 -0
- package/testeranto/reports/core/src/lib/baseBuilder.test/baseBuilder.test.node/node/prompt.txt +26 -0
- package/testeranto/reports/core/src/lib/baseBuilder.test/baseBuilder.test.node/node/suite-0/given-testInitialization/then-0/butThen/hello.txt +1 -0
- package/testeranto/reports/core/src/lib/baseBuilder.test/baseBuilder.test.node/node/tests.json +69 -0
- package/testeranto/reports/core/src/lib/baseBuilder.test/baseBuilder.test.node/node/type_errors.txt +74 -0
- package/testeranto/reports/core/src/lib/baseBuilder.test/baseBuilder.test.pure/pure/lint_errors.txt +2 -0
- package/testeranto/reports/core/src/lib/baseBuilder.test/baseBuilder.test.pure/pure/message.txt +2 -0
- package/testeranto/reports/core/src/lib/baseBuilder.test/baseBuilder.test.pure/pure/prompt.txt +26 -0
- package/testeranto/reports/core/src/lib/baseBuilder.test/baseBuilder.test.pure/pure/type_errors.txt +74 -0
- package/testeranto/reports/core/src/lib/baseBuilder.test/baseBuilder.test.web/web/lint_errors.txt +2 -0
- package/testeranto/reports/core/src/lib/baseBuilder.test/baseBuilder.test.web/web/logs.txt +61 -0
- package/testeranto/reports/core/src/lib/baseBuilder.test/baseBuilder.test.web/web/message.txt +2 -0
- package/testeranto/reports/core/src/lib/baseBuilder.test/baseBuilder.test.web/web/prompt.txt +26 -0
- package/testeranto/reports/core/src/lib/baseBuilder.test/baseBuilder.test.web/web/suite-0/given-testInitialization/then-0/butThen/hello.txt +1 -0
- package/testeranto/reports/core/src/lib/baseBuilder.test/baseBuilder.test.web/web/tests.json +69 -0
- package/testeranto/reports/core/src/lib/baseBuilder.test/baseBuilder.test.web/web/type_errors.txt +74 -0
- package/testeranto/reports/core/summary.json +23 -0
- package/testeranto/reports/staticSite/config.json +24 -0
- package/testeranto/reports/staticSite/src/ReportServer.test.ts/index/node/lint_errors.txt +5 -0
- package/testeranto/reports/staticSite/src/ReportServer.test.ts/index/node/logs.txt +44 -0
- package/testeranto/reports/staticSite/src/ReportServer.test.ts/index/node/message.txt +2 -0
- package/testeranto/reports/staticSite/src/ReportServer.test.ts/index/node/prompt.txt +23 -0
- package/testeranto/reports/{allTests/src/lib/core.test/core.test → staticSite/src/ReportServer.test.ts/index}/node/type_errors.txt +21 -32
- package/testeranto/reports/staticSite/summary.json +9 -0
- package/testeranto/reportsnode_build_errors +17 -0
- package/testeranto.config.ts +37 -20
- package/testeranto/bundles/node/allTests/chunk-3EUGBAOM.mjs +0 -113
- package/testeranto/bundles/node/allTests/chunk-E75CSRER.mjs +0 -800
- package/testeranto/bundles/node/allTests/chunk-M6DO7VMB.mjs +0 -252
- package/testeranto/bundles/node/allTests/src/lib/BaseSuite.test/node.test.mjs +0 -323
- package/testeranto/bundles/node/allTests/src/lib/classBuilder.test/classBuilder.test.mjs +0 -411
- package/testeranto/bundles/node/allTests/src/lib/core.test/core.test.mjs +0 -528
- package/testeranto/bundles/node/allTests/src/lib/pmProxy.test/index.mjs +0 -4650
- package/testeranto/bundles/pure/allTests/chunk-KHDVEHF7.mjs +0 -185
- package/testeranto/bundles/pure/allTests/src/Pure.test.mjs +0 -429
- package/testeranto/bundles/pure/allTests/src/lib/BaseSuite.test/pure.test.mjs +0 -425
- package/testeranto/bundles/web/allTests/chunk-HPYA4YZC.mjs +0 -2283
- package/testeranto/bundles/web/allTests/src/components/pure/ProjectPageView.test/index.html +0 -19
- package/testeranto/bundles/web/allTests/src/components/pure/ProjectPageView.test/index.mjs +0 -37524
- package/testeranto/bundles/web/allTests/src/lib/BaseSuite.test/web.test.html +0 -19
- package/testeranto/bundles/web/allTests/src/lib/BaseSuite.test/web.test.mjs +0 -440
- package/testeranto/reports/allTests/src/Pure.test/pure/lint_errors.txt +0 -0
- package/testeranto/reports/allTests/src/Pure.test/pure/message.txt +0 -2
- package/testeranto/reports/allTests/src/Pure.test/pure/prompt.txt +0 -13
- package/testeranto/reports/allTests/src/Pure.test/pure/type_errors.txt +0 -101
- package/testeranto/reports/allTests/src/components/pure/ProjectPageView.test/index/web/lint_errors.txt +0 -13
- package/testeranto/reports/allTests/src/components/pure/ProjectPageView.test/index/web/logs.txt +0 -50
- package/testeranto/reports/allTests/src/components/pure/ProjectPageView.test/index/web/message.txt +0 -2
- package/testeranto/reports/allTests/src/components/pure/ProjectPageView.test/index/web/prompt.txt +0 -17
- package/testeranto/reports/allTests/src/components/pure/ProjectPageView.test/index/web/tests.json +0 -32
- package/testeranto/reports/allTests/src/components/pure/ProjectPageView.test/index/web/type_errors.txt +0 -68
- package/testeranto/reports/allTests/src/lib/BaseSuite.test/node.test/node/lint_errors.txt +0 -0
- package/testeranto/reports/allTests/src/lib/BaseSuite.test/node.test/node/logs.txt +0 -52
- package/testeranto/reports/allTests/src/lib/BaseSuite.test/node.test/node/message.txt +0 -2
- package/testeranto/reports/allTests/src/lib/BaseSuite.test/node.test/node/prompt.txt +0 -13
- package/testeranto/reports/allTests/src/lib/BaseSuite.test/node.test/node/tests.json +0 -31
- package/testeranto/reports/allTests/src/lib/BaseSuite.test/node.test/node/type_errors.txt +0 -111
- package/testeranto/reports/allTests/src/lib/BaseSuite.test/pure.test/pure/bdd_errors.txt +0 -1
- package/testeranto/reports/allTests/src/lib/BaseSuite.test/pure.test/pure/lint_errors.txt +0 -0
- package/testeranto/reports/allTests/src/lib/BaseSuite.test/pure.test/pure/message.txt +0 -2
- package/testeranto/reports/allTests/src/lib/BaseSuite.test/pure.test/pure/prompt.txt +0 -14
- package/testeranto/reports/allTests/src/lib/BaseSuite.test/pure.test/pure/tests.json +0 -31
- package/testeranto/reports/allTests/src/lib/BaseSuite.test/pure.test/pure/type_errors.txt +0 -111
- package/testeranto/reports/allTests/src/lib/BaseSuite.test/web.test/web/bdd_errors.txt +0 -1
- package/testeranto/reports/allTests/src/lib/BaseSuite.test/web.test/web/lint_errors.txt +0 -0
- package/testeranto/reports/allTests/src/lib/BaseSuite.test/web.test/web/logs.txt +0 -108
- package/testeranto/reports/allTests/src/lib/BaseSuite.test/web.test/web/message.txt +0 -2
- package/testeranto/reports/allTests/src/lib/BaseSuite.test/web.test/web/prompt.txt +0 -14
- package/testeranto/reports/allTests/src/lib/BaseSuite.test/web.test/web/tests.json +0 -31
- package/testeranto/reports/allTests/src/lib/BaseSuite.test/web.test/web/type_errors.txt +0 -111
- package/testeranto/reports/allTests/src/lib/classBuilder.test/classBuilder.test/node/bdd_errors.txt +0 -1
- package/testeranto/reports/allTests/src/lib/classBuilder.test/classBuilder.test/node/lint_errors.txt +0 -0
- package/testeranto/reports/allTests/src/lib/classBuilder.test/classBuilder.test/node/logs.txt +0 -700
- package/testeranto/reports/allTests/src/lib/classBuilder.test/classBuilder.test/node/message.txt +0 -2
- package/testeranto/reports/allTests/src/lib/classBuilder.test/classBuilder.test/node/prompt.txt +0 -16
- package/testeranto/reports/allTests/src/lib/classBuilder.test/classBuilder.test/node/tests.json +0 -164
- package/testeranto/reports/allTests/src/lib/classBuilder.test/classBuilder.test/node/type_errors.txt +0 -138
- package/testeranto/reports/allTests/src/lib/core.test/core.test/node/lint_errors.txt +0 -21
- package/testeranto/reports/allTests/src/lib/core.test/core.test/node/logs.txt +0 -7
- package/testeranto/reports/allTests/src/lib/core.test/core.test/node/message.txt +0 -2
- package/testeranto/reports/allTests/src/lib/core.test/core.test/node/prompt.txt +0 -18
- package/testeranto/reports/allTests/src/lib/pmProxy.test/index/node/bdd_errors.txt +0 -1
- package/testeranto/reports/allTests/src/lib/pmProxy.test/index/node/lint_errors.txt +0 -20
- package/testeranto/reports/allTests/src/lib/pmProxy.test/index/node/logs.txt +0 -31
- package/testeranto/reports/allTests/src/lib/pmProxy.test/index/node/message.txt +0 -2
- package/testeranto/reports/allTests/src/lib/pmProxy.test/index/node/prompt.txt +0 -16
- package/testeranto/reports/allTests/src/lib/pmProxy.test/index/node/tests.json +0 -134
- package/testeranto/reports/allTests/src/lib/pmProxy.test/index/node/type_errors.txt +0 -76
- package/testeranto/reportsweb_build_errors +0 -25
- /package/testeranto/reports/{allTests/src/components/pure/ProjectPageView.test/index/web → core/src/lib/baseBuilder.test/baseBuilder.test.node/node}/bdd_errors.txt +0 -0
- /package/testeranto/reports/{allTests/src/lib/BaseSuite.test/node.test/node → core/src/lib/baseBuilder.test/baseBuilder.test.web/web}/bdd_errors.txt +0 -0
|
@@ -1,34 +1,984 @@
|
|
|
1
1
|
import { createRequire } from 'module';const require = createRequire(import.meta.url);
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
|
|
3
|
+
// src/lib/index.ts
|
|
4
|
+
var BaseAdapter = () => ({
|
|
5
|
+
beforeAll: async (s) => s,
|
|
6
|
+
beforeEach: async function(subject, initialValues, x, testResource, pm) {
|
|
7
|
+
return subject;
|
|
8
|
+
},
|
|
9
|
+
afterEach: async (s) => s,
|
|
10
|
+
afterAll: (store) => void 0,
|
|
11
|
+
butThen: async (store, thenCb) => {
|
|
12
|
+
return thenCb(store);
|
|
13
|
+
},
|
|
14
|
+
andWhen: async (store, whenCB, testResource, pm) => {
|
|
15
|
+
try {
|
|
16
|
+
await whenCB(store, testResource, pm);
|
|
17
|
+
} catch (error) {
|
|
18
|
+
console.error("Error in andWhen:", error);
|
|
19
|
+
throw error;
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
assertThis: (x) => x
|
|
23
|
+
});
|
|
24
|
+
var DefaultAdapter = (p) => {
|
|
25
|
+
return {
|
|
26
|
+
...BaseAdapter,
|
|
27
|
+
...p
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
var defaultTestResourceRequirement = {
|
|
31
|
+
ports: 0
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
// src/lib/pmProxy.ts
|
|
35
|
+
var baseProxy = function(pm, mappings) {
|
|
36
|
+
return new Proxy(pm, {
|
|
37
|
+
get: (target, prop, receiver) => {
|
|
38
|
+
for (const mapping of mappings) {
|
|
39
|
+
const method = mapping[0];
|
|
40
|
+
const arger = mapping[1];
|
|
41
|
+
if (prop === method) {
|
|
42
|
+
return (...x) => target[prop](arger(...x));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return (...x) => target[prop](...x);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
var butThenProxy = (pm, filepath) => {
|
|
50
|
+
return baseProxy(pm, [
|
|
51
|
+
[
|
|
52
|
+
"screencast",
|
|
53
|
+
(opts, p) => {
|
|
54
|
+
const path2 = `${filepath}/butThen/${opts.path}`;
|
|
55
|
+
pm.currentStep?.artifacts?.push(path2);
|
|
56
|
+
return [
|
|
57
|
+
{
|
|
58
|
+
...opts,
|
|
59
|
+
path: path2
|
|
60
|
+
},
|
|
61
|
+
p
|
|
62
|
+
];
|
|
63
|
+
}
|
|
64
|
+
],
|
|
65
|
+
[
|
|
66
|
+
"createWriteStream",
|
|
67
|
+
(fp) => {
|
|
68
|
+
const path2 = `${filepath}/butThen/${fp}`;
|
|
69
|
+
pm.currentStep?.artifacts?.push(path2);
|
|
70
|
+
return [path2];
|
|
71
|
+
}
|
|
72
|
+
],
|
|
73
|
+
[
|
|
74
|
+
"writeFileSync",
|
|
75
|
+
(fp, contents) => {
|
|
76
|
+
const path2 = `${filepath}/butThen/${fp}`;
|
|
77
|
+
pm.currentStep?.artifacts?.push(path2);
|
|
78
|
+
return [path2, contents];
|
|
79
|
+
}
|
|
80
|
+
],
|
|
81
|
+
[
|
|
82
|
+
"customScreenShot",
|
|
83
|
+
(opts, p) => {
|
|
84
|
+
const path2 = `${filepath}/butThen/${opts.path}`;
|
|
85
|
+
pm.currentStep?.artifacts?.push(path2);
|
|
86
|
+
return [
|
|
87
|
+
{
|
|
88
|
+
...opts,
|
|
89
|
+
path: path2
|
|
90
|
+
},
|
|
91
|
+
p
|
|
92
|
+
];
|
|
93
|
+
}
|
|
94
|
+
]
|
|
95
|
+
]);
|
|
96
|
+
};
|
|
97
|
+
var andWhenProxy = (pm, filepath) => baseProxy(pm, [
|
|
98
|
+
[
|
|
99
|
+
"screencast",
|
|
100
|
+
(opts, p) => [
|
|
101
|
+
{
|
|
102
|
+
...opts,
|
|
103
|
+
path: `${filepath}/andWhen/${opts.path}`
|
|
104
|
+
},
|
|
105
|
+
p
|
|
106
|
+
]
|
|
107
|
+
],
|
|
108
|
+
["createWriteStream", (fp) => [`${filepath}/andWhen/${fp}`]],
|
|
109
|
+
["writeFileSync", (fp, contents) => [`${filepath}/andWhen${fp}`, contents]],
|
|
110
|
+
[
|
|
111
|
+
"customScreenShot",
|
|
112
|
+
(opts, p) => [
|
|
113
|
+
{
|
|
114
|
+
...opts,
|
|
115
|
+
path: `${filepath}/andWhen${opts.path}`
|
|
116
|
+
},
|
|
117
|
+
p
|
|
118
|
+
]
|
|
119
|
+
]
|
|
120
|
+
]);
|
|
121
|
+
var afterEachProxy = (pm, suite, given) => baseProxy(pm, [
|
|
122
|
+
[
|
|
123
|
+
"screencast",
|
|
124
|
+
(opts, p) => [
|
|
125
|
+
{
|
|
126
|
+
...opts,
|
|
127
|
+
path: `suite-${suite}/given-${given}/afterEach/${opts.path}`
|
|
128
|
+
},
|
|
129
|
+
p
|
|
130
|
+
]
|
|
131
|
+
],
|
|
132
|
+
["createWriteStream", (fp) => [`suite-${suite}/afterEach/${fp}`]],
|
|
133
|
+
[
|
|
134
|
+
"writeFileSync",
|
|
135
|
+
(fp, contents) => [
|
|
136
|
+
`suite-${suite}/given-${given}/afterEach/${fp}`,
|
|
137
|
+
contents
|
|
138
|
+
]
|
|
139
|
+
],
|
|
140
|
+
[
|
|
141
|
+
"customScreenShot",
|
|
142
|
+
(opts, p) => [
|
|
143
|
+
{
|
|
144
|
+
...opts,
|
|
145
|
+
path: `suite-${suite}/given-${given}/afterEach/${opts.path}`
|
|
146
|
+
},
|
|
147
|
+
p
|
|
148
|
+
]
|
|
149
|
+
]
|
|
150
|
+
]);
|
|
151
|
+
var beforeEachProxy = (pm, suite) => baseProxy(pm, [
|
|
152
|
+
[
|
|
153
|
+
"screencast",
|
|
154
|
+
(opts, p) => [
|
|
155
|
+
{
|
|
156
|
+
...opts,
|
|
157
|
+
path: `suite-${suite}/beforeEach/${opts.path}`
|
|
158
|
+
},
|
|
159
|
+
p
|
|
160
|
+
]
|
|
161
|
+
],
|
|
162
|
+
[
|
|
163
|
+
"writeFileSync",
|
|
164
|
+
(fp, contents) => [`suite-${suite}/beforeEach/${fp}`, contents]
|
|
165
|
+
],
|
|
166
|
+
[
|
|
167
|
+
"customScreenShot",
|
|
168
|
+
(opts, p) => [
|
|
169
|
+
{
|
|
170
|
+
...opts,
|
|
171
|
+
path: `suite-${suite}/beforeEach/${opts.path}`
|
|
172
|
+
},
|
|
173
|
+
p
|
|
174
|
+
]
|
|
175
|
+
],
|
|
176
|
+
["createWriteStream", (fp) => [`suite-${suite}/beforeEach/${fp}`]]
|
|
177
|
+
]);
|
|
178
|
+
var beforeAllProxy = (pm, suite) => baseProxy(pm, [
|
|
179
|
+
[
|
|
180
|
+
"writeFileSync",
|
|
181
|
+
(fp, contents) => [`suite-${suite}/beforeAll/${fp}`, contents]
|
|
182
|
+
],
|
|
183
|
+
[
|
|
184
|
+
"customScreenShot",
|
|
185
|
+
(opts, p) => [
|
|
186
|
+
{
|
|
187
|
+
...opts,
|
|
188
|
+
path: `suite-${suite}/beforeAll/${opts.path}`
|
|
189
|
+
},
|
|
190
|
+
p
|
|
191
|
+
]
|
|
192
|
+
],
|
|
193
|
+
["createWriteStream", (fp) => [`suite-${suite}/beforeAll/${fp}`]]
|
|
194
|
+
]);
|
|
195
|
+
var afterAllProxy = (pm, suite) => baseProxy(pm, [
|
|
196
|
+
["createWriteStream", (fp) => [`suite-${suite}/afterAll/${fp}`]],
|
|
197
|
+
[
|
|
198
|
+
"writeFileSync",
|
|
199
|
+
(fp, contents) => [`suite-${suite}/afterAll/${fp}`, contents]
|
|
200
|
+
],
|
|
201
|
+
[
|
|
202
|
+
"customScreenShot",
|
|
203
|
+
(opts, p) => [
|
|
204
|
+
{
|
|
205
|
+
...opts,
|
|
206
|
+
path: `suite-${suite}/afterAll/${opts.path}`
|
|
207
|
+
},
|
|
208
|
+
p
|
|
209
|
+
]
|
|
210
|
+
]
|
|
211
|
+
]);
|
|
212
|
+
|
|
213
|
+
// src/lib/abstractBase.ts
|
|
214
|
+
var BaseGiven = class {
|
|
215
|
+
constructor(name, features, whens, thens, givenCB, initialValues) {
|
|
216
|
+
this.artifacts = [];
|
|
217
|
+
this.name = name;
|
|
218
|
+
this.features = features;
|
|
219
|
+
this.whens = whens;
|
|
220
|
+
this.thens = thens;
|
|
221
|
+
this.givenCB = givenCB;
|
|
222
|
+
this.initialValues = initialValues;
|
|
223
|
+
}
|
|
224
|
+
addArtifact(path2) {
|
|
225
|
+
console.log(`[Artifact] Adding to ${this.constructor.name}:`, path2);
|
|
226
|
+
this.artifacts.push(path2);
|
|
227
|
+
}
|
|
228
|
+
beforeAll(store) {
|
|
229
|
+
return store;
|
|
230
|
+
}
|
|
231
|
+
toObj() {
|
|
232
|
+
return {
|
|
233
|
+
key: this.key,
|
|
234
|
+
name: this.name,
|
|
235
|
+
whens: this.whens.map((w) => {
|
|
236
|
+
if (w && w.toObj)
|
|
237
|
+
return w.toObj();
|
|
238
|
+
console.error("w is not as expected!", w.toString());
|
|
239
|
+
return {};
|
|
240
|
+
}),
|
|
241
|
+
thens: this.thens.map((t) => t.toObj()),
|
|
242
|
+
error: this.error ? [this.error, this.error.stack] : null,
|
|
243
|
+
failed: this.failed,
|
|
244
|
+
features: this.features,
|
|
245
|
+
artifacts: this.artifacts
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
async afterEach(store, key, artifactory, pm) {
|
|
249
|
+
return store;
|
|
250
|
+
}
|
|
251
|
+
async give(subject, key, testResourceConfiguration, tester, artifactory, tLog, pm, suiteNdx) {
|
|
252
|
+
this.key = key;
|
|
253
|
+
tLog(`
|
|
254
|
+
${this.key}`);
|
|
255
|
+
tLog(`
|
|
256
|
+
Given: ${this.name}`);
|
|
257
|
+
const givenArtifactory = (fPath, value) => artifactory(`given-${key}/${fPath}`, value);
|
|
258
|
+
this.uberCatcher((e) => {
|
|
259
|
+
console.error(e.toString());
|
|
260
|
+
this.error = e.error;
|
|
261
|
+
tLog(e.stack);
|
|
262
|
+
});
|
|
263
|
+
try {
|
|
264
|
+
const proxiedPm = beforeEachProxy(pm, suiteNdx.toString());
|
|
265
|
+
console.log(`[Given] Setting currentStep for beforeEach:`, this.name);
|
|
266
|
+
proxiedPm.currentStep = this;
|
|
267
|
+
this.store = await this.givenThat(
|
|
268
|
+
subject,
|
|
269
|
+
testResourceConfiguration,
|
|
270
|
+
givenArtifactory,
|
|
271
|
+
this.givenCB,
|
|
272
|
+
this.initialValues,
|
|
273
|
+
proxiedPm
|
|
274
|
+
);
|
|
275
|
+
} catch (e) {
|
|
276
|
+
console.error("Given failure: ", e.toString());
|
|
277
|
+
this.error = e;
|
|
278
|
+
throw e;
|
|
279
|
+
}
|
|
280
|
+
try {
|
|
281
|
+
for (const [whenNdx, whenStep] of this.whens.entries()) {
|
|
282
|
+
await whenStep.test(
|
|
283
|
+
this.store,
|
|
284
|
+
testResourceConfiguration,
|
|
285
|
+
tLog,
|
|
286
|
+
pm,
|
|
287
|
+
`suite-${suiteNdx}/given-${key}/when/${whenNdx}`
|
|
288
|
+
);
|
|
289
|
+
}
|
|
290
|
+
for (const [thenNdx, thenStep] of this.thens.entries()) {
|
|
291
|
+
const t = await thenStep.test(
|
|
292
|
+
this.store,
|
|
293
|
+
testResourceConfiguration,
|
|
294
|
+
tLog,
|
|
295
|
+
pm,
|
|
296
|
+
`suite-${suiteNdx}/given-${key}/then-${thenNdx}`
|
|
297
|
+
);
|
|
298
|
+
tester(t);
|
|
299
|
+
}
|
|
300
|
+
} catch (e) {
|
|
301
|
+
this.failed = true;
|
|
302
|
+
tLog(e.stack);
|
|
303
|
+
throw e;
|
|
304
|
+
} finally {
|
|
305
|
+
try {
|
|
306
|
+
await this.afterEach(
|
|
307
|
+
this.store,
|
|
308
|
+
this.key,
|
|
309
|
+
givenArtifactory,
|
|
310
|
+
afterEachProxy(pm, suiteNdx.toString(), key)
|
|
311
|
+
);
|
|
312
|
+
} catch (e) {
|
|
313
|
+
console.error("afterEach failed!", e.toString());
|
|
314
|
+
this.failed = e;
|
|
315
|
+
throw e;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
return this.store;
|
|
319
|
+
}
|
|
320
|
+
};
|
|
321
|
+
var BaseWhen = class {
|
|
322
|
+
constructor(name, whenCB) {
|
|
323
|
+
this.artifacts = [];
|
|
324
|
+
this.name = name;
|
|
325
|
+
this.whenCB = whenCB;
|
|
326
|
+
}
|
|
327
|
+
toObj() {
|
|
328
|
+
console.log("toObj error", this.error);
|
|
329
|
+
if (this.error) {
|
|
330
|
+
return {
|
|
331
|
+
name: this.name,
|
|
332
|
+
error: this.error && this.error.name + this.error.stack,
|
|
333
|
+
artifacts: this.artifacts
|
|
334
|
+
};
|
|
335
|
+
} else {
|
|
336
|
+
return {
|
|
337
|
+
name: this.name,
|
|
338
|
+
artifacts: this.artifacts
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
async test(store, testResourceConfiguration, tLog, pm, filepath) {
|
|
343
|
+
try {
|
|
344
|
+
tLog(" When:", this.name);
|
|
345
|
+
console.debug("[DEBUG] Executing When step:", this.name.toString());
|
|
346
|
+
const proxiedPm = andWhenProxy(pm, filepath);
|
|
347
|
+
console.log(`[When] Setting currentStep for andWhen:`, this.name);
|
|
348
|
+
proxiedPm.currentStep = this;
|
|
349
|
+
const result = await this.andWhen(
|
|
350
|
+
store,
|
|
351
|
+
this.whenCB,
|
|
352
|
+
testResourceConfiguration,
|
|
353
|
+
proxiedPm
|
|
354
|
+
);
|
|
355
|
+
console.debug("[DEBUG] When step completed:", this.name.toString());
|
|
356
|
+
return result;
|
|
357
|
+
} catch (e) {
|
|
358
|
+
console.error(
|
|
359
|
+
"[ERROR] When step failed:",
|
|
360
|
+
this.name.toString(),
|
|
361
|
+
e.toString()
|
|
362
|
+
);
|
|
363
|
+
this.error = e;
|
|
364
|
+
throw e;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
};
|
|
368
|
+
var BaseThen = class {
|
|
369
|
+
constructor(name, thenCB) {
|
|
370
|
+
this.artifacts = [];
|
|
371
|
+
this.name = name;
|
|
372
|
+
this.thenCB = thenCB;
|
|
373
|
+
this.error = false;
|
|
374
|
+
}
|
|
375
|
+
toObj() {
|
|
376
|
+
return {
|
|
377
|
+
name: this.name,
|
|
378
|
+
error: this.error,
|
|
379
|
+
artifacts: this.artifacts
|
|
380
|
+
};
|
|
381
|
+
}
|
|
382
|
+
async test(store, testResourceConfiguration, tLog, pm, filepath) {
|
|
383
|
+
const proxiedPm = butThenProxy(pm, filepath);
|
|
384
|
+
console.log(`[Then] Setting currentStep for butThen:`, this.name);
|
|
385
|
+
proxiedPm.currentStep = this;
|
|
386
|
+
return this.butThen(
|
|
387
|
+
store,
|
|
388
|
+
async (s) => {
|
|
389
|
+
if (typeof this.thenCB === "function") {
|
|
390
|
+
return await this.thenCB(s, proxiedPm);
|
|
391
|
+
} else {
|
|
392
|
+
return this.thenCB;
|
|
393
|
+
}
|
|
394
|
+
},
|
|
395
|
+
testResourceConfiguration,
|
|
396
|
+
butThenProxy(pm, filepath)
|
|
397
|
+
).catch((e) => {
|
|
398
|
+
this.error = e.toString();
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
};
|
|
402
|
+
|
|
403
|
+
// src/lib/basebuilder.ts
|
|
404
|
+
var BaseBuilder = class {
|
|
405
|
+
constructor(input, suitesOverrides, givenOverides, whenOverides, thenOverides, testResourceRequirement, testSpecification) {
|
|
406
|
+
this.artifacts = [];
|
|
407
|
+
this.artifacts = [];
|
|
408
|
+
this.testResourceRequirement = testResourceRequirement;
|
|
409
|
+
this.suitesOverrides = suitesOverrides;
|
|
410
|
+
this.givenOverides = givenOverides;
|
|
411
|
+
this.whenOverides = whenOverides;
|
|
412
|
+
this.thenOverides = thenOverides;
|
|
413
|
+
this.testSpecification = testSpecification;
|
|
414
|
+
this.specs = testSpecification(
|
|
415
|
+
this.Suites(),
|
|
416
|
+
this.Given(),
|
|
417
|
+
this.When(),
|
|
418
|
+
this.Then()
|
|
419
|
+
);
|
|
420
|
+
this.testJobs = this.specs.map((suite) => {
|
|
421
|
+
const suiteRunner = (suite2) => async (puppetMaster, tLog) => {
|
|
422
|
+
const x = await suite2.run(
|
|
423
|
+
input,
|
|
424
|
+
puppetMaster.testResourceConfiguration,
|
|
425
|
+
(fPath, value) => puppetMaster.testArtiFactoryfileWriter(
|
|
426
|
+
tLog,
|
|
427
|
+
(p) => {
|
|
428
|
+
this.artifacts.push(p);
|
|
429
|
+
}
|
|
430
|
+
)(puppetMaster.testResourceConfiguration.fs + "/" + fPath, value),
|
|
431
|
+
tLog,
|
|
432
|
+
puppetMaster
|
|
433
|
+
);
|
|
434
|
+
return x;
|
|
435
|
+
};
|
|
436
|
+
const runner = suiteRunner(suite);
|
|
437
|
+
return {
|
|
438
|
+
test: suite,
|
|
439
|
+
toObj: () => {
|
|
440
|
+
return suite.toObj();
|
|
441
|
+
},
|
|
442
|
+
runner,
|
|
443
|
+
receiveTestResourceConfig: async function(puppetMaster) {
|
|
444
|
+
const tLog = async (...l) => {
|
|
445
|
+
};
|
|
446
|
+
const suiteDone = await runner(puppetMaster, tLog);
|
|
447
|
+
const fails = suiteDone.fails;
|
|
448
|
+
await puppetMaster.writeFileSync([
|
|
449
|
+
`bdd_errors.txt`,
|
|
450
|
+
fails.toString()
|
|
451
|
+
]);
|
|
452
|
+
await puppetMaster.writeFileSync([
|
|
453
|
+
`tests.json`,
|
|
454
|
+
JSON.stringify(this.toObj(), null, 2)
|
|
455
|
+
]);
|
|
456
|
+
return {
|
|
457
|
+
failed: fails > 0,
|
|
458
|
+
fails,
|
|
459
|
+
artifacts: this.artifacts || [],
|
|
460
|
+
// logPromise,
|
|
461
|
+
features: suiteDone.features()
|
|
462
|
+
};
|
|
463
|
+
}
|
|
464
|
+
};
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
// testsJson() {
|
|
468
|
+
// puppetMaster.writeFileSync(
|
|
469
|
+
// `tests.json`,
|
|
470
|
+
// JSON.stringify({ features: suiteDone.features() }, null, 2)
|
|
471
|
+
// );
|
|
472
|
+
// }
|
|
473
|
+
Specs() {
|
|
474
|
+
return this.specs;
|
|
475
|
+
}
|
|
476
|
+
Suites() {
|
|
477
|
+
return this.suitesOverrides;
|
|
478
|
+
}
|
|
479
|
+
Given() {
|
|
480
|
+
return this.givenOverides;
|
|
481
|
+
}
|
|
482
|
+
When() {
|
|
483
|
+
return this.whenOverides;
|
|
484
|
+
}
|
|
485
|
+
Then() {
|
|
486
|
+
return this.thenOverides;
|
|
487
|
+
}
|
|
488
|
+
};
|
|
489
|
+
|
|
490
|
+
// src/lib/classBuilder.ts
|
|
491
|
+
var ClassBuilder = class extends BaseBuilder {
|
|
492
|
+
constructor(testImplementation, testSpecification, input, suiteKlasser, givenKlasser, whenKlasser, thenKlasser, testResourceRequirement) {
|
|
493
|
+
const classySuites = Object.entries(testImplementation.suites).reduce(
|
|
494
|
+
(a, [key], index) => {
|
|
495
|
+
a[key] = (somestring, givens) => {
|
|
496
|
+
return new suiteKlasser.prototype.constructor(
|
|
497
|
+
somestring,
|
|
498
|
+
index,
|
|
499
|
+
givens
|
|
500
|
+
);
|
|
501
|
+
};
|
|
502
|
+
return a;
|
|
503
|
+
},
|
|
504
|
+
{}
|
|
505
|
+
);
|
|
506
|
+
const classyGivens = Object.entries(testImplementation.givens).reduce(
|
|
507
|
+
(a, [key, g]) => {
|
|
508
|
+
a[key] = (features, whens, thens, ...initialValues) => {
|
|
509
|
+
return new givenKlasser.prototype.constructor(
|
|
510
|
+
key,
|
|
511
|
+
features,
|
|
512
|
+
whens,
|
|
513
|
+
thens,
|
|
514
|
+
testImplementation.givens[key],
|
|
515
|
+
initialValues
|
|
516
|
+
);
|
|
517
|
+
};
|
|
518
|
+
return a;
|
|
519
|
+
},
|
|
520
|
+
{}
|
|
521
|
+
);
|
|
522
|
+
const classyWhens = Object.entries(testImplementation.whens).reduce(
|
|
523
|
+
(a, [key, whEn]) => {
|
|
524
|
+
a[key] = (...payload) => {
|
|
525
|
+
return new whenKlasser.prototype.constructor(
|
|
526
|
+
`${whEn.name}: ${payload && payload.toString()}`,
|
|
527
|
+
whEn(...payload)
|
|
528
|
+
);
|
|
529
|
+
};
|
|
530
|
+
return a;
|
|
531
|
+
},
|
|
532
|
+
{}
|
|
533
|
+
);
|
|
534
|
+
const classyThens = Object.entries(
|
|
535
|
+
testImplementation.thens
|
|
536
|
+
).reduce(
|
|
537
|
+
(a, [key, thEn]) => {
|
|
538
|
+
a[key] = (expected, ...x) => {
|
|
539
|
+
return new thenKlasser.prototype.constructor(
|
|
540
|
+
`${thEn.name}: ${expected && expected.toString()}`,
|
|
541
|
+
thEn(expected, ...x)
|
|
542
|
+
);
|
|
543
|
+
};
|
|
544
|
+
return a;
|
|
545
|
+
},
|
|
546
|
+
{}
|
|
547
|
+
);
|
|
548
|
+
super(
|
|
549
|
+
input,
|
|
550
|
+
classySuites,
|
|
551
|
+
classyGivens,
|
|
552
|
+
classyWhens,
|
|
553
|
+
classyThens,
|
|
554
|
+
testResourceRequirement,
|
|
555
|
+
testSpecification
|
|
556
|
+
);
|
|
557
|
+
}
|
|
558
|
+
};
|
|
559
|
+
|
|
560
|
+
// src/lib/BaseSuite.ts
|
|
561
|
+
var BaseSuite = class {
|
|
562
|
+
constructor(name, index, givens = {}) {
|
|
563
|
+
const suiteName = name || "testSuite";
|
|
564
|
+
if (!suiteName) {
|
|
565
|
+
throw new Error("BaseSuite requires a non-empty name");
|
|
566
|
+
}
|
|
567
|
+
console.log(
|
|
568
|
+
"[DEBUG] BaseSuite constructor - name:",
|
|
569
|
+
suiteName,
|
|
570
|
+
"index:",
|
|
571
|
+
index
|
|
572
|
+
);
|
|
573
|
+
this.name = suiteName;
|
|
574
|
+
this.index = index;
|
|
575
|
+
this.givens = givens;
|
|
576
|
+
this.fails = 0;
|
|
577
|
+
console.log("[DEBUG] BaseSuite initialized:", this.name, this.index);
|
|
578
|
+
console.log("[DEBUG] BaseSuite givens:", Object.keys(givens).toString());
|
|
579
|
+
}
|
|
580
|
+
features() {
|
|
581
|
+
try {
|
|
582
|
+
const features = Object.keys(this.givens).map((k) => this.givens[k].features).flat().filter((value, index, array) => {
|
|
583
|
+
return array.indexOf(value) === index;
|
|
584
|
+
});
|
|
585
|
+
console.debug("[DEBUG] Features extracted:", features.toString());
|
|
586
|
+
return features || [];
|
|
587
|
+
} catch (e) {
|
|
588
|
+
console.error("[ERROR] Failed to extract features:", e);
|
|
589
|
+
return [];
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
toObj() {
|
|
593
|
+
const givens = Object.keys(this.givens).map((k) => this.givens[k].toObj());
|
|
594
|
+
return {
|
|
595
|
+
name: this.name,
|
|
596
|
+
givens,
|
|
597
|
+
fails: this.fails,
|
|
598
|
+
failed: this.failed,
|
|
599
|
+
features: this.features()
|
|
600
|
+
};
|
|
601
|
+
}
|
|
602
|
+
setup(s, artifactory, tr, pm) {
|
|
603
|
+
return new Promise((res) => res(s));
|
|
604
|
+
}
|
|
605
|
+
assertThat(t) {
|
|
606
|
+
return !!t;
|
|
607
|
+
}
|
|
608
|
+
afterAll(store, artifactory, pm) {
|
|
609
|
+
return store;
|
|
610
|
+
}
|
|
611
|
+
async run(input, testResourceConfiguration, artifactory, tLog, pm) {
|
|
612
|
+
this.testResourceConfiguration = testResourceConfiguration;
|
|
613
|
+
const suiteArtifactory = (fPath, value) => artifactory(`suite-${this.index}-${this.name}/${fPath}`, value);
|
|
614
|
+
tLog("\nSuite:", this.index, this.name);
|
|
615
|
+
const sNdx = this.index;
|
|
616
|
+
const subject = await this.setup(
|
|
617
|
+
input,
|
|
618
|
+
suiteArtifactory,
|
|
619
|
+
testResourceConfiguration,
|
|
620
|
+
beforeAllProxy(pm, sNdx.toString())
|
|
621
|
+
);
|
|
622
|
+
for (const [gKey, g] of Object.entries(this.givens)) {
|
|
623
|
+
const giver = this.givens[gKey];
|
|
624
|
+
this.store = await giver.give(
|
|
625
|
+
subject,
|
|
626
|
+
gKey,
|
|
627
|
+
testResourceConfiguration,
|
|
628
|
+
this.assertThat,
|
|
629
|
+
suiteArtifactory,
|
|
630
|
+
tLog,
|
|
631
|
+
pm,
|
|
632
|
+
sNdx
|
|
633
|
+
).catch((e) => {
|
|
634
|
+
this.failed = true;
|
|
635
|
+
this.fails = this.fails + 1;
|
|
636
|
+
throw e;
|
|
637
|
+
});
|
|
638
|
+
}
|
|
639
|
+
try {
|
|
640
|
+
this.afterAll(
|
|
641
|
+
this.store,
|
|
642
|
+
artifactory,
|
|
643
|
+
afterAllProxy(pm, sNdx.toString())
|
|
644
|
+
);
|
|
645
|
+
} catch (e) {
|
|
646
|
+
console.error(e);
|
|
647
|
+
}
|
|
648
|
+
return this;
|
|
649
|
+
}
|
|
650
|
+
};
|
|
651
|
+
|
|
652
|
+
// src/lib/core.ts
|
|
653
|
+
var TesterantoCore = class extends ClassBuilder {
|
|
654
|
+
constructor(input, testSpecification, testImplementation, testResourceRequirement = defaultTestResourceRequirement, testAdapter2, uberCatcher) {
|
|
655
|
+
const fullAdapter = DefaultAdapter(testAdapter2);
|
|
656
|
+
super(
|
|
657
|
+
testImplementation,
|
|
658
|
+
testSpecification,
|
|
659
|
+
input,
|
|
660
|
+
class extends BaseSuite {
|
|
661
|
+
afterAll(store, artifactory, pm) {
|
|
662
|
+
return fullAdapter.afterAll(store, pm);
|
|
663
|
+
}
|
|
664
|
+
assertThat(t) {
|
|
665
|
+
return fullAdapter.assertThis(t);
|
|
666
|
+
}
|
|
667
|
+
async setup(s, artifactory, tr, pm) {
|
|
668
|
+
return (fullAdapter.beforeAll || (async (input2, artifactory2, tr2, pm2) => input2))(
|
|
669
|
+
s,
|
|
670
|
+
this.testResourceConfiguration,
|
|
671
|
+
// artifactory,
|
|
672
|
+
pm
|
|
673
|
+
);
|
|
674
|
+
}
|
|
675
|
+
},
|
|
676
|
+
class Given extends BaseGiven {
|
|
677
|
+
constructor() {
|
|
678
|
+
super(...arguments);
|
|
679
|
+
this.uberCatcher = uberCatcher;
|
|
680
|
+
}
|
|
681
|
+
async givenThat(subject, testResource, artifactory, initializer, initialValues, pm) {
|
|
682
|
+
return fullAdapter.beforeEach(
|
|
683
|
+
subject,
|
|
684
|
+
initializer,
|
|
685
|
+
testResource,
|
|
686
|
+
initialValues,
|
|
687
|
+
pm
|
|
688
|
+
);
|
|
689
|
+
}
|
|
690
|
+
afterEach(store, key, artifactory, pm) {
|
|
691
|
+
return new Promise(
|
|
692
|
+
(res) => res(fullAdapter.afterEach(store, key, pm))
|
|
693
|
+
);
|
|
694
|
+
}
|
|
695
|
+
},
|
|
696
|
+
class When extends BaseWhen {
|
|
697
|
+
async andWhen(store, whenCB, testResource, pm) {
|
|
698
|
+
return await fullAdapter.andWhen(store, whenCB, testResource, pm);
|
|
699
|
+
}
|
|
700
|
+
},
|
|
701
|
+
class Then extends BaseThen {
|
|
702
|
+
async butThen(store, thenCB, testResource, pm) {
|
|
703
|
+
return await fullAdapter.butThen(store, thenCB, testResource, pm);
|
|
704
|
+
}
|
|
705
|
+
},
|
|
706
|
+
testResourceRequirement
|
|
707
|
+
);
|
|
708
|
+
}
|
|
709
|
+
};
|
|
710
|
+
|
|
711
|
+
// src/PM/node.ts
|
|
712
|
+
import net from "net";
|
|
713
|
+
import fs from "fs";
|
|
714
|
+
import path from "path";
|
|
715
|
+
|
|
716
|
+
// src/PM/index.ts
|
|
717
|
+
var PM = class {
|
|
718
|
+
};
|
|
719
|
+
|
|
720
|
+
// src/PM/node.ts
|
|
721
|
+
var fPaths = [];
|
|
722
|
+
var PM_Node = class extends PM {
|
|
723
|
+
constructor(t, ipcFile) {
|
|
724
|
+
super();
|
|
725
|
+
this.testResourceConfiguration = t;
|
|
726
|
+
this.client = net.createConnection(ipcFile, () => {
|
|
727
|
+
return;
|
|
728
|
+
});
|
|
729
|
+
}
|
|
730
|
+
start() {
|
|
731
|
+
throw new Error("DEPRECATED");
|
|
732
|
+
}
|
|
733
|
+
stop() {
|
|
734
|
+
throw new Error("stop not implemented.");
|
|
735
|
+
}
|
|
736
|
+
send(command, ...argz) {
|
|
737
|
+
const key = Math.random().toString();
|
|
738
|
+
if (!this.client) {
|
|
739
|
+
console.error(
|
|
740
|
+
`Tried to send "${command} (${argz})" but the test has not been started and the IPC client is not established. Exiting as failure!`
|
|
741
|
+
);
|
|
742
|
+
process.exit(-1);
|
|
743
|
+
}
|
|
744
|
+
return new Promise((res) => {
|
|
745
|
+
const myListener = (event) => {
|
|
746
|
+
const x = JSON.parse(event);
|
|
747
|
+
if (x.key === key) {
|
|
748
|
+
process.removeListener("message", myListener);
|
|
749
|
+
res(x.payload);
|
|
750
|
+
}
|
|
751
|
+
};
|
|
752
|
+
process.addListener("message", myListener);
|
|
753
|
+
this.client.write(JSON.stringify([command, ...argz, key]));
|
|
754
|
+
});
|
|
755
|
+
}
|
|
756
|
+
async launchSideCar(n) {
|
|
757
|
+
return this.send(
|
|
758
|
+
"launchSideCar",
|
|
759
|
+
n,
|
|
760
|
+
this.testResourceConfiguration.name
|
|
761
|
+
);
|
|
762
|
+
}
|
|
763
|
+
stopSideCar(n) {
|
|
764
|
+
return this.send(
|
|
765
|
+
"stopSideCar",
|
|
766
|
+
n,
|
|
767
|
+
this.testResourceConfiguration.name
|
|
768
|
+
);
|
|
769
|
+
}
|
|
770
|
+
async pages() {
|
|
771
|
+
return this.send("pages", ...arguments);
|
|
772
|
+
}
|
|
773
|
+
waitForSelector(p, s) {
|
|
774
|
+
return this.send("waitForSelector", ...arguments);
|
|
775
|
+
}
|
|
776
|
+
closePage(p) {
|
|
777
|
+
return this.send("closePage", ...arguments);
|
|
778
|
+
}
|
|
779
|
+
goto(page, url) {
|
|
780
|
+
return this.send("goto", ...arguments);
|
|
781
|
+
}
|
|
782
|
+
async newPage() {
|
|
783
|
+
return this.send("newPage");
|
|
784
|
+
}
|
|
785
|
+
$(selector, page) {
|
|
786
|
+
return this.send("$", ...arguments);
|
|
787
|
+
}
|
|
788
|
+
isDisabled(selector) {
|
|
789
|
+
return this.send("isDisabled", ...arguments);
|
|
790
|
+
}
|
|
791
|
+
getAttribute(selector, attribute, p) {
|
|
792
|
+
return this.send("getAttribute", ...arguments);
|
|
793
|
+
}
|
|
794
|
+
getInnerHtml(selector, p) {
|
|
795
|
+
return this.send("getInnerHtml", ...arguments);
|
|
796
|
+
}
|
|
797
|
+
// setValue(selector: string) {
|
|
798
|
+
// return this.send("getValue", ...arguments);
|
|
799
|
+
// }
|
|
800
|
+
focusOn(selector) {
|
|
801
|
+
return this.send("focusOn", ...arguments);
|
|
802
|
+
}
|
|
803
|
+
typeInto(selector) {
|
|
804
|
+
return this.send("typeInto", ...arguments);
|
|
805
|
+
}
|
|
806
|
+
page() {
|
|
807
|
+
return this.send("page");
|
|
808
|
+
}
|
|
809
|
+
click(selector) {
|
|
810
|
+
return this.send("click", ...arguments);
|
|
811
|
+
}
|
|
812
|
+
screencast(opts, page) {
|
|
813
|
+
return this.send(
|
|
814
|
+
"screencast",
|
|
815
|
+
{
|
|
816
|
+
...opts,
|
|
817
|
+
path: this.testResourceConfiguration.fs + "/" + opts.path
|
|
818
|
+
},
|
|
819
|
+
page,
|
|
820
|
+
this.testResourceConfiguration.name
|
|
821
|
+
);
|
|
822
|
+
}
|
|
823
|
+
screencastStop(p) {
|
|
824
|
+
return this.send("screencastStop", ...arguments);
|
|
825
|
+
}
|
|
826
|
+
customScreenShot(x, y) {
|
|
827
|
+
const opts = x[0];
|
|
828
|
+
const page = x[1];
|
|
829
|
+
return this.send(
|
|
830
|
+
"customScreenShot",
|
|
831
|
+
{
|
|
832
|
+
...opts,
|
|
833
|
+
path: this.testResourceConfiguration.fs + "/" + opts.path
|
|
834
|
+
},
|
|
835
|
+
this.testResourceConfiguration.name,
|
|
836
|
+
page
|
|
837
|
+
);
|
|
838
|
+
}
|
|
839
|
+
async existsSync(destFolder) {
|
|
840
|
+
return await this.send(
|
|
841
|
+
"existsSync",
|
|
842
|
+
this.testResourceConfiguration.fs + "/" + destFolder
|
|
843
|
+
);
|
|
844
|
+
}
|
|
845
|
+
mkdirSync() {
|
|
846
|
+
return this.send("mkdirSync", this.testResourceConfiguration.fs + "/");
|
|
847
|
+
}
|
|
848
|
+
async write(uid, contents) {
|
|
849
|
+
return await this.send("write", ...arguments);
|
|
850
|
+
}
|
|
851
|
+
async writeFileSync([filepath, contents]) {
|
|
852
|
+
return await this.send(
|
|
853
|
+
"writeFileSync",
|
|
854
|
+
this.testResourceConfiguration.fs + "/" + filepath,
|
|
855
|
+
contents,
|
|
856
|
+
this.testResourceConfiguration.name
|
|
857
|
+
);
|
|
858
|
+
}
|
|
859
|
+
async createWriteStream(filepath) {
|
|
860
|
+
return await this.send(
|
|
861
|
+
"createWriteStream",
|
|
862
|
+
this.testResourceConfiguration.fs + "/" + filepath,
|
|
863
|
+
this.testResourceConfiguration.name
|
|
864
|
+
);
|
|
865
|
+
}
|
|
866
|
+
async end(uid) {
|
|
867
|
+
return await this.send("end", ...arguments);
|
|
868
|
+
}
|
|
869
|
+
async customclose() {
|
|
870
|
+
return await this.send(
|
|
871
|
+
"customclose",
|
|
872
|
+
this.testResourceConfiguration.fs,
|
|
873
|
+
this.testResourceConfiguration.name
|
|
874
|
+
);
|
|
875
|
+
}
|
|
876
|
+
testArtiFactoryfileWriter(tLog, callback) {
|
|
877
|
+
return (fPath, value) => {
|
|
878
|
+
callback(
|
|
879
|
+
new Promise((res, rej) => {
|
|
880
|
+
tLog("testArtiFactory =>", fPath);
|
|
881
|
+
const cleanPath = path.resolve(fPath);
|
|
882
|
+
fPaths.push(cleanPath.replace(process.cwd(), ``));
|
|
883
|
+
const targetDir = cleanPath.split("/").slice(0, -1).join("/");
|
|
884
|
+
fs.mkdir(targetDir, { recursive: true }, async (error) => {
|
|
885
|
+
if (error) {
|
|
886
|
+
console.error(`\u2757\uFE0FtestArtiFactory failed`, targetDir, error);
|
|
887
|
+
}
|
|
888
|
+
if (Buffer.isBuffer(value)) {
|
|
889
|
+
fs.writeFileSync(fPath, value, "binary");
|
|
890
|
+
res();
|
|
891
|
+
} else if (`string` === typeof value) {
|
|
892
|
+
fs.writeFileSync(fPath, value.toString(), {
|
|
893
|
+
encoding: "utf-8"
|
|
894
|
+
});
|
|
895
|
+
res();
|
|
896
|
+
} else {
|
|
897
|
+
const pipeStream = value;
|
|
898
|
+
const myFile = fs.createWriteStream(fPath);
|
|
899
|
+
pipeStream.pipe(myFile);
|
|
900
|
+
pipeStream.on("close", () => {
|
|
901
|
+
myFile.close();
|
|
902
|
+
res();
|
|
903
|
+
});
|
|
904
|
+
}
|
|
905
|
+
});
|
|
906
|
+
})
|
|
907
|
+
);
|
|
908
|
+
};
|
|
909
|
+
}
|
|
910
|
+
// launch(options?: PuppeteerLaunchOptions): Promise<Browser>;
|
|
911
|
+
startPuppeteer(options) {
|
|
912
|
+
}
|
|
913
|
+
};
|
|
914
|
+
|
|
915
|
+
// src/Node.ts
|
|
916
|
+
var ipcfile;
|
|
917
|
+
var NodeTesteranto = class extends TesterantoCore {
|
|
918
|
+
constructor(input, testSpecification, testImplementation, testResourceRequirement, testAdapter2) {
|
|
919
|
+
super(
|
|
920
|
+
input,
|
|
921
|
+
testSpecification,
|
|
922
|
+
testImplementation,
|
|
923
|
+
testResourceRequirement,
|
|
924
|
+
testAdapter2,
|
|
925
|
+
() => {
|
|
926
|
+
}
|
|
927
|
+
);
|
|
928
|
+
}
|
|
929
|
+
async receiveTestResourceConfig(partialTestResource) {
|
|
930
|
+
console.log("receiveTestResourceConfig", partialTestResource);
|
|
931
|
+
const t = JSON.parse(partialTestResource);
|
|
932
|
+
const pm = new PM_Node(t, ipcfile);
|
|
933
|
+
return await this.testJobs[0].receiveTestResourceConfig(pm);
|
|
934
|
+
}
|
|
935
|
+
};
|
|
936
|
+
var testeranto = async (input, testSpecification, testImplementation, testAdapter2, testResourceRequirement = defaultTestResourceRequirement) => {
|
|
937
|
+
try {
|
|
938
|
+
const t = new NodeTesteranto(
|
|
939
|
+
input,
|
|
940
|
+
testSpecification,
|
|
941
|
+
testImplementation,
|
|
942
|
+
testResourceRequirement,
|
|
943
|
+
testAdapter2
|
|
944
|
+
);
|
|
945
|
+
process.on("unhandledRejection", (reason, promise) => {
|
|
946
|
+
console.error("Unhandled Rejection at:", promise, "reason:", reason);
|
|
947
|
+
});
|
|
948
|
+
ipcfile = process.argv[3];
|
|
949
|
+
const f = await t.receiveTestResourceConfig(process.argv[2]);
|
|
950
|
+
console.error("goodbye node with failures", f.fails);
|
|
951
|
+
process.exit(f.fails);
|
|
952
|
+
} catch (e) {
|
|
953
|
+
console.error("goodbye node with caught error", e);
|
|
954
|
+
process.exit(-1);
|
|
955
|
+
}
|
|
956
|
+
};
|
|
957
|
+
var Node_default = testeranto;
|
|
8
958
|
|
|
9
959
|
// src/lib/baseBuilder.test/baseBuilder.test.specification.ts
|
|
10
960
|
var specification = (Suite, Given, When, Then) => {
|
|
11
961
|
return [
|
|
12
962
|
Suite.Default("Testing BaseBuilder functionality", {
|
|
13
|
-
testInitialization: Given
|
|
963
|
+
testInitialization: Given["the default BaseBuilder"](
|
|
14
964
|
["BaseBuilder should initialize correctly"],
|
|
15
965
|
[],
|
|
16
966
|
[
|
|
17
|
-
Then
|
|
18
|
-
Then
|
|
19
|
-
Then
|
|
20
|
-
Then
|
|
967
|
+
Then["it is initialized"](),
|
|
968
|
+
Then["it tracks artifacts"]()
|
|
969
|
+
// Then["it creates jobs"](),
|
|
970
|
+
// Then["it generates TestSpecifications"](),
|
|
21
971
|
]
|
|
22
972
|
),
|
|
23
|
-
testSpecsGeneration: Given
|
|
973
|
+
testSpecsGeneration: Given["the default BaseBuilder"](
|
|
24
974
|
["BaseBuilder should generate specs from test specification"],
|
|
25
975
|
[],
|
|
26
|
-
[Then
|
|
976
|
+
[Then["it generates TestSpecifications"]()]
|
|
27
977
|
),
|
|
28
|
-
testJobsCreation: Given
|
|
978
|
+
testJobsCreation: Given["the default BaseBuilder"](
|
|
29
979
|
["BaseBuilder should create test jobs"],
|
|
30
980
|
[],
|
|
31
|
-
[Then
|
|
981
|
+
[Then["it creates jobs"]()]
|
|
32
982
|
)
|
|
33
983
|
})
|
|
34
984
|
];
|
|
@@ -77,7 +1027,7 @@ var implementation = {
|
|
|
77
1027
|
Default: "BaseBuilder test suite"
|
|
78
1028
|
},
|
|
79
1029
|
givens: {
|
|
80
|
-
|
|
1030
|
+
"the default BaseBuilder": () => {
|
|
81
1031
|
return new MockBaseBuilder(
|
|
82
1032
|
{},
|
|
83
1033
|
// input
|
|
@@ -95,11 +1045,19 @@ var implementation = {
|
|
|
95
1045
|
// testSpecification
|
|
96
1046
|
);
|
|
97
1047
|
},
|
|
98
|
-
|
|
99
|
-
return new MockBaseBuilder(
|
|
1048
|
+
"a BaseBuilder with TestInput": (input) => {
|
|
1049
|
+
return new MockBaseBuilder(
|
|
1050
|
+
input,
|
|
1051
|
+
{},
|
|
1052
|
+
{},
|
|
1053
|
+
{},
|
|
1054
|
+
{},
|
|
1055
|
+
{ ports: [] },
|
|
1056
|
+
() => []
|
|
1057
|
+
);
|
|
100
1058
|
},
|
|
101
|
-
|
|
102
|
-
return new MockBaseBuilder({}, {}, {}, {}, {},
|
|
1059
|
+
"a BaseBuilder with Test Resource Requirements": (requirements) => {
|
|
1060
|
+
return new MockBaseBuilder({}, {}, {}, {}, {}, requirements, () => []);
|
|
103
1061
|
}
|
|
104
1062
|
},
|
|
105
1063
|
whens: {
|
|
@@ -113,7 +1071,8 @@ var implementation = {
|
|
|
113
1071
|
}
|
|
114
1072
|
},
|
|
115
1073
|
thens: {
|
|
116
|
-
|
|
1074
|
+
"it is initialized": () => (builder, utils) => {
|
|
1075
|
+
utils.writeFileSync("hello.txt", "world");
|
|
117
1076
|
if (!(builder instanceof BaseBuilder)) {
|
|
118
1077
|
console.error("Builder instance:", builder);
|
|
119
1078
|
throw new Error(
|
|
@@ -135,19 +1094,19 @@ var implementation = {
|
|
|
135
1094
|
});
|
|
136
1095
|
return builder;
|
|
137
1096
|
},
|
|
138
|
-
|
|
1097
|
+
"it generates TestSpecifications": () => (builder) => {
|
|
139
1098
|
if (!Array.isArray(builder.specs)) {
|
|
140
1099
|
throw new Error("Specs were not generated");
|
|
141
1100
|
}
|
|
142
1101
|
return builder;
|
|
143
1102
|
},
|
|
144
|
-
|
|
1103
|
+
"it creates jobs": () => (builder) => {
|
|
145
1104
|
if (!Array.isArray(builder.testJobs)) {
|
|
146
1105
|
throw new Error("Test jobs were not created");
|
|
147
1106
|
}
|
|
148
1107
|
return builder;
|
|
149
1108
|
},
|
|
150
|
-
|
|
1109
|
+
"it tracks artifacts": () => (builder) => {
|
|
151
1110
|
if (!Array.isArray(builder.artifacts)) {
|
|
152
1111
|
throw new Error("Artifacts array not initialized");
|
|
153
1112
|
}
|