testeranto 0.70.0 → 0.74.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.
Files changed (98) hide show
  1. package/README.md +9 -18
  2. package/dist/common/Node.js +7 -34
  3. package/dist/common/PM/index.js +71 -0
  4. package/dist/common/PM/main.js +370 -0
  5. package/dist/common/PM/node.js +84 -0
  6. package/dist/common/PM/web.js +129 -0
  7. package/dist/common/Project.js +20 -2
  8. package/dist/common/Puppeteer.js +109 -0
  9. package/dist/common/Reporter.js +119 -0
  10. package/dist/common/Scheduler.js +1 -0
  11. package/dist/common/SubPackages/puppeteer.js +3 -1
  12. package/dist/common/SubPackages/react/jsx/index.js +14 -2
  13. package/dist/common/SubPackages/react-dom/component/web.js +98 -45
  14. package/dist/common/SubPackages/react-test-renderer/jsx/index.js +0 -1
  15. package/dist/common/Web.js +24 -44
  16. package/dist/common/esbuildConfigs/web.js +3 -1
  17. package/dist/common/lib/abstractBase.js +189 -41
  18. package/dist/common/lib/basebuilder.js +56 -29
  19. package/dist/common/lib/classBuilder.js +6 -2
  20. package/dist/common/lib/core.js +41 -45
  21. package/dist/common/lib/index.js +2 -1
  22. package/dist/common/preload.js +14 -18
  23. package/dist/common/tsconfig.common.tsbuildinfo +1 -1
  24. package/dist/module/Node.js +7 -34
  25. package/dist/module/PM/index.js +67 -0
  26. package/dist/module/PM/main.js +340 -0
  27. package/dist/module/PM/node.js +77 -0
  28. package/dist/module/PM/web.js +122 -0
  29. package/dist/module/Project.js +20 -2
  30. package/dist/module/Puppeteer.js +104 -0
  31. package/dist/module/Reporter.js +114 -0
  32. package/dist/module/Scheduler.js +1 -0
  33. package/dist/module/SubPackages/puppeteer.js +3 -1
  34. package/dist/module/SubPackages/react/jsx/index.js +11 -2
  35. package/dist/module/SubPackages/react/jsx/node.js +1 -1
  36. package/dist/module/SubPackages/react-dom/component/web.js +98 -45
  37. package/dist/module/SubPackages/react-test-renderer/jsx/index.js +0 -1
  38. package/dist/module/Web.js +24 -44
  39. package/dist/module/esbuildConfigs/web.js +3 -1
  40. package/dist/module/lib/abstractBase.js +189 -41
  41. package/dist/module/lib/basebuilder.js +56 -29
  42. package/dist/module/lib/classBuilder.js +6 -2
  43. package/dist/module/lib/core.js +41 -45
  44. package/dist/module/lib/index.js +2 -1
  45. package/dist/module/preload.js +15 -14
  46. package/dist/module/tsconfig.module.tsbuildinfo +1 -1
  47. package/dist/prebuild/Report.css +1616 -584
  48. package/dist/prebuild/Report.js +2635 -2506
  49. package/dist/types/PM/index.d.ts +19 -0
  50. package/dist/types/PM/main.d.ts +26 -0
  51. package/dist/types/PM/node.d.ts +25 -0
  52. package/dist/types/PM/web.d.ts +24 -0
  53. package/dist/types/Reporter.d.ts +1 -0
  54. package/dist/types/Scheduler.d.ts +0 -0
  55. package/dist/types/SubPackages/react/jsx/index.d.ts +2 -5
  56. package/dist/types/SubPackages/react-dom/component/web.d.ts +1 -1
  57. package/dist/types/lib/abstractBase.d.ts +13 -12
  58. package/dist/types/lib/basebuilder.d.ts +4 -2
  59. package/dist/types/lib/classBuilder.d.ts +2 -2
  60. package/dist/types/lib/core.d.ts +4 -4
  61. package/dist/types/lib/index.d.ts +6 -5
  62. package/dist/types/lib/types.d.ts +16 -24
  63. package/dist/types/preload.d.ts +0 -1
  64. package/dist/types/tsconfig.types.tsbuildinfo +1 -1
  65. package/package.json +3 -5
  66. package/src/Node.ts +8 -47
  67. package/src/PM/index.ts +102 -0
  68. package/src/PM/main.ts +452 -0
  69. package/src/PM/node.ts +122 -0
  70. package/src/PM/web.ts +162 -0
  71. package/src/Project.ts +21 -2
  72. package/src/Puppeteer.ts +131 -0
  73. package/src/Report.tsx +160 -46
  74. package/src/Reporter.ts +134 -0
  75. package/src/Scheduler.ts +0 -0
  76. package/src/SubPackages/puppeteer.ts +3 -3
  77. package/src/SubPackages/react/jsx/index.ts +13 -3
  78. package/src/SubPackages/react/jsx/node.ts +5 -8
  79. package/src/SubPackages/react-dom/component/web.ts +126 -67
  80. package/src/SubPackages/react-test-renderer/jsx/index.ts +0 -1
  81. package/src/Web.ts +25 -69
  82. package/src/esbuildConfigs/web.ts +4 -2
  83. package/src/lib/abstractBase.ts +260 -65
  84. package/src/lib/basebuilder.ts +121 -100
  85. package/src/lib/classBuilder.ts +5 -4
  86. package/src/lib/core.ts +58 -59
  87. package/src/lib/index.ts +10 -9
  88. package/src/lib/types.ts +18 -27
  89. package/src/preload.ts +14 -14
  90. package/dist/common/NodeWriter.js +0 -54
  91. package/dist/common/electron.js +0 -266
  92. package/dist/module/NodeWriter.js +0 -48
  93. package/dist/module/electron.js +0 -261
  94. package/dist/types/NodeWriter.d.ts +0 -2
  95. package/src/NodeWriter.ts +0 -72
  96. package/src/electron.ts +0 -317
  97. package/yarn-error.log +0 -3144
  98. /package/dist/types/{electron.d.ts → Puppeteer.d.ts} +0 -0
