testeranto 0.173.0 → 0.177.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/PM/base.js +5 -5
- package/dist/common/src/PM/main.js +48 -52
- package/dist/common/src/PM/node.js +4 -1
- package/dist/common/src/PM/pure.js +4 -1
- package/dist/common/src/PM/web.js +4 -1
- package/dist/common/src/Pure.js +0 -4
- package/dist/common/src/Pure.test.js +1 -1
- package/dist/common/src/ReportServerLib.js +11 -5
- package/dist/common/src/esbuildConfigs/node.js +1 -3
- package/dist/common/src/lib/BaseSuite.js +13 -11
- package/dist/common/src/lib/abstractBase.js +39 -42
- package/dist/common/src/lib/basebuilder.js +5 -0
- package/dist/common/src/lib/core.js +1 -0
- package/dist/common/src/lib/pmProxy.js +210 -100
- package/dist/common/src/lib/pmProxy.test/adapter.js +2 -2
- package/dist/common/src/lib/pmProxy.test/implementation.js +1 -1
- package/dist/common/testeranto.config.js +39 -39
- package/dist/common/tsconfig.common.tsbuildinfo +1 -1
- package/dist/module/src/PM/base.js +5 -5
- package/dist/module/src/PM/main.js +13 -17
- package/dist/module/src/PM/node.js +4 -1
- package/dist/module/src/PM/pure.js +4 -1
- package/dist/module/src/PM/web.js +4 -1
- package/dist/module/src/Pure.js +0 -4
- package/dist/module/src/Pure.test.js +1 -1
- package/dist/module/src/ReportServerLib.js +11 -5
- package/dist/module/src/esbuildConfigs/node.js +1 -3
- package/dist/module/src/lib/BaseSuite.js +13 -11
- package/dist/module/src/lib/abstractBase.js +39 -42
- package/dist/module/src/lib/basebuilder.js +5 -0
- package/dist/module/src/lib/core.js +1 -0
- package/dist/module/src/lib/pmProxy.js +210 -100
- package/dist/module/src/lib/pmProxy.test/adapter.js +2 -2
- package/dist/module/src/lib/pmProxy.test/implementation.js +1 -1
- package/dist/module/testeranto.config.js +39 -39
- package/dist/module/tsconfig.module.tsbuildinfo +1 -1
- package/dist/prebuild/ReportServer.mjs +10 -4
- package/dist/prebuild/build.mjs +1 -1
- package/dist/prebuild/run.mjs +19 -22
- package/dist/types/src/PM/base.d.ts +1 -1
- package/dist/types/src/PM/node.d.ts +1 -1
- package/dist/types/src/PM/pure.d.ts +1 -1
- package/dist/types/src/PM/web.d.ts +1 -1
- package/dist/types/src/ReportServerLib.d.ts +1 -2
- package/dist/types/src/lib/BaseSuite.d.ts +2 -0
- package/dist/types/src/lib/abstractBase.d.ts +4 -6
- package/dist/types/src/lib/pmProxy.d.ts +3 -3
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/PM/base.ts +6 -9
- package/src/PM/main.ts +17 -20
- package/src/PM/node.ts +6 -1
- package/src/PM/pure.ts +6 -1
- package/src/PM/web.ts +5 -1
- package/src/Pure.test.ts +6 -6
- package/src/Pure.ts +0 -8
- package/src/ReportServerLib.ts +10 -7
- package/src/esbuildConfigs/node.ts +1 -1
- package/src/lib/BaseSuite.ts +16 -21
- package/src/lib/abstractBase.ts +57 -49
- package/src/lib/basebuilder.ts +6 -0
- package/src/lib/core.ts +1 -0
- package/src/lib/pmProxy.test/adapter.ts +2 -2
- package/src/lib/pmProxy.test/implementation.ts +3 -3
- package/src/lib/pmProxy.test/types.ts +0 -2
- package/src/lib/pmProxy.ts +224 -92
- package/testeranto/bundles/node/core/metafile.json +2 -480
- package/testeranto/bundles/pure/core/metafile.json +3 -621
- package/testeranto/bundles/web/core/metafile.json +14384 -78
- package/testeranto/bundles/web/core/src/{lib/baseBuilder.test/baseBuilder.test.web.html → components/pure/ProjectPageView.test/index.html} +2 -2
- package/testeranto/bundles/web/core/src/components/pure/ProjectPageView.test/index.mjs +39991 -0
- package/testeranto/projects.json +0 -1
- package/testeranto/reports/core/config.json +5 -5
- package/testeranto/reports/core/src/components/pure/ProjectPageView.test/index/web/lint_errors.txt +18 -0
- package/testeranto/reports/core/src/components/pure/ProjectPageView.test/index/web/logs.txt +59 -0
- package/testeranto/reports/core/src/components/pure/ProjectPageView.test/index/web/message.txt +2 -0
- package/testeranto/reports/core/src/components/pure/ProjectPageView.test/index/web/prompt.txt +27 -0
- package/testeranto/reports/core/src/components/pure/ProjectPageView.test/index/web/suite-0/given-basicRender/then-0/butThen/happyPath.png +0 -0
- package/testeranto/reports/{staticSite/src/ReportServer.test.ts/index/node → core/src/components/pure/ProjectPageView.test/index/web}/type_errors.txt +20 -22
- package/testeranto/reports/core/summary.json +5 -19
- package/testeranto.config.ts +39 -39
- package/tsc.log +78 -92
- package/testeranto/bundles/node/allTests/metafile.json +0 -486
- package/testeranto/bundles/node/allTests/src/lib/baseBuilder.test/baseBuilder.test.node.mjs +0 -1182
- package/testeranto/bundles/node/core/src/lib/baseBuilder.test/baseBuilder.test.node.mjs +0 -1182
- package/testeranto/bundles/node/staticSite/metafile.json +0 -593
- package/testeranto/bundles/node/staticSite/src/ReportServer.test.ts/index.mjs +0 -1594
- package/testeranto/bundles/pure/allTests/metafile.json +0 -626
- package/testeranto/bundles/pure/allTests/src/lib/baseBuilder.test/baseBuilder.test.pure.mjs +0 -1094
- package/testeranto/bundles/pure/core/src/lib/baseBuilder.test/baseBuilder.test.pure.mjs +0 -1094
- package/testeranto/bundles/pure/staticSite/metafile.json +0 -8
- package/testeranto/bundles/web/allTests/metafile.json +0 -780
- package/testeranto/bundles/web/allTests/src/lib/baseBuilder.test/baseBuilder.test.web.html +0 -19
- package/testeranto/bundles/web/allTests/src/lib/baseBuilder.test/baseBuilder.test.web.mjs +0 -1092
- package/testeranto/bundles/web/core/src/lib/baseBuilder.test/baseBuilder.test.web.mjs +0 -1092
- package/testeranto/bundles/web/staticSite/metafile.json +0 -8
- package/testeranto/reports/allTests/config.json +0 -40
- package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.node/node/bdd_errors.txt +0 -1
- package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.node/node/lint_errors.txt +0 -2
- package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.node/node/logs.txt +0 -33
- package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.node/node/message.txt +0 -2
- package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.node/node/prompt.txt +0 -26
- package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.node/node/suite-0/given-testInitialization/then-0/butThen/hello.txt +0 -1
- package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.node/node/tests.json +0 -69
- package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.node/node/type_errors.txt +0 -74
- package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.pure/pure/lint_errors.txt +0 -2
- package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.pure/pure/message.txt +0 -2
- package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.pure/pure/prompt.txt +0 -26
- package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.pure/pure/type_errors.txt +0 -74
- package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.web/web/bdd_errors.txt +0 -1
- package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.web/web/lint_errors.txt +0 -2
- package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.web/web/logs.txt +0 -63
- package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.web/web/message.txt +0 -2
- package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.web/web/prompt.txt +0 -26
- package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.web/web/suite-0/given-testInitialization/then-0/butThen/hello.txt +0 -1
- package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.web/web/tests.json +0 -69
- package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.web/web/type_errors.txt +0 -74
- package/testeranto/reports/allTests/summary.json +0 -23
- package/testeranto/reports/core/src/lib/baseBuilder.test/baseBuilder.test.node/node/bdd_errors.txt +0 -1
- package/testeranto/reports/core/src/lib/baseBuilder.test/baseBuilder.test.node/node/lint_errors.txt +0 -2
- package/testeranto/reports/core/src/lib/baseBuilder.test/baseBuilder.test.node/node/logs.txt +0 -32
- package/testeranto/reports/core/src/lib/baseBuilder.test/baseBuilder.test.node/node/message.txt +0 -2
- package/testeranto/reports/core/src/lib/baseBuilder.test/baseBuilder.test.node/node/prompt.txt +0 -26
- package/testeranto/reports/core/src/lib/baseBuilder.test/baseBuilder.test.node/node/suite-0/given-testInitialization/then-0/butThen/hello.txt +0 -1
- package/testeranto/reports/core/src/lib/baseBuilder.test/baseBuilder.test.node/node/tests.json +0 -69
- package/testeranto/reports/core/src/lib/baseBuilder.test/baseBuilder.test.node/node/type_errors.txt +0 -74
- package/testeranto/reports/core/src/lib/baseBuilder.test/baseBuilder.test.pure/pure/lint_errors.txt +0 -2
- package/testeranto/reports/core/src/lib/baseBuilder.test/baseBuilder.test.pure/pure/message.txt +0 -2
- package/testeranto/reports/core/src/lib/baseBuilder.test/baseBuilder.test.pure/pure/prompt.txt +0 -26
- package/testeranto/reports/core/src/lib/baseBuilder.test/baseBuilder.test.pure/pure/type_errors.txt +0 -74
- package/testeranto/reports/core/src/lib/baseBuilder.test/baseBuilder.test.web/web/bdd_errors.txt +0 -1
- package/testeranto/reports/core/src/lib/baseBuilder.test/baseBuilder.test.web/web/lint_errors.txt +0 -2
- package/testeranto/reports/core/src/lib/baseBuilder.test/baseBuilder.test.web/web/logs.txt +0 -61
- package/testeranto/reports/core/src/lib/baseBuilder.test/baseBuilder.test.web/web/message.txt +0 -2
- package/testeranto/reports/core/src/lib/baseBuilder.test/baseBuilder.test.web/web/prompt.txt +0 -26
- package/testeranto/reports/core/src/lib/baseBuilder.test/baseBuilder.test.web/web/suite-0/given-testInitialization/then-0/butThen/hello.txt +0 -1
- package/testeranto/reports/core/src/lib/baseBuilder.test/baseBuilder.test.web/web/tests.json +0 -69
- package/testeranto/reports/core/src/lib/baseBuilder.test/baseBuilder.test.web/web/type_errors.txt +0 -74
- package/testeranto/reports/staticSite/config.json +0 -24
- package/testeranto/reports/staticSite/src/ReportServer.test.ts/index/node/lint_errors.txt +0 -5
- package/testeranto/reports/staticSite/src/ReportServer.test.ts/index/node/logs.txt +0 -44
- package/testeranto/reports/staticSite/src/ReportServer.test.ts/index/node/message.txt +0 -2
- package/testeranto/reports/staticSite/src/ReportServer.test.ts/index/node/prompt.txt +0 -23
- package/testeranto/reports/staticSite/summary.json +0 -9
- package/testeranto/reportsnode_build_errors +0 -17
|
@@ -1,1182 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module';const require = createRequire(import.meta.url);
|
|
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;
|
|
958
|
-
|
|
959
|
-
// src/lib/baseBuilder.test/baseBuilder.test.specification.ts
|
|
960
|
-
var specification = (Suite, Given, When, Then) => {
|
|
961
|
-
return [
|
|
962
|
-
Suite.Default("Testing BaseBuilder functionality", {
|
|
963
|
-
testInitialization: Given["the default BaseBuilder"](
|
|
964
|
-
["BaseBuilder should initialize correctly"],
|
|
965
|
-
[],
|
|
966
|
-
[
|
|
967
|
-
Then["it is initialized"](),
|
|
968
|
-
Then["it tracks artifacts"]()
|
|
969
|
-
// Then["it creates jobs"](),
|
|
970
|
-
// Then["it generates TestSpecifications"](),
|
|
971
|
-
]
|
|
972
|
-
),
|
|
973
|
-
testSpecsGeneration: Given["the default BaseBuilder"](
|
|
974
|
-
["BaseBuilder should generate specs from test specification"],
|
|
975
|
-
[],
|
|
976
|
-
[Then["it generates TestSpecifications"]()]
|
|
977
|
-
),
|
|
978
|
-
testJobsCreation: Given["the default BaseBuilder"](
|
|
979
|
-
["BaseBuilder should create test jobs"],
|
|
980
|
-
[],
|
|
981
|
-
[Then["it creates jobs"]()]
|
|
982
|
-
)
|
|
983
|
-
})
|
|
984
|
-
];
|
|
985
|
-
};
|
|
986
|
-
|
|
987
|
-
// src/lib/baseBuilder.test/baseBuilder.test.mock.ts
|
|
988
|
-
var MockBaseBuilder = class extends BaseBuilder {
|
|
989
|
-
constructor(input, suitesOverrides = {}, givenOverrides = {}, whenOverrides = {}, thenOverrides = {}, testResourceRequirement = { ports: 0 }, testSpecification = () => []) {
|
|
990
|
-
super(
|
|
991
|
-
input,
|
|
992
|
-
suitesOverrides,
|
|
993
|
-
givenOverrides,
|
|
994
|
-
whenOverrides,
|
|
995
|
-
thenOverrides,
|
|
996
|
-
testResourceRequirement,
|
|
997
|
-
testSpecification
|
|
998
|
-
);
|
|
999
|
-
this.summary = {};
|
|
1000
|
-
}
|
|
1001
|
-
/**
|
|
1002
|
-
* Simplified version for testing that doesn't actually run tests
|
|
1003
|
-
*/
|
|
1004
|
-
testRun(puppetMaster) {
|
|
1005
|
-
this.summary = {
|
|
1006
|
-
[puppetMaster.testResourceConfiguration.name]: {
|
|
1007
|
-
typeErrors: 0,
|
|
1008
|
-
staticErrors: 0,
|
|
1009
|
-
runTimeError: "",
|
|
1010
|
-
prompt: "",
|
|
1011
|
-
failingFeatures: {}
|
|
1012
|
-
}
|
|
1013
|
-
};
|
|
1014
|
-
return Promise.resolve({
|
|
1015
|
-
failed: false,
|
|
1016
|
-
fails: 0,
|
|
1017
|
-
artifacts: [],
|
|
1018
|
-
// logPromise: Promise.resolve(),
|
|
1019
|
-
features: []
|
|
1020
|
-
});
|
|
1021
|
-
}
|
|
1022
|
-
};
|
|
1023
|
-
|
|
1024
|
-
// src/lib/baseBuilder.test/baseBuilder.test.implementation.ts
|
|
1025
|
-
var implementation = {
|
|
1026
|
-
suites: {
|
|
1027
|
-
Default: "BaseBuilder test suite"
|
|
1028
|
-
},
|
|
1029
|
-
givens: {
|
|
1030
|
-
"the default BaseBuilder": () => {
|
|
1031
|
-
return new MockBaseBuilder(
|
|
1032
|
-
{},
|
|
1033
|
-
// input
|
|
1034
|
-
{},
|
|
1035
|
-
// suitesOverrides
|
|
1036
|
-
{},
|
|
1037
|
-
// givenOverrides
|
|
1038
|
-
{},
|
|
1039
|
-
// whenOverrides
|
|
1040
|
-
{},
|
|
1041
|
-
// thenOverrides
|
|
1042
|
-
{ ports: 0 },
|
|
1043
|
-
// testResourceRequirement
|
|
1044
|
-
() => []
|
|
1045
|
-
// testSpecification
|
|
1046
|
-
);
|
|
1047
|
-
},
|
|
1048
|
-
"a BaseBuilder with TestInput": (input) => {
|
|
1049
|
-
return new MockBaseBuilder(
|
|
1050
|
-
input,
|
|
1051
|
-
{},
|
|
1052
|
-
{},
|
|
1053
|
-
{},
|
|
1054
|
-
{},
|
|
1055
|
-
{ ports: [] },
|
|
1056
|
-
() => []
|
|
1057
|
-
);
|
|
1058
|
-
},
|
|
1059
|
-
"a BaseBuilder with Test Resource Requirements": (requirements) => {
|
|
1060
|
-
return new MockBaseBuilder({}, {}, {}, {}, {}, requirements, () => []);
|
|
1061
|
-
}
|
|
1062
|
-
},
|
|
1063
|
-
whens: {
|
|
1064
|
-
addArtifact: (artifact) => (builder) => {
|
|
1065
|
-
builder.artifacts.push(artifact);
|
|
1066
|
-
return builder;
|
|
1067
|
-
},
|
|
1068
|
-
setTestJobs: (jobs) => (builder) => {
|
|
1069
|
-
builder.testJobs = jobs;
|
|
1070
|
-
return builder;
|
|
1071
|
-
}
|
|
1072
|
-
},
|
|
1073
|
-
thens: {
|
|
1074
|
-
"it is initialized": () => (builder, utils) => {
|
|
1075
|
-
utils.writeFileSync("hello.txt", "world");
|
|
1076
|
-
if (!(builder instanceof BaseBuilder)) {
|
|
1077
|
-
console.error("Builder instance:", builder);
|
|
1078
|
-
throw new Error(
|
|
1079
|
-
`Builder was not properly initialized - expected BaseBuilder instance but got ${builder?.constructor?.name}`
|
|
1080
|
-
);
|
|
1081
|
-
}
|
|
1082
|
-
[
|
|
1083
|
-
"artifacts",
|
|
1084
|
-
"testJobs",
|
|
1085
|
-
"specs",
|
|
1086
|
-
"suitesOverrides",
|
|
1087
|
-
"givenOverides",
|
|
1088
|
-
"whenOverides",
|
|
1089
|
-
"thenOverides"
|
|
1090
|
-
].forEach((prop) => {
|
|
1091
|
-
if (!(prop in builder)) {
|
|
1092
|
-
throw new Error(`Builder missing required property: ${prop}`);
|
|
1093
|
-
}
|
|
1094
|
-
});
|
|
1095
|
-
return builder;
|
|
1096
|
-
},
|
|
1097
|
-
"it generates TestSpecifications": () => (builder) => {
|
|
1098
|
-
if (!Array.isArray(builder.specs)) {
|
|
1099
|
-
throw new Error("Specs were not generated");
|
|
1100
|
-
}
|
|
1101
|
-
return builder;
|
|
1102
|
-
},
|
|
1103
|
-
"it creates jobs": () => (builder) => {
|
|
1104
|
-
if (!Array.isArray(builder.testJobs)) {
|
|
1105
|
-
throw new Error("Test jobs were not created");
|
|
1106
|
-
}
|
|
1107
|
-
return builder;
|
|
1108
|
-
},
|
|
1109
|
-
"it tracks artifacts": () => (builder) => {
|
|
1110
|
-
if (!Array.isArray(builder.artifacts)) {
|
|
1111
|
-
throw new Error("Artifacts array not initialized");
|
|
1112
|
-
}
|
|
1113
|
-
return builder;
|
|
1114
|
-
},
|
|
1115
|
-
resourceRequirementsSet: () => (builder) => {
|
|
1116
|
-
if (!builder.testResourceRequirement) {
|
|
1117
|
-
throw new Error("Resource requirements not set");
|
|
1118
|
-
}
|
|
1119
|
-
return builder;
|
|
1120
|
-
},
|
|
1121
|
-
suitesOverridesConfigured: () => (builder) => {
|
|
1122
|
-
if (!builder.suitesOverrides) {
|
|
1123
|
-
throw new Error("Suites overrides not configured");
|
|
1124
|
-
}
|
|
1125
|
-
return builder;
|
|
1126
|
-
},
|
|
1127
|
-
givensOverridesConfigured: () => (builder) => {
|
|
1128
|
-
if (!builder.givenOverides) {
|
|
1129
|
-
throw new Error("Givens overrides not configured");
|
|
1130
|
-
}
|
|
1131
|
-
return builder;
|
|
1132
|
-
},
|
|
1133
|
-
whensOverridesConfigured: () => (builder) => {
|
|
1134
|
-
if (!builder.whenOverides) {
|
|
1135
|
-
throw new Error("Whens overrides not configured");
|
|
1136
|
-
}
|
|
1137
|
-
return builder;
|
|
1138
|
-
},
|
|
1139
|
-
thensOverridesConfigured: () => (builder) => {
|
|
1140
|
-
if (!builder.thenOverides) {
|
|
1141
|
-
throw new Error("Thens overrides not configured");
|
|
1142
|
-
}
|
|
1143
|
-
return builder;
|
|
1144
|
-
}
|
|
1145
|
-
}
|
|
1146
|
-
};
|
|
1147
|
-
|
|
1148
|
-
// src/lib/baseBuilder.test/baseBuilder.test.adapter.ts
|
|
1149
|
-
var testAdapter = {
|
|
1150
|
-
beforeAll: async (input, testResource, pm) => input,
|
|
1151
|
-
beforeEach: async (subject, initializer, testResource, initialValues, pm) => {
|
|
1152
|
-
console.log("Initializing test with:", {
|
|
1153
|
-
subject,
|
|
1154
|
-
initializer,
|
|
1155
|
-
initialValues
|
|
1156
|
-
});
|
|
1157
|
-
const result = initializer();
|
|
1158
|
-
console.log("Initialization result:", result.toString());
|
|
1159
|
-
return result;
|
|
1160
|
-
},
|
|
1161
|
-
andWhen: async (store, whenCB, testResource, utils) => {
|
|
1162
|
-
return whenCB(store, utils);
|
|
1163
|
-
},
|
|
1164
|
-
butThen: async (store, thenCB, testResource, pm) => {
|
|
1165
|
-
return thenCB(store, pm);
|
|
1166
|
-
},
|
|
1167
|
-
afterEach: (store) => store,
|
|
1168
|
-
afterAll: () => {
|
|
1169
|
-
},
|
|
1170
|
-
assertThis: (x) => x
|
|
1171
|
-
};
|
|
1172
|
-
|
|
1173
|
-
// src/lib/baseBuilder.test/baseBuilder.test.node.ts
|
|
1174
|
-
var baseBuilder_test_node_default = Node_default(
|
|
1175
|
-
MockBaseBuilder.prototype,
|
|
1176
|
-
specification,
|
|
1177
|
-
implementation,
|
|
1178
|
-
testAdapter
|
|
1179
|
-
);
|
|
1180
|
-
export {
|
|
1181
|
-
baseBuilder_test_node_default as default
|
|
1182
|
-
};
|