testeranto 0.70.0 → 0.73.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 +9 -18
- package/dist/common/Node.js +14 -34
- package/dist/common/PM/index.js +71 -0
- package/dist/common/PM/main.js +361 -0
- package/dist/common/PM/node.js +176 -0
- package/dist/common/PM/web.js +174 -0
- package/dist/common/Project.js +20 -2
- package/dist/common/Puppeteer.js +109 -0
- package/dist/common/Reporter.js +119 -0
- package/dist/common/Scheduler.js +1 -0
- package/dist/common/SubPackages/puppeteer.js +3 -1
- package/dist/common/SubPackages/react-dom/component/web.js +98 -45
- package/dist/common/SubPackages/react-test-renderer/jsx/index.js +0 -1
- package/dist/common/Web.js +24 -43
- package/dist/common/esbuildConfigs/web.js +3 -1
- package/dist/common/lib/abstractBase.js +189 -41
- package/dist/common/lib/basebuilder.js +56 -29
- package/dist/common/lib/classBuilder.js +6 -2
- package/dist/common/lib/core.js +41 -45
- package/dist/common/lib/index.js +2 -1
- package/dist/common/preload.js +14 -18
- package/dist/common/tsconfig.common.tsbuildinfo +1 -1
- package/dist/module/Node.js +14 -34
- package/dist/module/PM/index.js +67 -0
- package/dist/module/PM/main.js +331 -0
- package/dist/module/PM/node.js +168 -0
- package/dist/module/PM/web.js +167 -0
- package/dist/module/Project.js +20 -2
- package/dist/module/Puppeteer.js +104 -0
- package/dist/module/Reporter.js +114 -0
- package/dist/module/Scheduler.js +1 -0
- package/dist/module/SubPackages/puppeteer.js +3 -1
- package/dist/module/SubPackages/react/jsx/node.js +1 -1
- package/dist/module/SubPackages/react-dom/component/web.js +98 -45
- package/dist/module/SubPackages/react-test-renderer/jsx/index.js +0 -1
- package/dist/module/Web.js +24 -43
- package/dist/module/esbuildConfigs/web.js +3 -1
- package/dist/module/lib/abstractBase.js +189 -41
- package/dist/module/lib/basebuilder.js +56 -29
- package/dist/module/lib/classBuilder.js +6 -2
- package/dist/module/lib/core.js +41 -45
- package/dist/module/lib/index.js +2 -1
- package/dist/module/preload.js +15 -14
- package/dist/module/tsconfig.module.tsbuildinfo +1 -1
- package/dist/prebuild/Report.css +1616 -584
- package/dist/prebuild/Report.js +2635 -2506
- package/dist/types/PM/index.d.ts +19 -0
- package/dist/types/PM/main.d.ts +28 -0
- package/dist/types/PM/node.d.ts +26 -0
- package/dist/types/PM/web.d.ts +24 -0
- package/dist/types/Reporter.d.ts +1 -0
- package/dist/types/Scheduler.d.ts +0 -0
- package/dist/types/SubPackages/react-dom/component/web.d.ts +1 -1
- package/dist/types/lib/abstractBase.d.ts +13 -12
- package/dist/types/lib/basebuilder.d.ts +4 -2
- package/dist/types/lib/classBuilder.d.ts +2 -2
- package/dist/types/lib/core.d.ts +4 -4
- package/dist/types/lib/index.d.ts +6 -5
- package/dist/types/lib/types.d.ts +16 -24
- package/dist/types/preload.d.ts +0 -1
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/package.json +3 -5
- package/src/Node.ts +18 -43
- package/src/PM/index.ts +102 -0
- package/src/PM/main.ts +420 -0
- package/src/PM/node.ts +515 -0
- package/src/PM/web.ts +497 -0
- package/src/Project.ts +21 -2
- package/src/Puppeteer.ts +131 -0
- package/src/Report.tsx +158 -44
- package/src/Reporter.ts +134 -0
- package/src/Scheduler.ts +0 -0
- package/src/SubPackages/puppeteer.ts +3 -3
- package/src/SubPackages/react/jsx/node.ts +5 -8
- package/src/SubPackages/react-dom/component/web.ts +126 -67
- package/src/SubPackages/react-test-renderer/jsx/index.ts +0 -1
- package/src/Web.ts +25 -67
- package/src/esbuildConfigs/web.ts +4 -2
- package/src/lib/abstractBase.ts +260 -65
- package/src/lib/basebuilder.ts +121 -100
- package/src/lib/classBuilder.ts +5 -4
- package/src/lib/core.ts +58 -59
- package/src/lib/index.ts +10 -9
- package/src/lib/types.ts +18 -27
- package/src/preload.ts +14 -14
- package/dist/common/NodeWriter.js +0 -54
- package/dist/common/electron.js +0 -266
- package/dist/module/NodeWriter.js +0 -48
- package/dist/module/electron.js +0 -261
- package/dist/types/NodeWriter.d.ts +0 -2
- package/src/NodeWriter.ts +0 -72
- package/src/electron.ts +0 -317
- package/yarn-error.log +0 -3144
- /package/dist/types/{electron.d.ts → Puppeteer.d.ts} +0 -0
package/dist/module/Web.js
CHANGED
|
@@ -1,52 +1,33 @@
|
|
|
1
|
+
import { PM_Web } from "./PM/web";
|
|
1
2
|
import Testeranto from "./lib/core.js";
|
|
2
3
|
import { defaultTestResourceRequirement, } from "./lib/index.js";
|
|
3
|
-
// const remote = require("@electron/remote");
|
|
4
|
-
// import remote from "@electron/remote";
|
|
5
|
-
// const electron = require("electron");
|
|
6
|
-
// const remote =
|
|
7
|
-
// process.type === "browser" ? electron : require("@electron/remote");
|
|
8
4
|
class WebTesteranto extends Testeranto {
|
|
9
5
|
constructor(input, testSpecification, testImplementation, testResourceRequirement, testInterface) {
|
|
10
|
-
super(input, testSpecification, testImplementation, testResourceRequirement,
|
|
11
|
-
const testResourceArg = decodeURIComponent(new URLSearchParams(location.search).get("requesting") || "");
|
|
12
|
-
try {
|
|
13
|
-
const partialTestResource = JSON.parse(testResourceArg);
|
|
14
|
-
this.receiveTestResourceConfig(this.testJobs[0], partialTestResource);
|
|
15
|
-
}
|
|
16
|
-
catch (e) {
|
|
17
|
-
console.error(e);
|
|
18
|
-
// process.exit(-1);
|
|
19
|
-
}
|
|
20
|
-
const requesting = new URLSearchParams(location.search).get("requesting");
|
|
21
|
-
if (requesting) {
|
|
22
|
-
const testResourceArg = decodeURIComponent(requesting);
|
|
23
|
-
try {
|
|
24
|
-
const partialTestResource = JSON.parse(testResourceArg);
|
|
25
|
-
console.log("initial test resource", partialTestResource);
|
|
26
|
-
this.receiveTestResourceConfig(this.testJobs[0], partialTestResource);
|
|
27
|
-
}
|
|
28
|
-
catch (e) {
|
|
29
|
-
console.error(e);
|
|
30
|
-
// process.exit(-1);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
6
|
+
super(input, testSpecification, testImplementation, testResourceRequirement, testInterface);
|
|
33
7
|
}
|
|
34
|
-
async receiveTestResourceConfig(
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
});
|
|
8
|
+
async receiveTestResourceConfig(partialTestResource) {
|
|
9
|
+
const t = partialTestResource; //JSON.parse(partialTestResource);
|
|
10
|
+
const pm = new PM_Web(t);
|
|
11
|
+
const { failed, artifacts, logPromise } = await this.testJobs[0].receiveTestResourceConfig(pm);
|
|
39
12
|
console.log("test is done, awaiting test result write to fs");
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
13
|
+
pm.customclose();
|
|
14
|
+
// Promise.all([...artifacts, logPromise]).then(async () => {
|
|
15
|
+
// console.log("hello world");
|
|
16
|
+
// pm.customclose();
|
|
17
|
+
// // we can't close the window becuase we might be taking a screenshot
|
|
18
|
+
// // window.close();
|
|
19
|
+
// // console.log(
|
|
20
|
+
// // "(window as any).browser",
|
|
21
|
+
// // JSON.stringify(await (window as any).browser)
|
|
22
|
+
// // );
|
|
23
|
+
// // var currentWindow = (await (window as any).browser).getCurrentWindow();
|
|
24
|
+
// // window.close();
|
|
25
|
+
// // var customWindow = window.open("", "_blank", "");
|
|
26
|
+
// // customWindow.close();
|
|
27
|
+
// // this.puppetMaster.browser.page
|
|
28
|
+
// // window["customclose"]();
|
|
29
|
+
// // console.log("goodbye", window["customclose"]());
|
|
30
|
+
// });
|
|
50
31
|
}
|
|
51
32
|
}
|
|
52
33
|
export default async (input, testSpecification, testImplementation, testInterface, testResourceRequirement = defaultTestResourceRequirement) => {
|
|
@@ -14,7 +14,6 @@ export default (config, entryPoints) => {
|
|
|
14
14
|
"features.test.ts",
|
|
15
15
|
// "url",
|
|
16
16
|
"react",
|
|
17
|
-
"electron",
|
|
18
17
|
"path",
|
|
19
18
|
"fs",
|
|
20
19
|
"stream",
|
|
@@ -29,6 +28,9 @@ export default (config, entryPoints) => {
|
|
|
29
28
|
"zlib",
|
|
30
29
|
"crypto",
|
|
31
30
|
"https",
|
|
31
|
+
"util",
|
|
32
|
+
"process",
|
|
33
|
+
"dns",
|
|
32
34
|
], platform: "browser", entryPoints: [...entryPoints], plugins: [
|
|
33
35
|
...(config.webPlugins || []),
|
|
34
36
|
{
|
|
@@ -13,45 +13,114 @@ export class BaseSuite {
|
|
|
13
13
|
fails: this.fails,
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
|
-
setup(s, artifactory, tr,
|
|
16
|
+
setup(s, artifactory, tr, pm) {
|
|
17
17
|
return new Promise((res) => res(s));
|
|
18
18
|
}
|
|
19
19
|
assertThat(t) {
|
|
20
|
-
// console.log("base assertThat")
|
|
21
20
|
return t;
|
|
22
21
|
}
|
|
23
|
-
|
|
22
|
+
afterAll(store, artifactory, pm) {
|
|
23
|
+
return store;
|
|
24
|
+
}
|
|
25
|
+
async run(input, testResourceConfiguration, artifactory, tLog, pm) {
|
|
24
26
|
this.testResourceConfiguration = testResourceConfiguration;
|
|
25
|
-
tLog("test resources: ", testResourceConfiguration);
|
|
27
|
+
tLog("test resources: ", JSON.stringify(testResourceConfiguration));
|
|
26
28
|
const suiteArtifactory = (fPath, value) => artifactory(`suite-${this.index}-${this.name}/${fPath}`, value);
|
|
27
|
-
|
|
29
|
+
console.log("\nSuite:", this.index, this.name);
|
|
28
30
|
tLog("\nSuite:", this.index, this.name);
|
|
29
|
-
|
|
30
|
-
|
|
31
|
+
const sNdx = this.index;
|
|
32
|
+
const sName = this.name;
|
|
33
|
+
for (const [gNdx, g] of Object.entries(this.givens)) {
|
|
34
|
+
const subject = await this.setup(input, suiteArtifactory, testResourceConfiguration, pm);
|
|
35
|
+
const giver = this.givens[gNdx];
|
|
31
36
|
try {
|
|
32
|
-
this.store = await giver.give(subject,
|
|
37
|
+
this.store = await giver.give(subject, gNdx, testResourceConfiguration, this.assertThat, suiteArtifactory, tLog, pm, sNdx);
|
|
33
38
|
}
|
|
34
39
|
catch (e) {
|
|
35
40
|
console.error(e);
|
|
36
41
|
this.fails.push(giver);
|
|
37
|
-
return this;
|
|
42
|
+
// return this;
|
|
38
43
|
}
|
|
39
44
|
}
|
|
40
|
-
|
|
41
|
-
|
|
45
|
+
const afterAllProxy = new Proxy(pm, {
|
|
46
|
+
get(target, prop, receiver) {
|
|
47
|
+
if (prop === "writeFileSync") {
|
|
48
|
+
return (fp, contents) => target[prop](`suite-${sNdx}/afterAll/${fp}`, contents);
|
|
49
|
+
}
|
|
50
|
+
if (prop === "browser") {
|
|
51
|
+
return new Proxy(target[prop], {
|
|
52
|
+
get(bTarget, bProp, bReceiver) {
|
|
53
|
+
if (bProp === "pages") {
|
|
54
|
+
return async () => {
|
|
55
|
+
return bTarget.pages().then((pages) => {
|
|
56
|
+
return pages.map((page) => {
|
|
57
|
+
return new Proxy(page, {
|
|
58
|
+
get(pTarget, pProp, pReciever) {
|
|
59
|
+
if (pProp === "screenshot") {
|
|
60
|
+
return async (x) => {
|
|
61
|
+
// console.log(
|
|
62
|
+
// "custom-screenshot-MARK-afterAllProxy",
|
|
63
|
+
// // arguments,
|
|
64
|
+
// // x,
|
|
65
|
+
// window["custom-screenshot"].toString()
|
|
66
|
+
// );
|
|
67
|
+
return await window["custom-screenshot"](Object.assign(Object.assign({}, x), { path: `${testResourceConfiguration.fs}/suite-${sNdx}/afterAll` +
|
|
68
|
+
"/" +
|
|
69
|
+
x.path }));
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
// else if (pProp === "mainFrame") {
|
|
73
|
+
// return () => target[pProp](...arguments);
|
|
74
|
+
// }
|
|
75
|
+
else {
|
|
76
|
+
return Reflect.get(...arguments);
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
// return (await target.pages()).map((page) => {
|
|
83
|
+
// return new Proxy(page, handler2);
|
|
84
|
+
// });
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
return Reflect.get(...arguments);
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
// pm.browser
|
|
94
|
+
try {
|
|
95
|
+
this.afterAll(this.store, artifactory, afterAllProxy);
|
|
42
96
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
giver.afterAll(this.store, artifactory, utils);
|
|
48
|
-
}
|
|
49
|
-
catch (e) {
|
|
50
|
-
console.error(e);
|
|
51
|
-
this.fails.push(giver);
|
|
52
|
-
return this;
|
|
53
|
-
}
|
|
97
|
+
catch (e) {
|
|
98
|
+
console.error(e);
|
|
99
|
+
// this.fails.push(this);
|
|
100
|
+
// return this;
|
|
54
101
|
}
|
|
102
|
+
// for (const [ndx, thater] of this.checks.entries()) {
|
|
103
|
+
// await thater.check(
|
|
104
|
+
// subject,
|
|
105
|
+
// thater.name,
|
|
106
|
+
// testResourceConfiguration,
|
|
107
|
+
// this.assertThat,
|
|
108
|
+
// suiteArtifactory,
|
|
109
|
+
// tLog,
|
|
110
|
+
// pm
|
|
111
|
+
// );
|
|
112
|
+
// }
|
|
113
|
+
// @TODO fix me
|
|
114
|
+
// for (const k of Object.keys(this.givens)) {
|
|
115
|
+
// const giver = this.givens[k];
|
|
116
|
+
// try {
|
|
117
|
+
// giver.afterAll(this.store, artifactory, pm);
|
|
118
|
+
// } catch (e) {
|
|
119
|
+
// console.error(e);
|
|
120
|
+
// this.fails.push(giver);
|
|
121
|
+
// return this;
|
|
122
|
+
// }
|
|
123
|
+
// }
|
|
55
124
|
////////////////
|
|
56
125
|
return this;
|
|
57
126
|
}
|
|
@@ -68,32 +137,39 @@ export class BaseGiven {
|
|
|
68
137
|
beforeAll(store, artifactory) {
|
|
69
138
|
return store;
|
|
70
139
|
}
|
|
71
|
-
afterAll(store, artifactory, utils) {
|
|
72
|
-
return store;
|
|
73
|
-
}
|
|
74
140
|
toObj() {
|
|
75
141
|
return {
|
|
76
142
|
name: this.name,
|
|
77
143
|
whens: this.whens.map((w) => w.toObj()),
|
|
78
144
|
thens: this.thens.map((t) => t.toObj()),
|
|
79
145
|
error: this.error ? [this.error, this.error.stack] : null,
|
|
146
|
+
// fail: this.fail ? [this.fail] : false,
|
|
80
147
|
features: this.features,
|
|
81
148
|
};
|
|
82
149
|
}
|
|
83
|
-
async afterEach(store, key, artifactory,
|
|
150
|
+
async afterEach(store, key, artifactory, pm) {
|
|
84
151
|
return store;
|
|
85
152
|
}
|
|
86
|
-
async give(subject, key, testResourceConfiguration, tester, artifactory, tLog,
|
|
153
|
+
async give(subject, key, testResourceConfiguration, tester, artifactory, tLog, pm, suiteNdx) {
|
|
87
154
|
tLog(`\n Given: ${this.name}`);
|
|
88
155
|
const givenArtifactory = (fPath, value) => artifactory(`given-${key}/${fPath}`, value);
|
|
89
156
|
try {
|
|
90
|
-
this.store = await this.givenThat(subject, testResourceConfiguration, givenArtifactory, this.givenCB);
|
|
91
157
|
// tLog(`\n Given this.store`, this.store);
|
|
92
|
-
|
|
93
|
-
|
|
158
|
+
const beforeEachProxy = new Proxy(pm, {
|
|
159
|
+
get(target, prop, receiver) {
|
|
160
|
+
if (prop === "writeFileSync") {
|
|
161
|
+
console.log("beforeEachProx", arguments, target[prop]);
|
|
162
|
+
return (fp, contents) => target[prop](`suite-${suiteNdx}/given-${key}/when/beforeEach/${fp}`, contents);
|
|
163
|
+
}
|
|
164
|
+
return Reflect.get(...arguments);
|
|
165
|
+
},
|
|
166
|
+
});
|
|
167
|
+
this.store = await this.givenThat(subject, testResourceConfiguration, givenArtifactory, this.givenCB, beforeEachProxy);
|
|
168
|
+
for (const [whenNdx, whenStep] of this.whens.entries()) {
|
|
169
|
+
await whenStep.test(this.store, testResourceConfiguration, tLog, pm, `suite-${suiteNdx}/given-${key}/when/${whenNdx}`);
|
|
94
170
|
}
|
|
95
171
|
for (const thenStep of this.thens) {
|
|
96
|
-
const t = await thenStep.test(this.store, testResourceConfiguration, tLog,
|
|
172
|
+
const t = await thenStep.test(this.store, testResourceConfiguration, tLog, pm);
|
|
97
173
|
tester(t);
|
|
98
174
|
}
|
|
99
175
|
}
|
|
@@ -105,7 +181,66 @@ export class BaseGiven {
|
|
|
105
181
|
}
|
|
106
182
|
finally {
|
|
107
183
|
try {
|
|
108
|
-
|
|
184
|
+
// const afterEachProxy = new Proxy(pm, {
|
|
185
|
+
// get(target, prop, receiver) {
|
|
186
|
+
// if (prop === "writeFileSync") {
|
|
187
|
+
// console.log("afterEachProxy", arguments, target[prop]);
|
|
188
|
+
// return (fp, contents) =>
|
|
189
|
+
// // target[prop](`${key}/andWhen/${fp}`, contents);
|
|
190
|
+
// target[prop](`${key}/afterEach/${fp}`, contents);
|
|
191
|
+
// }
|
|
192
|
+
// return Reflect.get(...arguments);
|
|
193
|
+
// },
|
|
194
|
+
// });
|
|
195
|
+
// await this.afterEach(this.store, key, givenArtifactory, afterEachProxy);
|
|
196
|
+
// await this.afterEach(this.store, key, givenArtifactory, pm);
|
|
197
|
+
const afterEachProxy = new Proxy(pm, {
|
|
198
|
+
get(target, prop, receiver) {
|
|
199
|
+
if (prop === "writeFileSync") {
|
|
200
|
+
return (fp, contents) => target[prop](`suite-${suiteNdx}/given-${key}/afterAll/${fp}`, contents);
|
|
201
|
+
}
|
|
202
|
+
if (prop === "browser") {
|
|
203
|
+
return new Proxy(target[prop], {
|
|
204
|
+
get(bTarget, bProp, bReceiver) {
|
|
205
|
+
if (bProp === "pages") {
|
|
206
|
+
return async () => {
|
|
207
|
+
return bTarget.pages().then((pages) => {
|
|
208
|
+
return pages.map((page) => {
|
|
209
|
+
return new Proxy(page, {
|
|
210
|
+
get(pTarget, pProp, pReciever) {
|
|
211
|
+
if (pProp === "screenshot") {
|
|
212
|
+
return async (x) => {
|
|
213
|
+
// console.log(
|
|
214
|
+
// "custom-screenshot-MARK-afterEachProxy",
|
|
215
|
+
// window["custom-screenshot"].toString()
|
|
216
|
+
// );
|
|
217
|
+
return await window["custom-screenshot"](Object.assign(Object.assign({}, x), { path: `${testResourceConfiguration.fs}/suite-${suiteNdx}/given-${key}/afterEach` +
|
|
218
|
+
"/" +
|
|
219
|
+
x.path }));
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
// else if (pProp === "mainFrame") {
|
|
223
|
+
// return () => target[pProp](...arguments);
|
|
224
|
+
// }
|
|
225
|
+
else {
|
|
226
|
+
return Reflect.get(...arguments);
|
|
227
|
+
}
|
|
228
|
+
},
|
|
229
|
+
});
|
|
230
|
+
});
|
|
231
|
+
});
|
|
232
|
+
// return (await target.pages()).map((page) => {
|
|
233
|
+
// return new Proxy(page, handler2);
|
|
234
|
+
// });
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
},
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
return Reflect.get(...arguments);
|
|
241
|
+
},
|
|
242
|
+
});
|
|
243
|
+
await this.afterEach(this.store, key, givenArtifactory, afterEachProxy);
|
|
109
244
|
}
|
|
110
245
|
catch (e) {
|
|
111
246
|
console.error("afterEach failed! no error will be recorded!", e);
|
|
@@ -125,10 +260,22 @@ export class BaseWhen {
|
|
|
125
260
|
error: this.error,
|
|
126
261
|
};
|
|
127
262
|
}
|
|
128
|
-
async test(store, testResourceConfiguration, tLog,
|
|
263
|
+
async test(store, testResourceConfiguration, tLog, pm, key) {
|
|
129
264
|
tLog(" When:", this.name);
|
|
265
|
+
const name = this.name;
|
|
266
|
+
const andWhenProxy = new Proxy(pm, {
|
|
267
|
+
get(target, prop, receiver) {
|
|
268
|
+
if (prop === "writeFileSync") {
|
|
269
|
+
console.log("andWhenProxy", arguments, target[prop]);
|
|
270
|
+
return (fp, contents) =>
|
|
271
|
+
// target[prop](`${key}/andWhen/${fp}`, contents);
|
|
272
|
+
target[prop](`${key}/andWhen/${fp}`, contents);
|
|
273
|
+
}
|
|
274
|
+
return Reflect.get(...arguments);
|
|
275
|
+
},
|
|
276
|
+
});
|
|
130
277
|
try {
|
|
131
|
-
return await this.andWhen(store, this.whenCB, testResourceConfiguration);
|
|
278
|
+
return await this.andWhen(store, this.whenCB, testResourceConfiguration, andWhenProxy);
|
|
132
279
|
}
|
|
133
280
|
catch (e) {
|
|
134
281
|
this.error = true;
|
|
@@ -140,6 +287,7 @@ export class BaseThen {
|
|
|
140
287
|
constructor(name, thenCB) {
|
|
141
288
|
this.name = name;
|
|
142
289
|
this.thenCB = thenCB;
|
|
290
|
+
this.error = false;
|
|
143
291
|
}
|
|
144
292
|
toObj() {
|
|
145
293
|
return {
|
|
@@ -147,7 +295,7 @@ export class BaseThen {
|
|
|
147
295
|
error: this.error,
|
|
148
296
|
};
|
|
149
297
|
}
|
|
150
|
-
async test(store, testResourceConfiguration, tLog,
|
|
298
|
+
async test(store, testResourceConfiguration, tLog, pm) {
|
|
151
299
|
tLog(" Then:", this.name);
|
|
152
300
|
try {
|
|
153
301
|
const x = await this.butThen(store, this.thenCB, testResourceConfiguration);
|
|
@@ -155,7 +303,7 @@ export class BaseThen {
|
|
|
155
303
|
}
|
|
156
304
|
catch (e) {
|
|
157
305
|
console.log("test failed", e);
|
|
158
|
-
this.error =
|
|
306
|
+
this.error = e.message;
|
|
159
307
|
throw e;
|
|
160
308
|
}
|
|
161
309
|
}
|
|
@@ -168,25 +316,25 @@ export class BaseCheck {
|
|
|
168
316
|
this.whens = whens;
|
|
169
317
|
this.thens = thens;
|
|
170
318
|
}
|
|
171
|
-
async afterEach(store, key, cb,
|
|
319
|
+
async afterEach(store, key, cb, pm) {
|
|
172
320
|
return;
|
|
173
321
|
}
|
|
174
|
-
async check(subject, key, testResourceConfiguration, tester, artifactory, tLog,
|
|
322
|
+
async check(subject, key, testResourceConfiguration, tester, artifactory, tLog, pm) {
|
|
175
323
|
tLog(`\n Check: ${this.name}`);
|
|
176
324
|
const store = await this.checkThat(subject, testResourceConfiguration, artifactory);
|
|
177
325
|
await this.checkCB(Object.entries(this.whens).reduce((a, [key, when]) => {
|
|
178
326
|
a[key] = async (payload) => {
|
|
179
|
-
return await when(payload, testResourceConfiguration).test(store, testResourceConfiguration, tLog,
|
|
327
|
+
return await when(payload, testResourceConfiguration).test(store, testResourceConfiguration, tLog, pm, "x");
|
|
180
328
|
};
|
|
181
329
|
return a;
|
|
182
330
|
}, {}), Object.entries(this.thens).reduce((a, [key, then]) => {
|
|
183
331
|
a[key] = async (payload) => {
|
|
184
|
-
const t = await then(payload, testResourceConfiguration).test(store, testResourceConfiguration, tLog,
|
|
332
|
+
const t = await then(payload, testResourceConfiguration).test(store, testResourceConfiguration, tLog, pm);
|
|
185
333
|
tester(t);
|
|
186
334
|
};
|
|
187
335
|
return a;
|
|
188
336
|
}, {}));
|
|
189
|
-
await this.afterEach(store, key, () => { },
|
|
337
|
+
await this.afterEach(store, key, () => { }, pm);
|
|
190
338
|
return;
|
|
191
339
|
}
|
|
192
340
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export class BaseBuilder {
|
|
2
|
-
constructor(input, suitesOverrides, givenOverides, whenOverides, thenOverides, checkOverides,
|
|
2
|
+
constructor(input, suitesOverrides, givenOverides, whenOverides, thenOverides, checkOverides, testResourceRequirement, testSpecification
|
|
3
|
+
// puppetMaster: PM
|
|
4
|
+
) {
|
|
3
5
|
this.input = input;
|
|
4
6
|
this.artifacts = [];
|
|
5
7
|
this.artifacts = [];
|
|
@@ -10,47 +12,72 @@ export class BaseBuilder {
|
|
|
10
12
|
this.thenOverides = thenOverides;
|
|
11
13
|
this.checkOverides = checkOverides;
|
|
12
14
|
this.testSpecification = testSpecification;
|
|
15
|
+
// this.puppetMaster = puppetMaster;
|
|
13
16
|
this.specs = testSpecification(this.Suites(), this.Given(), this.When(), this.Then(), this.Check());
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
this.testJobs = this.specs.map((suite) => {
|
|
18
|
+
const suiteRunner = (suite) => async (
|
|
19
|
+
// testResourceConfiguration: ITTestResourceConfiguration,
|
|
20
|
+
puppetMaster, tLog) => {
|
|
21
|
+
await puppetMaster.startPuppeteer({
|
|
22
|
+
browserWSEndpoint: puppetMaster.testResourceConfiguration.browserWSEndpoint,
|
|
23
|
+
}, puppetMaster.testResourceConfiguration.fs);
|
|
24
|
+
return await suite.run(input, puppetMaster.testResourceConfiguration, (fPath, value) => puppetMaster.testArtiFactoryfileWriter(tLog, (p) => {
|
|
25
|
+
this.artifacts.push(p);
|
|
26
|
+
})(puppetMaster.testResourceConfiguration.fs + "/" + fPath, value), tLog, puppetMaster);
|
|
27
|
+
};
|
|
28
|
+
const runner = suiteRunner(suite);
|
|
21
29
|
return {
|
|
22
30
|
test: suite,
|
|
23
|
-
testResourceRequirement,
|
|
31
|
+
// testResourceRequirement,
|
|
24
32
|
toObj: () => {
|
|
25
33
|
return suite.toObj();
|
|
26
34
|
},
|
|
27
35
|
runner,
|
|
28
|
-
receiveTestResourceConfig: async function (
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
//
|
|
37
|
-
//
|
|
36
|
+
receiveTestResourceConfig: async function (
|
|
37
|
+
// testResourceConfiguration = {
|
|
38
|
+
// name: "",
|
|
39
|
+
// fs: ".",
|
|
40
|
+
// ports: [],
|
|
41
|
+
// browserWSEndpoint: "",
|
|
42
|
+
// },
|
|
43
|
+
puppetMaster) {
|
|
44
|
+
// console.log(
|
|
45
|
+
// `testResourceConfiguration! ${JSON.stringify(
|
|
46
|
+
// testResourceConfiguration,
|
|
47
|
+
// null,
|
|
48
|
+
// 2
|
|
49
|
+
// )}`
|
|
50
|
+
// );
|
|
51
|
+
// console.log("puppetMaster", puppetMaster);
|
|
52
|
+
await puppetMaster
|
|
53
|
+
.mkdirSync();
|
|
54
|
+
// if (!puppetMaster.existsSync(destFolder)) {
|
|
55
|
+
// puppetMaster.mkdirSync(destFolder, { recursive: true });
|
|
38
56
|
// }
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
57
|
+
// puppetMaster.writeFileSync(
|
|
58
|
+
// // puppetMaster.testResourceConfiguration.fs + `/tests.json`,
|
|
59
|
+
// `tests.json`,
|
|
60
|
+
// JSON.stringify(this.toObj(), null, 2)
|
|
61
|
+
// );
|
|
62
|
+
const logFilePath = "log.txt";
|
|
63
|
+
// puppetMaster.testResourceConfiguration.fs + `/log.txt`;
|
|
64
|
+
const access = await puppetMaster.createWriteStream(logFilePath);
|
|
65
|
+
// console.log("access", access);
|
|
66
|
+
const tLog = (...l) => {
|
|
67
|
+
// access.write(`${l.toString()}\n`);
|
|
68
|
+
// console.log("tLog", l);
|
|
69
|
+
puppetMaster.write(access, `${l.toString()}\n`);
|
|
70
|
+
};
|
|
71
|
+
const suiteDone = await runner(puppetMaster, tLog);
|
|
44
72
|
const logPromise = new Promise((res, rej) => {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
});
|
|
73
|
+
puppetMaster.end(access);
|
|
74
|
+
res(true);
|
|
48
75
|
});
|
|
49
|
-
access.end();
|
|
50
76
|
const numberOfFailures = Object.keys(suiteDone.givens).filter((k) => {
|
|
51
77
|
return suiteDone.givens[k].error;
|
|
52
78
|
}).length;
|
|
53
|
-
|
|
79
|
+
puppetMaster.writeFileSync(`exitcode`, numberOfFailures.toString());
|
|
80
|
+
puppetMaster.writeFileSync(`tests.json`, JSON.stringify(this.toObj(), null, 2));
|
|
54
81
|
console.log(`exiting gracefully with ${numberOfFailures} failures.`);
|
|
55
82
|
return {
|
|
56
83
|
failed: numberOfFailures,
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { BaseBuilder } from "./basebuilder.js";
|
|
2
2
|
export class ClassBuilder extends BaseBuilder {
|
|
3
|
-
constructor(testImplementation, testSpecification, input, suiteKlasser, givenKlasser, whenKlasser, thenKlasser, checkKlasser, testResourceRequirement
|
|
3
|
+
constructor(testImplementation, testSpecification, input, suiteKlasser, givenKlasser, whenKlasser, thenKlasser, checkKlasser, testResourceRequirement
|
|
4
|
+
// puppetMaster: PM
|
|
5
|
+
) {
|
|
4
6
|
const classySuites = Object.entries(testImplementation.suites).reduce((a, [key], index) => {
|
|
5
7
|
a[key] = (somestring, givens, checks) => {
|
|
6
8
|
return new suiteKlasser.prototype.constructor(somestring, index, givens, checks);
|
|
@@ -31,6 +33,8 @@ export class ClassBuilder extends BaseBuilder {
|
|
|
31
33
|
};
|
|
32
34
|
return a;
|
|
33
35
|
}, {});
|
|
34
|
-
super(input, classySuites, classyGivens, classyWhens, classyThens, classyChecks,
|
|
36
|
+
super(input, classySuites, classyGivens, classyWhens, classyThens, classyChecks, testResourceRequirement, testSpecification
|
|
37
|
+
// puppetMaster
|
|
38
|
+
);
|
|
35
39
|
}
|
|
36
40
|
}
|