@@ -3,55 +3,35 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ const web_1 = require("./PM/web");
6
7
  const core_js_1 = __importDefault(require("./lib/core.js"));
7
8
  const index_js_1 = require("./lib/index.js");
8
- // const remote = require("@electron/remote");
9
- // import remote from "@electron/remote";
10
- // const electron = require("electron");
11
- // const remote =
12
- // process.type === "browser" ? electron : require("@electron/remote");
13
9
  class WebTesteranto extends core_js_1.default {
14
10
  constructor(input, testSpecification, testImplementation, testResourceRequirement, testInterface) {
15
- super(input, testSpecification, testImplementation, testResourceRequirement, window.NodeWriter, testInterface);
16
- const testResourceArg = decodeURIComponent(new URLSearchParams(location.search).get("requesting") || "");
17
- try {
18
- const partialTestResource = JSON.parse(testResourceArg);
19
- this.receiveTestResourceConfig(this.testJobs[0], partialTestResource);
20
- }
21
- catch (e) {
22
- console.error(e);
23
- // process.exit(-1);
24
- }
25
- const requesting = new URLSearchParams(location.search).get("requesting");
26
- if (requesting) {
27
- const testResourceArg = decodeURIComponent(requesting);
28
- try {
29
- const partialTestResource = JSON.parse(testResourceArg);
30
- console.log("initial test resource", partialTestResource);
31
- this.receiveTestResourceConfig(this.testJobs[0], partialTestResource);
32
- }
33
- catch (e) {
34
- console.error(e);
35
- // process.exit(-1);
36
- }
37
- }
11
+ super(input, testSpecification, testImplementation, testResourceRequirement, testInterface);
38
12
  }
39
- async receiveTestResourceConfig(t, partialTestResource) {
40
- const { failed, artifacts, logPromise } = await t.receiveTestResourceConfig(partialTestResource, {
41
- browser: await window.browser,
42
- ipc: window.ipcRenderer,
43
- });
44
- console.log("test is done, awaiting test result write to fs");
45
- Promise.all([...artifacts, logPromise]).then(async () => {
46
- // we can't close the window becuase we might be taking a screenshot
47
- // window.close();
48
- // console.log(
49
- // "(window as any).browser",
50
- // JSON.stringify(await (window as any).browser)
51
- // );
52
- // var currentWindow = (await (window as any).browser).getCurrentWindow();
53
- // currentWindow.close();
54
- });
13
+ async receiveTestResourceConfig(partialTestResource) {
14
+ const t = partialTestResource; //JSON.parse(partialTestResource);
15
+ const pm = new web_1.PM_Web(t);
16
+ const { failed, artifacts, logPromise } = await this.testJobs[0].receiveTestResourceConfig(pm);
17
+ pm.customclose();
18
+ // Promise.all([...artifacts, logPromise]).then(async () => {
19
+ // console.log("hello world");
20
+ // pm.customclose();
21
+ // // we can't close the window becuase we might be taking a screenshot
22
+ // // window.close();
23
+ // // console.log(
24
+ // // "(window as any).browser",
25
+ // // JSON.stringify(await (window as any).browser)
26
+ // // );
27
+ // // var currentWindow = (await (window as any).browser).getCurrentWindow();
28
+ // // window.close();
29
+ // // var customWindow = window.open("", "_blank", "");
30
+ // // customWindow.close();
31
+ // // this.puppetMaster.browser.page
32
+ // // window["customclose"]();
33
+ // // console.log("goodbye", window["customclose"]());
34
+ // });
55
35
  }
56
36
  }
57
37
  exports.default = async (input, testSpecification, testImplementation, testInterface, testResourceRequirement = index_js_1.defaultTestResourceRequirement) => {
@@ -19,7 +19,6 @@ exports.default = (config, entryPoints) => {
19
19
  "features.test.ts",
20
20
  // "url",
21
21
  "react",
22
- "electron",
23
22
  "path",
24
23
  "fs",
25
24
  "stream",
@@ -34,6 +33,9 @@ exports.default = (config, entryPoints) => {
34
33
  "zlib",
35
34
  "crypto",
36
35
  "https",
36
+ "util",
37
+ "process",
38
+ "dns",
37
39
  ], platform: "browser", entryPoints: [...entryPoints], plugins: [
38
40
  ...(config.webPlugins || []),
39
41
  {
@@ -16,45 +16,114 @@ class BaseSuite {
16
16
  fails: this.fails,
17
17
  };
18
18
  }
19
- setup(s, artifactory, tr, utils) {
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
- async run(input, testResourceConfiguration, artifactory, tLog, utils) {
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
- const subject = await this.setup(input, suiteArtifactory, testResourceConfiguration, utils);
32
+ console.log("\nSuite:", this.index, this.name);
31
33
  tLog("\nSuite:", this.index, this.name);
32
- for (const k of Object.keys(this.givens)) {
33
- const giver = this.givens[k];
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, k, testResourceConfiguration, this.assertThat, suiteArtifactory, tLog, utils);
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
- for (const [ndx, thater] of this.checks.entries()) {
44
- await thater.check(subject, thater.name, testResourceConfiguration, this.assertThat, suiteArtifactory, tLog, utils);
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
- // @TODO fix me
47
- for (const k of Object.keys(this.givens)) {
48
- const giver = this.givens[k];
49
- try {
50
- giver.afterAll(this.store, artifactory, utils);
51
- }
52
- catch (e) {
53
- console.error(e);
54
- this.fails.push(giver);
55
- return this;
56
- }
100
+ catch (e) {
101
+ console.error(e);
102
+ // this.fails.push(this);
103
+ // return this;
57
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
+ // }
58
127
  ////////////////
59
128
  return this;
60
129
  }
@@ -72,32 +141,39 @@ class BaseGiven {
72
141
  beforeAll(store, artifactory) {
73
142
  return store;
74
143
  }
75
- afterAll(store, artifactory, utils) {
76
- return store;
77
- }
78
144
  toObj() {
79
145
  return {
80
146
  name: this.name,
81
147
  whens: this.whens.map((w) => w.toObj()),
82
148
  thens: this.thens.map((t) => t.toObj()),
83
149
  error: this.error ? [this.error, this.error.stack] : null,
150
+ // fail: this.fail ? [this.fail] : false,
84
151
  features: this.features,
85
152
  };
86
153
  }
87
- async afterEach(store, key, artifactory, utils) {
154
+ async afterEach(store, key, artifactory, pm) {
88
155
  return store;
89
156
  }
90
- async give(subject, key, testResourceConfiguration, tester, artifactory, tLog, utils) {
157
+ async give(subject, key, testResourceConfiguration, tester, artifactory, tLog, pm, suiteNdx) {
91
158
  tLog(`\n Given: ${this.name}`);
92
159
  const givenArtifactory = (fPath, value) => artifactory(`given-${key}/${fPath}`, value);
93
160
  try {
94
- this.store = await this.givenThat(subject, testResourceConfiguration, givenArtifactory, this.givenCB);
95
161
  // tLog(`\n Given this.store`, this.store);
96
- for (const whenStep of this.whens) {
97
- await whenStep.test(this.store, testResourceConfiguration, tLog, utils);
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}`);
98
174
  }
99
175
  for (const thenStep of this.thens) {
100
- const t = await thenStep.test(this.store, testResourceConfiguration, tLog, utils);
176
+ const t = await thenStep.test(this.store, testResourceConfiguration, tLog, pm);
101
177
  tester(t);
102
178
  }
103
179
  }
@@ -109,7 +185,66 @@ class BaseGiven {
109
185
  }
110
186
  finally {
111
187
  try {
112
- await this.afterEach(this.store, key, givenArtifactory, utils);
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 pTarget[pProp](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);
113
248
  }
114
249
  catch (e) {
115
250
  console.error("afterEach failed! no error will be recorded!", e);
@@ -130,10 +265,22 @@ class BaseWhen {
130
265
  error: this.error,
131
266
  };
132
267
  }
133
- async test(store, testResourceConfiguration, tLog, utils) {
268
+ async test(store, testResourceConfiguration, tLog, pm, key) {
134
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
+ });
135
282
  try {
136
- return await this.andWhen(store, this.whenCB, testResourceConfiguration);
283
+ return await this.andWhen(store, this.whenCB, testResourceConfiguration, andWhenProxy);
137
284
  }
138
285
  catch (e) {
139
286
  this.error = true;
@@ -146,6 +293,7 @@ class BaseThen {
146
293
  constructor(name, thenCB) {
147
294
  this.name = name;
148
295
  this.thenCB = thenCB;
296
+ this.error = false;
149
297
  }
150
298
  toObj() {
151
299
  return {
@@ -153,7 +301,7 @@ class BaseThen {
153
301
  error: this.error,
154
302
  };
155
303
  }
156
- async test(store, testResourceConfiguration, tLog, utils) {
304
+ async test(store, testResourceConfiguration, tLog, pm) {
157
305
  tLog(" Then:", this.name);
158
306
  try {
159
307
  const x = await this.butThen(store, this.thenCB, testResourceConfiguration);
@@ -161,7 +309,7 @@ class BaseThen {
161
309
  }
162
310
  catch (e) {
163
311
  console.log("test failed", e);
164
- this.error = true;
312
+ this.error = e.message;
165
313
  throw e;
166
314
  }
167
315
  }
@@ -175,25 +323,25 @@ class BaseCheck {
175
323
  this.whens = whens;
176
324
  this.thens = thens;
177
325
  }
178
- async afterEach(store, key, cb, utils) {
326
+ async afterEach(store, key, cb, pm) {
179
327
  return;
180
328
  }
181
- async check(subject, key, testResourceConfiguration, tester, artifactory, tLog, utils) {
329
+ async check(subject, key, testResourceConfiguration, tester, artifactory, tLog, pm) {
182
330
  tLog(`\n Check: ${this.name}`);
183
331
  const store = await this.checkThat(subject, testResourceConfiguration, artifactory);
184
332
  await this.checkCB(Object.entries(this.whens).reduce((a, [key, when]) => {
185
333
  a[key] = async (payload) => {
186
- return await when(payload, testResourceConfiguration).test(store, testResourceConfiguration, tLog, utils);
334
+ return await when(payload, testResourceConfiguration).test(store, testResourceConfiguration, tLog, pm, "x");
187
335
  };
188
336
  return a;
189
337
  }, {}), Object.entries(this.thens).reduce((a, [key, then]) => {
190
338
  a[key] = async (payload) => {
191
- const t = await then(payload, testResourceConfiguration).test(store, testResourceConfiguration, tLog, utils);
339
+ const t = await then(payload, testResourceConfiguration).test(store, testResourceConfiguration, tLog, pm);
192
340
  tester(t);
193
341
  };
194
342
  return a;
195
343
  }, {}));
196
- await this.afterEach(store, key, () => { }, utils);
344
+ await this.afterEach(store, key, () => { }, pm);
197
345
  return;
198
346
  }
199
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, logWriter, testResourceRequirement, testSpecification) {
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,47 +15,72 @@ 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
- const suiteRunner = (suite, utils) => async (testResourceConfiguration, tLog, utils) => {
18
- return await suite.run(input, testResourceConfiguration, (fPath, value) => logWriter.testArtiFactoryfileWriter(tLog, (p) => {
19
- this.artifacts.push(p);
20
- })(testResourceConfiguration.fs + "/" + fPath, value), tLog, utils);
21
- };
22
- this.testJobs = this.specs.map((suite, utils) => {
23
- const runner = suiteRunner(suite, utils);
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 (testResourceConfiguration = {
32
- name: "",
33
- fs: ".",
34
- ports: [],
35
- scheduled: false,
36
- }, y) {
37
- console.log(`testResourceConfiguration ${JSON.stringify(testResourceConfiguration, null, 2)}`);
38
- // await logWriter.mkdirSync(testResourceConfiguration.fs);
39
- // if (!fs.existsSync(destFolder)) {
40
- // fs.mkdirSync(destFolder, { recursive: true });
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 });
41
59
  // }
42
- logWriter.writeFileSync(`${testResourceConfiguration.fs}/tests.json`, JSON.stringify(this.toObj(), null, 2));
43
- const logFilePath = `${testResourceConfiguration.fs}/log.txt`;
44
- const access = await logWriter.createWriteStream(logFilePath);
45
- const tLog = (...l) => access.write(`${l.toString()}\n`);
46
- const suiteDone = await runner(testResourceConfiguration, tLog, y);
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);
69
+ const tLog = (...l) => {
70
+ // access.write(`${l.toString()}\n`);
71
+ // console.log("tLog", l);
72
+ puppetMaster.write(access, `${l.toString()}\n`);
73
+ };
74
+ const suiteDone = await runner(puppetMaster, tLog);
47
75
  const logPromise = new Promise((res, rej) => {
48
- access.on("finish", () => {
49
- res(true);
50
- });
76
+ puppetMaster.end(access);
77
+ res(true);
51
78
  });
52
- access.end();
53
79
  const numberOfFailures = Object.keys(suiteDone.givens).filter((k) => {
54
80
  return suiteDone.givens[k].error;
55
81
  }).length;
56
- logWriter.writeFileSync(`${testResourceConfiguration.fs}/exitcode`, numberOfFailures.toString());
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,
@@ -3,7 +3,9 @@ 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, logWriter) {
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);
@@ -34,7 +36,9 @@ class ClassBuilder extends basebuilder_js_1.BaseBuilder {
34
36
  };
35
37
  return a;
36
38
  }, {});
37
- super(input, classySuites, classyGivens, classyWhens, classyThens, classyChecks, logWriter, testResourceRequirement, testSpecification);
39
+ super(input, classySuites, classyGivens, classyWhens, classyThens, classyChecks, testResourceRequirement, testSpecification
40
+ // puppetMaster
41
+ );
38
42
  }
39
43
  }
40
44
  exports.ClassBuilder = ClassBuilder;