testeranto 0.62.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 +38 -26
- package/dist/cjs-shim.js +2 -2
- package/dist/common/Node.js +14 -51
- 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 +121 -266
- 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-dom/jsx/web.js +15 -7
- package/dist/common/SubPackages/react-test-renderer/MemoExoticComponent/node.js +1 -1
- package/dist/common/SubPackages/react-test-renderer/component/index.js +0 -1
- package/dist/common/SubPackages/react-test-renderer/fc/web.js +1 -1
- package/dist/common/SubPackages/react-test-renderer/jsx/index.js +1 -3
- package/dist/common/SubPackages/react-test-renderer/jsx/web.js +1 -1
- package/dist/common/SubPackages/react-test-renderer/jsx-promised/index.js +1 -1
- package/dist/common/Types.js +2 -32
- package/dist/common/Web.js +25 -37
- package/dist/common/esbuildConfigs/index.js +5 -5
- package/dist/common/esbuildConfigs/node.js +17 -15
- package/dist/common/esbuildConfigs/report.js +12 -47
- package/dist/common/esbuildConfigs/tests.js +0 -1
- package/dist/common/esbuildConfigs/web.js +17 -12
- package/dist/common/lib/abstractBase.js +190 -35
- package/dist/common/lib/basebuilder.js +56 -29
- package/dist/common/lib/classBuilder.js +8 -5
- package/dist/common/lib/core.js +42 -17
- package/dist/common/lib/index.js +11 -8
- package/dist/common/lib/types.js +2 -0
- package/dist/common/preload.js +14 -28
- package/dist/common/puppeteerConfiger.js +24 -0
- package/dist/common/tsconfig.common.tsbuildinfo +1 -1
- package/dist/module/Node.js +14 -51
- 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 +122 -267
- 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/jsx/web.js +1 -1
- package/dist/module/SubPackages/react-dom/component/node.js +2 -2
- package/dist/module/SubPackages/react-dom/component/web.js +98 -45
- package/dist/module/SubPackages/react-dom/jsx/web.js +17 -9
- package/dist/module/SubPackages/react-test-renderer/MemoExoticComponent/node.js +1 -1
- package/dist/module/SubPackages/react-test-renderer/component/index.js +0 -1
- package/dist/module/SubPackages/react-test-renderer/fc/web.js +1 -1
- package/dist/module/SubPackages/react-test-renderer/jsx/index.js +1 -3
- package/dist/module/SubPackages/react-test-renderer/jsx/web.js +1 -1
- package/dist/module/SubPackages/react-test-renderer/jsx-promised/index.js +1 -1
- package/dist/module/Types.js +3 -30
- package/dist/module/Web.js +26 -38
- package/dist/module/esbuildConfigs/index.js +5 -5
- package/dist/module/esbuildConfigs/node.js +17 -15
- package/dist/module/esbuildConfigs/report.js +11 -48
- package/dist/module/esbuildConfigs/tests.js +0 -1
- package/dist/module/esbuildConfigs/web.js +17 -12
- package/dist/module/lib/abstractBase.js +190 -35
- package/dist/module/lib/basebuilder.js +56 -29
- package/dist/module/lib/classBuilder.js +8 -5
- package/dist/module/lib/core.js +44 -19
- package/dist/module/lib/index.js +11 -8
- package/dist/module/preload.js +15 -27
- package/dist/module/puppeteerConfiger.js +19 -0
- 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/Node.d.ts +3 -2
- 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/Project.d.ts +1 -2
- package/dist/types/Puppeteer.d.ts +1 -0
- package/dist/types/Reporter.d.ts +1 -0
- package/dist/types/Scheduler.d.ts +0 -0
- package/dist/types/SubPackages/puppeteer.d.ts +3 -3
- package/dist/types/SubPackages/react/component/node.d.ts +1 -1
- package/dist/types/SubPackages/react/component/web.d.ts +1 -1
- package/dist/types/SubPackages/react/jsx/index.d.ts +1 -1
- package/dist/types/SubPackages/react/jsx/node.d.ts +1 -1
- package/dist/types/SubPackages/react/jsx/web.d.ts +2 -2
- package/dist/types/SubPackages/react-dom/component/node.d.ts +2 -2
- package/dist/types/SubPackages/react-dom/component/web.d.ts +1 -1
- package/dist/types/SubPackages/react-dom/jsx/node.d.ts +1 -1
- package/dist/types/SubPackages/react-dom/jsx/web.d.ts +1 -1
- package/dist/types/SubPackages/react-test-renderer/MemoExoticComponent/node.d.ts +1 -1
- package/dist/types/SubPackages/react-test-renderer/component/index.d.ts +1 -1
- package/dist/types/SubPackages/react-test-renderer/component/node.d.ts +1 -1
- package/dist/types/SubPackages/react-test-renderer/component/web.d.ts +1 -1
- package/dist/types/SubPackages/react-test-renderer/fc/node.d.ts +1 -1
- package/dist/types/SubPackages/react-test-renderer/fc/web.d.ts +1 -1
- package/dist/types/SubPackages/react-test-renderer/jsx/node.d.ts +1 -1
- package/dist/types/SubPackages/react-test-renderer/jsx/web.d.ts +3 -3
- package/dist/types/SubPackages/react-test-renderer/jsx-promised/index.d.ts +1 -1
- package/dist/types/SubPackages/react-test-renderer/jsx-promised/node.d.ts +1 -1
- package/dist/types/SubPackages/react-test-renderer/jsx-promised/web.d.ts +1 -1
- package/dist/types/Types.d.ts +19 -100
- package/dist/types/Web.d.ts +3 -2
- package/dist/types/esbuildConfigs/features.d.ts +1 -1
- package/dist/types/esbuildConfigs/index.d.ts +1 -1
- package/dist/types/esbuildConfigs/node.d.ts +1 -1
- package/dist/types/esbuildConfigs/report.d.ts +4 -0
- package/dist/types/esbuildConfigs/tests.d.ts +1 -1
- package/dist/types/esbuildConfigs/web.d.ts +1 -1
- package/dist/types/lib/abstractBase.d.ts +26 -24
- package/dist/types/lib/basebuilder.d.ts +10 -7
- package/dist/types/lib/classBuilder.d.ts +4 -3
- package/dist/types/lib/core.d.ts +5 -4
- package/dist/types/lib/index.d.ts +7 -5
- package/dist/types/lib/types.d.ts +62 -0
- package/dist/types/preload.d.ts +0 -1
- package/dist/types/puppeteerConfiger.d.ts +4 -0
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/package.json +6 -7
- package/src/Node.ts +30 -85
- 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 +183 -619
- 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 +19 -14
- package/src/SubPackages/react/component/node.ts +20 -32
- package/src/SubPackages/react/component/web.ts +20 -30
- package/src/SubPackages/react/jsx/index.ts +13 -24
- package/src/SubPackages/react/jsx/node.ts +5 -8
- package/src/SubPackages/react/jsx/web.ts +10 -8
- package/src/SubPackages/react-dom/component/node.ts +17 -23
- package/src/SubPackages/react-dom/component/web.ts +134 -95
- package/src/SubPackages/react-dom/jsx/web.ts +41 -48
- package/src/SubPackages/react-test-renderer/MemoExoticComponent/node.ts +27 -37
- package/src/SubPackages/react-test-renderer/component/index.ts +16 -30
- package/src/SubPackages/react-test-renderer/component/node.ts +5 -11
- package/src/SubPackages/react-test-renderer/component/web.ts +5 -11
- package/src/SubPackages/react-test-renderer/fc/node.ts +36 -50
- package/src/SubPackages/react-test-renderer/fc/web.ts +37 -50
- package/src/SubPackages/react-test-renderer/jsx/index.ts +15 -21
- package/src/SubPackages/react-test-renderer/jsx/node.ts +6 -10
- package/src/SubPackages/react-test-renderer/jsx/web.ts +7 -7
- package/src/SubPackages/react-test-renderer/jsx-promised/index.ts +13 -16
- package/src/Types.ts +73 -307
- package/src/Web.ts +40 -81
- package/src/cjs-shim.js +2 -2
- package/src/esbuildConfigs/features.ts +3 -4
- package/src/esbuildConfigs/index.ts +8 -8
- package/src/esbuildConfigs/node.ts +21 -20
- package/src/esbuildConfigs/report.ts +15 -51
- package/src/esbuildConfigs/tests.ts +3 -9
- package/src/esbuildConfigs/web.ts +22 -20
- package/src/lib/abstractBase.ts +312 -164
- package/src/lib/basebuilder.ts +123 -127
- package/src/lib/classBuilder.ts +30 -48
- package/src/lib/core.ts +115 -84
- package/src/lib/index.ts +58 -56
- package/src/lib/types.ts +197 -0
- package/src/preload.ts +14 -30
- package/src/puppeteerConfiger.ts +26 -0
- package/src/web.html.ts +1 -1
- package/dist/common/NodeWriter.js +0 -56
- package/dist/common/electron.js +0 -196
- package/dist/common/lib/browser.js +0 -26
- package/dist/common/nodeWriterElectron.js +0 -55
- package/dist/module/NodeWriter.js +0 -50
- package/dist/module/electron.js +0 -191
- package/dist/module/lib/browser.js +0 -22
- package/dist/module/nodeWriterElectron.js +0 -52
- package/dist/types/NodeWriter.d.ts +0 -2
- package/dist/types/lib/browser.d.ts +0 -6
- package/dist/types/nodeWriterElectron.d.ts +0 -2
- package/src/NodeWriter.ts +0 -69
- package/src/electron.ts +0 -250
- package/src/lib/browser.ts +0 -34
- package/src/nodeWriterElectron.ts +0 -71
- package/yarn-error.log +0 -3144
- /package/dist/{types/electron.d.ts → module/lib/types.js} +0 -0
|
@@ -16,38 +16,114 @@ class BaseSuite {
|
|
|
16
16
|
fails: this.fails,
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
|
-
setup(s, artifactory, tr,
|
|
19
|
+
setup(s, artifactory, tr, pm) {
|
|
20
20
|
return new Promise((res) => res(s));
|
|
21
21
|
}
|
|
22
22
|
assertThat(t) {
|
|
23
|
-
// console.log("base assertThat")
|
|
24
23
|
return t;
|
|
25
24
|
}
|
|
26
|
-
|
|
25
|
+
afterAll(store, artifactory, pm) {
|
|
26
|
+
return store;
|
|
27
|
+
}
|
|
28
|
+
async run(input, testResourceConfiguration, artifactory, tLog, pm) {
|
|
27
29
|
this.testResourceConfiguration = testResourceConfiguration;
|
|
28
|
-
tLog("test resources: ", testResourceConfiguration);
|
|
30
|
+
tLog("test resources: ", JSON.stringify(testResourceConfiguration));
|
|
29
31
|
const suiteArtifactory = (fPath, value) => artifactory(`suite-${this.index}-${this.name}/${fPath}`, value);
|
|
30
|
-
|
|
32
|
+
console.log("\nSuite:", this.index, this.name);
|
|
31
33
|
tLog("\nSuite:", this.index, this.name);
|
|
32
|
-
|
|
33
|
-
|
|
34
|
+
const sNdx = this.index;
|
|
35
|
+
const sName = this.name;
|
|
36
|
+
for (const [gNdx, g] of Object.entries(this.givens)) {
|
|
37
|
+
const subject = await this.setup(input, suiteArtifactory, testResourceConfiguration, pm);
|
|
38
|
+
const giver = this.givens[gNdx];
|
|
34
39
|
try {
|
|
35
|
-
this.store = await giver.give(subject,
|
|
40
|
+
this.store = await giver.give(subject, gNdx, testResourceConfiguration, this.assertThat, suiteArtifactory, tLog, pm, sNdx);
|
|
36
41
|
}
|
|
37
42
|
catch (e) {
|
|
38
43
|
console.error(e);
|
|
39
44
|
this.fails.push(giver);
|
|
40
|
-
return this;
|
|
45
|
+
// return this;
|
|
41
46
|
}
|
|
42
47
|
}
|
|
43
|
-
|
|
44
|
-
|
|
48
|
+
const afterAllProxy = new Proxy(pm, {
|
|
49
|
+
get(target, prop, receiver) {
|
|
50
|
+
if (prop === "writeFileSync") {
|
|
51
|
+
return (fp, contents) => target[prop](`suite-${sNdx}/afterAll/${fp}`, contents);
|
|
52
|
+
}
|
|
53
|
+
if (prop === "browser") {
|
|
54
|
+
return new Proxy(target[prop], {
|
|
55
|
+
get(bTarget, bProp, bReceiver) {
|
|
56
|
+
if (bProp === "pages") {
|
|
57
|
+
return async () => {
|
|
58
|
+
return bTarget.pages().then((pages) => {
|
|
59
|
+
return pages.map((page) => {
|
|
60
|
+
return new Proxy(page, {
|
|
61
|
+
get(pTarget, pProp, pReciever) {
|
|
62
|
+
if (pProp === "screenshot") {
|
|
63
|
+
return async (x) => {
|
|
64
|
+
// console.log(
|
|
65
|
+
// "custom-screenshot-MARK-afterAllProxy",
|
|
66
|
+
// // arguments,
|
|
67
|
+
// // x,
|
|
68
|
+
// window["custom-screenshot"].toString()
|
|
69
|
+
// );
|
|
70
|
+
return await window["custom-screenshot"](Object.assign(Object.assign({}, x), { path: `${testResourceConfiguration.fs}/suite-${sNdx}/afterAll` +
|
|
71
|
+
"/" +
|
|
72
|
+
x.path }));
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
// else if (pProp === "mainFrame") {
|
|
76
|
+
// return () => target[pProp](...arguments);
|
|
77
|
+
// }
|
|
78
|
+
else {
|
|
79
|
+
return Reflect.get(...arguments);
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
// return (await target.pages()).map((page) => {
|
|
86
|
+
// return new Proxy(page, handler2);
|
|
87
|
+
// });
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
return Reflect.get(...arguments);
|
|
94
|
+
},
|
|
95
|
+
});
|
|
96
|
+
// pm.browser
|
|
97
|
+
try {
|
|
98
|
+
this.afterAll(this.store, artifactory, afterAllProxy);
|
|
45
99
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
100
|
+
catch (e) {
|
|
101
|
+
console.error(e);
|
|
102
|
+
// this.fails.push(this);
|
|
103
|
+
// return this;
|
|
50
104
|
}
|
|
105
|
+
// for (const [ndx, thater] of this.checks.entries()) {
|
|
106
|
+
// await thater.check(
|
|
107
|
+
// subject,
|
|
108
|
+
// thater.name,
|
|
109
|
+
// testResourceConfiguration,
|
|
110
|
+
// this.assertThat,
|
|
111
|
+
// suiteArtifactory,
|
|
112
|
+
// tLog,
|
|
113
|
+
// pm
|
|
114
|
+
// );
|
|
115
|
+
// }
|
|
116
|
+
// @TODO fix me
|
|
117
|
+
// for (const k of Object.keys(this.givens)) {
|
|
118
|
+
// const giver = this.givens[k];
|
|
119
|
+
// try {
|
|
120
|
+
// giver.afterAll(this.store, artifactory, pm);
|
|
121
|
+
// } catch (e) {
|
|
122
|
+
// console.error(e);
|
|
123
|
+
// this.fails.push(giver);
|
|
124
|
+
// return this;
|
|
125
|
+
// }
|
|
126
|
+
// }
|
|
51
127
|
////////////////
|
|
52
128
|
return this;
|
|
53
129
|
}
|
|
@@ -65,32 +141,39 @@ class BaseGiven {
|
|
|
65
141
|
beforeAll(store, artifactory) {
|
|
66
142
|
return store;
|
|
67
143
|
}
|
|
68
|
-
afterAll(store, artifactory, utils) {
|
|
69
|
-
return store;
|
|
70
|
-
}
|
|
71
144
|
toObj() {
|
|
72
145
|
return {
|
|
73
146
|
name: this.name,
|
|
74
147
|
whens: this.whens.map((w) => w.toObj()),
|
|
75
148
|
thens: this.thens.map((t) => t.toObj()),
|
|
76
149
|
error: this.error ? [this.error, this.error.stack] : null,
|
|
150
|
+
// fail: this.fail ? [this.fail] : false,
|
|
77
151
|
features: this.features,
|
|
78
152
|
};
|
|
79
153
|
}
|
|
80
|
-
async afterEach(store, key, artifactory) {
|
|
154
|
+
async afterEach(store, key, artifactory, pm) {
|
|
81
155
|
return store;
|
|
82
156
|
}
|
|
83
|
-
async give(subject, key, testResourceConfiguration, tester, artifactory, tLog,
|
|
157
|
+
async give(subject, key, testResourceConfiguration, tester, artifactory, tLog, pm, suiteNdx) {
|
|
84
158
|
tLog(`\n Given: ${this.name}`);
|
|
85
159
|
const givenArtifactory = (fPath, value) => artifactory(`given-${key}/${fPath}`, value);
|
|
86
160
|
try {
|
|
87
|
-
this.store = await this.givenThat(subject, testResourceConfiguration, givenArtifactory, this.givenCB);
|
|
88
161
|
// tLog(`\n Given this.store`, this.store);
|
|
89
|
-
|
|
90
|
-
|
|
162
|
+
const beforeEachProxy = new Proxy(pm, {
|
|
163
|
+
get(target, prop, receiver) {
|
|
164
|
+
if (prop === "writeFileSync") {
|
|
165
|
+
console.log("beforeEachProx", arguments, target[prop]);
|
|
166
|
+
return (fp, contents) => target[prop](`suite-${suiteNdx}/given-${key}/when/beforeEach/${fp}`, contents);
|
|
167
|
+
}
|
|
168
|
+
return Reflect.get(...arguments);
|
|
169
|
+
},
|
|
170
|
+
});
|
|
171
|
+
this.store = await this.givenThat(subject, testResourceConfiguration, givenArtifactory, this.givenCB, beforeEachProxy);
|
|
172
|
+
for (const [whenNdx, whenStep] of this.whens.entries()) {
|
|
173
|
+
await whenStep.test(this.store, testResourceConfiguration, tLog, pm, `suite-${suiteNdx}/given-${key}/when/${whenNdx}`);
|
|
91
174
|
}
|
|
92
175
|
for (const thenStep of this.thens) {
|
|
93
|
-
const t = await thenStep.test(this.store, testResourceConfiguration, tLog,
|
|
176
|
+
const t = await thenStep.test(this.store, testResourceConfiguration, tLog, pm);
|
|
94
177
|
tester(t);
|
|
95
178
|
}
|
|
96
179
|
}
|
|
@@ -102,7 +185,66 @@ class BaseGiven {
|
|
|
102
185
|
}
|
|
103
186
|
finally {
|
|
104
187
|
try {
|
|
105
|
-
|
|
188
|
+
// const afterEachProxy = new Proxy(pm, {
|
|
189
|
+
// get(target, prop, receiver) {
|
|
190
|
+
// if (prop === "writeFileSync") {
|
|
191
|
+
// console.log("afterEachProxy", arguments, target[prop]);
|
|
192
|
+
// return (fp, contents) =>
|
|
193
|
+
// // target[prop](`${key}/andWhen/${fp}`, contents);
|
|
194
|
+
// target[prop](`${key}/afterEach/${fp}`, contents);
|
|
195
|
+
// }
|
|
196
|
+
// return Reflect.get(...arguments);
|
|
197
|
+
// },
|
|
198
|
+
// });
|
|
199
|
+
// await this.afterEach(this.store, key, givenArtifactory, afterEachProxy);
|
|
200
|
+
// await this.afterEach(this.store, key, givenArtifactory, pm);
|
|
201
|
+
const afterEachProxy = new Proxy(pm, {
|
|
202
|
+
get(target, prop, receiver) {
|
|
203
|
+
if (prop === "writeFileSync") {
|
|
204
|
+
return (fp, contents) => target[prop](`suite-${suiteNdx}/given-${key}/afterAll/${fp}`, contents);
|
|
205
|
+
}
|
|
206
|
+
if (prop === "browser") {
|
|
207
|
+
return new Proxy(target[prop], {
|
|
208
|
+
get(bTarget, bProp, bReceiver) {
|
|
209
|
+
if (bProp === "pages") {
|
|
210
|
+
return async () => {
|
|
211
|
+
return bTarget.pages().then((pages) => {
|
|
212
|
+
return pages.map((page) => {
|
|
213
|
+
return new Proxy(page, {
|
|
214
|
+
get(pTarget, pProp, pReciever) {
|
|
215
|
+
if (pProp === "screenshot") {
|
|
216
|
+
return async (x) => {
|
|
217
|
+
// console.log(
|
|
218
|
+
// "custom-screenshot-MARK-afterEachProxy",
|
|
219
|
+
// window["custom-screenshot"].toString()
|
|
220
|
+
// );
|
|
221
|
+
return await window["custom-screenshot"](Object.assign(Object.assign({}, x), { path: `${testResourceConfiguration.fs}/suite-${suiteNdx}/given-${key}/afterEach` +
|
|
222
|
+
"/" +
|
|
223
|
+
x.path }));
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
// else if (pProp === "mainFrame") {
|
|
227
|
+
// return () => target[pProp](...arguments);
|
|
228
|
+
// }
|
|
229
|
+
else {
|
|
230
|
+
return Reflect.get(...arguments);
|
|
231
|
+
}
|
|
232
|
+
},
|
|
233
|
+
});
|
|
234
|
+
});
|
|
235
|
+
});
|
|
236
|
+
// return (await target.pages()).map((page) => {
|
|
237
|
+
// return new Proxy(page, handler2);
|
|
238
|
+
// });
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
},
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
return Reflect.get(...arguments);
|
|
245
|
+
},
|
|
246
|
+
});
|
|
247
|
+
await this.afterEach(this.store, key, givenArtifactory, afterEachProxy);
|
|
106
248
|
}
|
|
107
249
|
catch (e) {
|
|
108
250
|
console.error("afterEach failed! no error will be recorded!", e);
|
|
@@ -123,10 +265,22 @@ class BaseWhen {
|
|
|
123
265
|
error: this.error,
|
|
124
266
|
};
|
|
125
267
|
}
|
|
126
|
-
async test(store, testResourceConfiguration, tLog,
|
|
268
|
+
async test(store, testResourceConfiguration, tLog, pm, key) {
|
|
127
269
|
tLog(" When:", this.name);
|
|
270
|
+
const name = this.name;
|
|
271
|
+
const andWhenProxy = new Proxy(pm, {
|
|
272
|
+
get(target, prop, receiver) {
|
|
273
|
+
if (prop === "writeFileSync") {
|
|
274
|
+
console.log("andWhenProxy", arguments, target[prop]);
|
|
275
|
+
return (fp, contents) =>
|
|
276
|
+
// target[prop](`${key}/andWhen/${fp}`, contents);
|
|
277
|
+
target[prop](`${key}/andWhen/${fp}`, contents);
|
|
278
|
+
}
|
|
279
|
+
return Reflect.get(...arguments);
|
|
280
|
+
},
|
|
281
|
+
});
|
|
128
282
|
try {
|
|
129
|
-
return await this.andWhen(store, this.whenCB, testResourceConfiguration);
|
|
283
|
+
return await this.andWhen(store, this.whenCB, testResourceConfiguration, andWhenProxy);
|
|
130
284
|
}
|
|
131
285
|
catch (e) {
|
|
132
286
|
this.error = true;
|
|
@@ -139,6 +293,7 @@ class BaseThen {
|
|
|
139
293
|
constructor(name, thenCB) {
|
|
140
294
|
this.name = name;
|
|
141
295
|
this.thenCB = thenCB;
|
|
296
|
+
this.error = false;
|
|
142
297
|
}
|
|
143
298
|
toObj() {
|
|
144
299
|
return {
|
|
@@ -146,15 +301,15 @@ class BaseThen {
|
|
|
146
301
|
error: this.error,
|
|
147
302
|
};
|
|
148
303
|
}
|
|
149
|
-
async test(store, testResourceConfiguration, tLog,
|
|
304
|
+
async test(store, testResourceConfiguration, tLog, pm) {
|
|
150
305
|
tLog(" Then:", this.name);
|
|
151
306
|
try {
|
|
152
|
-
const x =
|
|
307
|
+
const x = await this.butThen(store, this.thenCB, testResourceConfiguration);
|
|
153
308
|
return x;
|
|
154
309
|
}
|
|
155
310
|
catch (e) {
|
|
156
311
|
console.log("test failed", e);
|
|
157
|
-
this.error =
|
|
312
|
+
this.error = e.message;
|
|
158
313
|
throw e;
|
|
159
314
|
}
|
|
160
315
|
}
|
|
@@ -168,25 +323,25 @@ class BaseCheck {
|
|
|
168
323
|
this.whens = whens;
|
|
169
324
|
this.thens = thens;
|
|
170
325
|
}
|
|
171
|
-
async afterEach(store, key, cb) {
|
|
326
|
+
async afterEach(store, key, cb, pm) {
|
|
172
327
|
return;
|
|
173
328
|
}
|
|
174
|
-
async check(subject, key, testResourceConfiguration, tester, artifactory, tLog,
|
|
329
|
+
async check(subject, key, testResourceConfiguration, tester, artifactory, tLog, pm) {
|
|
175
330
|
tLog(`\n Check: ${this.name}`);
|
|
176
331
|
const store = await this.checkThat(subject, testResourceConfiguration, artifactory);
|
|
177
332
|
await this.checkCB(Object.entries(this.whens).reduce((a, [key, when]) => {
|
|
178
333
|
a[key] = async (payload) => {
|
|
179
|
-
return await when(payload, testResourceConfiguration).test(store, testResourceConfiguration, tLog,
|
|
334
|
+
return await when(payload, testResourceConfiguration).test(store, testResourceConfiguration, tLog, pm, "x");
|
|
180
335
|
};
|
|
181
336
|
return a;
|
|
182
337
|
}, {}), Object.entries(this.thens).reduce((a, [key, then]) => {
|
|
183
338
|
a[key] = async (payload) => {
|
|
184
|
-
const t = await then(payload, testResourceConfiguration).test(store, testResourceConfiguration, tLog,
|
|
339
|
+
const t = await then(payload, testResourceConfiguration).test(store, testResourceConfiguration, tLog, pm);
|
|
185
340
|
tester(t);
|
|
186
341
|
};
|
|
187
342
|
return a;
|
|
188
343
|
}, {}));
|
|
189
|
-
await this.afterEach(store, key);
|
|
344
|
+
await this.afterEach(store, key, () => { }, pm);
|
|
190
345
|
return;
|
|
191
346
|
}
|
|
192
347
|
}
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BaseBuilder = void 0;
|
|
4
4
|
class BaseBuilder {
|
|
5
|
-
constructor(input, suitesOverrides, givenOverides, whenOverides, thenOverides, checkOverides,
|
|
5
|
+
constructor(input, suitesOverrides, givenOverides, whenOverides, thenOverides, checkOverides, testResourceRequirement, testSpecification
|
|
6
|
+
// puppetMaster: PM
|
|
7
|
+
) {
|
|
6
8
|
this.input = input;
|
|
7
9
|
this.artifacts = [];
|
|
8
10
|
this.artifacts = [];
|
|
@@ -13,52 +15,77 @@ class BaseBuilder {
|
|
|
13
15
|
this.thenOverides = thenOverides;
|
|
14
16
|
this.checkOverides = checkOverides;
|
|
15
17
|
this.testSpecification = testSpecification;
|
|
18
|
+
// this.puppetMaster = puppetMaster;
|
|
16
19
|
this.specs = testSpecification(this.Suites(), this.Given(), this.When(), this.Then(), this.Check());
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
this.testJobs = this.specs.map((suite) => {
|
|
21
|
+
const suiteRunner = (suite) => async (
|
|
22
|
+
// testResourceConfiguration: ITTestResourceConfiguration,
|
|
23
|
+
puppetMaster, tLog) => {
|
|
24
|
+
await puppetMaster.startPuppeteer({
|
|
25
|
+
browserWSEndpoint: puppetMaster.testResourceConfiguration.browserWSEndpoint,
|
|
26
|
+
}, puppetMaster.testResourceConfiguration.fs);
|
|
27
|
+
return await suite.run(input, puppetMaster.testResourceConfiguration, (fPath, value) => puppetMaster.testArtiFactoryfileWriter(tLog, (p) => {
|
|
28
|
+
this.artifacts.push(p);
|
|
29
|
+
})(puppetMaster.testResourceConfiguration.fs + "/" + fPath, value), tLog, puppetMaster);
|
|
30
|
+
};
|
|
31
|
+
const runner = suiteRunner(suite);
|
|
24
32
|
return {
|
|
25
33
|
test: suite,
|
|
26
|
-
testResourceRequirement,
|
|
34
|
+
// testResourceRequirement,
|
|
27
35
|
toObj: () => {
|
|
28
36
|
return suite.toObj();
|
|
29
37
|
},
|
|
30
38
|
runner,
|
|
31
|
-
receiveTestResourceConfig: async function (
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
receiveTestResourceConfig: async function (
|
|
40
|
+
// testResourceConfiguration = {
|
|
41
|
+
// name: "",
|
|
42
|
+
// fs: ".",
|
|
43
|
+
// ports: [],
|
|
44
|
+
// browserWSEndpoint: "",
|
|
45
|
+
// },
|
|
46
|
+
puppetMaster) {
|
|
47
|
+
// console.log(
|
|
48
|
+
// `testResourceConfiguration! ${JSON.stringify(
|
|
49
|
+
// testResourceConfiguration,
|
|
50
|
+
// null,
|
|
51
|
+
// 2
|
|
52
|
+
// )}`
|
|
53
|
+
// );
|
|
54
|
+
// console.log("puppetMaster", puppetMaster);
|
|
55
|
+
await puppetMaster
|
|
56
|
+
.mkdirSync();
|
|
57
|
+
// if (!puppetMaster.existsSync(destFolder)) {
|
|
58
|
+
// puppetMaster.mkdirSync(destFolder, { recursive: true });
|
|
59
|
+
// }
|
|
60
|
+
// puppetMaster.writeFileSync(
|
|
61
|
+
// // puppetMaster.testResourceConfiguration.fs + `/tests.json`,
|
|
62
|
+
// `tests.json`,
|
|
63
|
+
// JSON.stringify(this.toObj(), null, 2)
|
|
64
|
+
// );
|
|
65
|
+
const logFilePath = "log.txt";
|
|
66
|
+
// puppetMaster.testResourceConfiguration.fs + `/log.txt`;
|
|
67
|
+
const access = await puppetMaster.createWriteStream(logFilePath);
|
|
68
|
+
// console.log("access", access);
|
|
42
69
|
const tLog = (...l) => {
|
|
43
|
-
//
|
|
44
|
-
|
|
70
|
+
// access.write(`${l.toString()}\n`);
|
|
71
|
+
// console.log("tLog", l);
|
|
72
|
+
puppetMaster.write(access, `${l.toString()}\n`);
|
|
45
73
|
};
|
|
46
|
-
const suiteDone = await runner(
|
|
47
|
-
const resultsFilePath = (`${testResourceConfiguration.fs}/results.json`);
|
|
48
|
-
logWriter.writeFileSync(resultsFilePath, JSON.stringify(suiteDone.toObj(), null, 2));
|
|
74
|
+
const suiteDone = await runner(puppetMaster, tLog);
|
|
49
75
|
const logPromise = new Promise((res, rej) => {
|
|
50
|
-
|
|
76
|
+
puppetMaster.end(access);
|
|
77
|
+
res(true);
|
|
51
78
|
});
|
|
52
|
-
access.end();
|
|
53
79
|
const numberOfFailures = Object.keys(suiteDone.givens).filter((k) => {
|
|
54
|
-
// console.log(`suiteDone.givens[k].error`, suiteDone.givens[k].error);
|
|
55
80
|
return suiteDone.givens[k].error;
|
|
56
81
|
}).length;
|
|
82
|
+
puppetMaster.writeFileSync(`exitcode`, numberOfFailures.toString());
|
|
83
|
+
puppetMaster.writeFileSync(`tests.json`, JSON.stringify(this.toObj(), null, 2));
|
|
57
84
|
console.log(`exiting gracefully with ${numberOfFailures} failures.`);
|
|
58
85
|
return {
|
|
59
86
|
failed: numberOfFailures,
|
|
60
87
|
artifacts: this.artifacts || [],
|
|
61
|
-
logPromise
|
|
88
|
+
logPromise,
|
|
62
89
|
};
|
|
63
90
|
},
|
|
64
91
|
};
|
|
@@ -3,17 +3,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ClassBuilder = void 0;
|
|
4
4
|
const basebuilder_js_1 = require("./basebuilder.js");
|
|
5
5
|
class ClassBuilder extends basebuilder_js_1.BaseBuilder {
|
|
6
|
-
constructor(testImplementation, testSpecification, input, suiteKlasser, givenKlasser, whenKlasser, thenKlasser, checkKlasser, testResourceRequirement
|
|
6
|
+
constructor(testImplementation, testSpecification, input, suiteKlasser, givenKlasser, whenKlasser, thenKlasser, checkKlasser, testResourceRequirement
|
|
7
|
+
// puppetMaster: PM
|
|
8
|
+
) {
|
|
7
9
|
const classySuites = Object.entries(testImplementation.suites).reduce((a, [key], index) => {
|
|
8
10
|
a[key] = (somestring, givens, checks) => {
|
|
9
11
|
return new suiteKlasser.prototype.constructor(somestring, index, givens, checks);
|
|
10
12
|
};
|
|
11
13
|
return a;
|
|
12
14
|
}, {});
|
|
13
|
-
const classyGivens = Object.entries(testImplementation.givens)
|
|
14
|
-
.reduce((a, [key, givEn]) => {
|
|
15
|
+
const classyGivens = Object.entries(testImplementation.givens).reduce((a, [key, givEn]) => {
|
|
15
16
|
a[key] = (features, whens, thens, givEn) => {
|
|
16
|
-
return new
|
|
17
|
+
return new givenKlasser.prototype.constructor(key, features, whens, thens, testImplementation.givens[key], givEn);
|
|
17
18
|
};
|
|
18
19
|
return a;
|
|
19
20
|
}, {});
|
|
@@ -35,7 +36,9 @@ class ClassBuilder extends basebuilder_js_1.BaseBuilder {
|
|
|
35
36
|
};
|
|
36
37
|
return a;
|
|
37
38
|
}, {});
|
|
38
|
-
super(input, classySuites, classyGivens, classyWhens, classyThens, classyChecks,
|
|
39
|
+
super(input, classySuites, classyGivens, classyWhens, classyThens, classyChecks, testResourceRequirement, testSpecification
|
|
40
|
+
// puppetMaster
|
|
41
|
+
);
|
|
39
42
|
}
|
|
40
43
|
}
|
|
41
44
|
exports.ClassBuilder = ClassBuilder;
|
package/dist/common/lib/core.js
CHANGED
|
@@ -4,30 +4,53 @@ const index_js_1 = require("./index.js");
|
|
|
4
4
|
const abstractBase_js_1 = require("./abstractBase.js");
|
|
5
5
|
const classBuilder_js_1 = require("./classBuilder.js");
|
|
6
6
|
class Testeranto extends classBuilder_js_1.ClassBuilder {
|
|
7
|
-
constructor(input, testSpecification, testImplementation, testResourceRequirement = index_js_1.defaultTestResourceRequirement,
|
|
7
|
+
constructor(input, testSpecification, testImplementation, testResourceRequirement = index_js_1.defaultTestResourceRequirement, testInterface
|
|
8
|
+
// puppetMaster: PM
|
|
9
|
+
) {
|
|
8
10
|
const fullTestInterface = (0, index_js_1.DefaultTestInterface)(testInterface);
|
|
9
11
|
super(testImplementation, testSpecification, input, class extends abstractBase_js_1.BaseSuite {
|
|
12
|
+
afterAll(store, artifactory, pm) {
|
|
13
|
+
// const pagesHandler = {
|
|
14
|
+
// get(target, prop) {
|
|
15
|
+
// console.log(`Getting pages property ${prop}`);
|
|
16
|
+
// return target[prop];
|
|
17
|
+
// },
|
|
18
|
+
// };
|
|
19
|
+
// const browserHandler = {
|
|
20
|
+
// get(target, prop) {
|
|
21
|
+
// console.log(`Getting browser property ${prop}`);
|
|
22
|
+
// if (prop === "pages") {
|
|
23
|
+
// // return target[prop];
|
|
24
|
+
// return new Proxy(target[prop], pagesHandler);
|
|
25
|
+
// } else {
|
|
26
|
+
// return target[prop];
|
|
27
|
+
// }
|
|
28
|
+
// },
|
|
29
|
+
// };
|
|
30
|
+
// const proxy = new Proxy(utils.browser, browserHandler);
|
|
31
|
+
return fullTestInterface.afterAll(store, (fPath, value) => {
|
|
32
|
+
artifactory(`afterAll4-${this.name}/${fPath}`, value);
|
|
33
|
+
}, pm);
|
|
34
|
+
}
|
|
10
35
|
assertThat(t) {
|
|
11
36
|
fullTestInterface.assertThis(t);
|
|
12
37
|
}
|
|
13
|
-
async setup(s, artifactory, tr) {
|
|
14
|
-
return (fullTestInterface.beforeAll ||
|
|
38
|
+
async setup(s, artifactory, tr, pm) {
|
|
39
|
+
return (fullTestInterface.beforeAll ||
|
|
40
|
+
(async (input, artifactory, tr, pm) => input))(s, this.testResourceConfiguration, artifactory, pm);
|
|
15
41
|
}
|
|
16
42
|
}, class Given extends abstractBase_js_1.BaseGiven {
|
|
17
|
-
async givenThat(subject, testResource, artifactory, initializer) {
|
|
43
|
+
async givenThat(subject, testResource, artifactory, initializer, pm) {
|
|
18
44
|
return fullTestInterface.beforeEach(subject, initializer, (fPath, value) =>
|
|
19
45
|
// TODO does not work?
|
|
20
|
-
artifactory(`beforeEach/${fPath}`, value), testResource, this.initialValues);
|
|
21
|
-
}
|
|
22
|
-
afterEach(store, key, artifactory) {
|
|
23
|
-
return new Promise((res) => res(fullTestInterface.afterEach(store, key, (fPath, value) => artifactory(`after/${fPath}`, value))));
|
|
46
|
+
artifactory(`beforeEach/${fPath}`, value), testResource, this.initialValues, pm);
|
|
24
47
|
}
|
|
25
|
-
|
|
26
|
-
return fullTestInterface.
|
|
48
|
+
afterEach(store, key, artifactory, pm) {
|
|
49
|
+
return new Promise((res) => res(fullTestInterface.afterEach(store, key, (fPath, value) => artifactory(`after/${fPath}`, value), pm)));
|
|
27
50
|
}
|
|
28
51
|
}, class When extends abstractBase_js_1.BaseWhen {
|
|
29
|
-
async andWhen(store, whenCB, testResource) {
|
|
30
|
-
return await fullTestInterface.andWhen(store, whenCB, testResource);
|
|
52
|
+
async andWhen(store, whenCB, testResource, pm) {
|
|
53
|
+
return await fullTestInterface.andWhen(store, whenCB, testResource, pm);
|
|
31
54
|
}
|
|
32
55
|
}, class Then extends abstractBase_js_1.BaseThen {
|
|
33
56
|
async butThen(store, thenCB, testResourceConfiguration) {
|
|
@@ -38,15 +61,17 @@ class Testeranto extends classBuilder_js_1.ClassBuilder {
|
|
|
38
61
|
super(name, features, checkCallback, whens, thens);
|
|
39
62
|
this.initialValues = initialValues;
|
|
40
63
|
}
|
|
41
|
-
async checkThat(subject, testResourceConfiguration, artifactory) {
|
|
42
|
-
return fullTestInterface.beforeEach(subject, this.initialValues, (fPath, value) => artifactory(`before/${fPath}`, value), testResourceConfiguration, this.initialValues);
|
|
64
|
+
async checkThat(subject, testResourceConfiguration, artifactory, pm) {
|
|
65
|
+
return fullTestInterface.beforeEach(subject, this.initialValues, (fPath, value) => artifactory(`before/${fPath}`, value), testResourceConfiguration, this.initialValues, pm);
|
|
43
66
|
}
|
|
44
|
-
afterEach(store, key, artifactory) {
|
|
67
|
+
afterEach(store, key, artifactory, pm) {
|
|
45
68
|
return new Promise((res) => res(fullTestInterface.afterEach(store, key, (fPath, value) =>
|
|
46
69
|
// TODO does not work?
|
|
47
|
-
artifactory(`afterEach2-${this.name}/${fPath}`, value))));
|
|
70
|
+
artifactory(`afterEach2-${this.name}/${fPath}`, value), pm)));
|
|
48
71
|
}
|
|
49
|
-
}, testResourceRequirement
|
|
72
|
+
}, testResourceRequirement
|
|
73
|
+
// puppetMaster
|
|
74
|
+
);
|
|
50
75
|
}
|
|
51
76
|
}
|
|
52
77
|
exports.default = Testeranto;
|
package/dist/common/lib/index.js
CHANGED
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.defaultTestResourceRequirement = exports.DefaultTestInterface = exports.BaseTestInterface = void 0;
|
|
4
|
+
// import { INodeUtils, ITestInterface, IUtils, IWebUtils } from "./types.js";
|
|
4
5
|
exports.BaseTestInterface = {
|
|
5
|
-
beforeAll:
|
|
6
|
-
beforeEach: async function (subject, initialValues, testResource) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
beforeAll: async (s) => s,
|
|
7
|
+
beforeEach: async function (subject, initialValues, x, testResource, pm) {
|
|
8
|
+
return subject;
|
|
9
|
+
},
|
|
10
|
+
afterEach: async (s) => s,
|
|
11
|
+
afterAll: (store) => undefined,
|
|
12
|
+
butThen: async (store, thenCb) => thenCb(store),
|
|
13
|
+
andWhen: (a) => a,
|
|
14
|
+
assertThis: () => null,
|
|
12
15
|
};
|
|
13
16
|
const DefaultTestInterface = (p) => {
|
|
14
17
|
return Object.assign(Object.assign({}, exports.BaseTestInterface), p);
|
|
15
18
|
};
|
|
16
19
|
exports.DefaultTestInterface = DefaultTestInterface;
|
|
17
20
|
exports.defaultTestResourceRequirement = {
|
|
18
|
-
ports: 0
|
|
21
|
+
ports: 0,
|
|
19
22
|
};
|
package/dist/common/preload.js
CHANGED
|
@@ -1,29 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
window.
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
//
|
|
11
|
-
//
|
|
12
|
-
//
|
|
13
|
-
//
|
|
14
|
-
//
|
|
15
|
-
//
|
|
16
|
-
// console.error = function (message) {
|
|
17
|
-
// ipcRenderer.invoke('web-error', message.toString());
|
|
18
|
-
// oldLog.apply(console, arguments);
|
|
19
|
-
// };
|
|
20
|
-
// var oldLog = console.warn;
|
|
21
|
-
// console.warn = function (message) {
|
|
22
|
-
// ipcRenderer.invoke('web-warn', message.toString());
|
|
23
|
-
// oldLog.apply(console, arguments);
|
|
24
|
-
// };
|
|
25
|
-
// var oldLog = console.info;
|
|
26
|
-
// console.info = function (message) {
|
|
27
|
-
// ipcRenderer.invoke('web-info', message.toString());
|
|
28
|
-
// oldLog.apply(console, arguments);
|
|
29
|
-
// };
|
|
2
|
+
// import puppeteer from "puppeteer-core";
|
|
3
|
+
// import { NodeWriter } from "./NodeWriter";
|
|
4
|
+
// import puppeteerConfiger from "./puppeteerConfiger";
|
|
5
|
+
// (window as any).NodeWriter = NodeWriter;
|
|
6
|
+
// (window as any).browser = new Promise(async (res, rej) => {
|
|
7
|
+
// const browser = await puppeteerConfiger("2999").then(async (json) => {
|
|
8
|
+
// const b = await puppeteer.connect({
|
|
9
|
+
// browserWSEndpoint: json.webSocketDebuggerUrl,
|
|
10
|
+
// defaultViewport: null,
|
|
11
|
+
// });
|
|
12
|
+
// console.log("connected!", b.isConnected());
|
|
13
|
+
// return res(b);
|
|
14
|
+
// });
|
|
15
|
+
// });
|