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
@@ -13,45 +13,114 @@ export class BaseSuite {
13
13
  fails: this.fails,
14
14
  };
15
15
  }
16
- setup(s, artifactory, tr, utils) {
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
- async run(input, testResourceConfiguration, artifactory, tLog, utils) {
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
- const subject = await this.setup(input, suiteArtifactory, testResourceConfiguration, utils);
29
+ console.log("\nSuite:", this.index, this.name);
28
30
  tLog("\nSuite:", this.index, this.name);
29
- for (const k of Object.keys(this.givens)) {
30
- const giver = this.givens[k];
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, k, testResourceConfiguration, this.assertThat, suiteArtifactory, tLog, utils);
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
- for (const [ndx, thater] of this.checks.entries()) {
41
- await thater.check(subject, thater.name, testResourceConfiguration, this.assertThat, suiteArtifactory, tLog, utils);
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
- // @TODO fix me
44
- for (const k of Object.keys(this.givens)) {
45
- const giver = this.givens[k];
46
- try {
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, utils) {
150
+ async afterEach(store, key, artifactory, pm) {
84
151
  return store;
85
152
  }
86
- async give(subject, key, testResourceConfiguration, tester, artifactory, tLog, utils) {
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
- for (const whenStep of this.whens) {
93
- await whenStep.test(this.store, testResourceConfiguration, tLog, utils);
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, utils);
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
- await this.afterEach(this.store, key, givenArtifactory, utils);
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 pTarget[pProp](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, utils) {
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, utils) {
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 = true;
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, utils) {
319
+ async afterEach(store, key, cb, pm) {
172
320
  return;
173
321
  }
174
- async check(subject, key, testResourceConfiguration, tester, artifactory, tLog, utils) {
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, utils);
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, utils);
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, () => { }, utils);
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, logWriter, testResourceRequirement, testSpecification) {
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
- const suiteRunner = (suite, utils) => async (testResourceConfiguration, tLog, utils) => {
15
- return await suite.run(input, testResourceConfiguration, (fPath, value) => logWriter.testArtiFactoryfileWriter(tLog, (p) => {
16
- this.artifacts.push(p);
17
- })(testResourceConfiguration.fs + "/" + fPath, value), tLog, utils);
18
- };
19
- this.testJobs = this.specs.map((suite, utils) => {
20
- const runner = suiteRunner(suite, utils);
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 (testResourceConfiguration = {
29
- name: "",
30
- fs: ".",
31
- ports: [],
32
- scheduled: false,
33
- }, y) {
34
- console.log(`testResourceConfiguration ${JSON.stringify(testResourceConfiguration, null, 2)}`);
35
- // await logWriter.mkdirSync(testResourceConfiguration.fs);
36
- // if (!fs.existsSync(destFolder)) {
37
- // fs.mkdirSync(destFolder, { recursive: true });
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
- logWriter.writeFileSync(`${testResourceConfiguration.fs}/tests.json`, JSON.stringify(this.toObj(), null, 2));
40
- const logFilePath = `${testResourceConfiguration.fs}/log.txt`;
41
- const access = await logWriter.createWriteStream(logFilePath);
42
- const tLog = (...l) => access.write(`${l.toString()}\n`);
43
- const suiteDone = await runner(testResourceConfiguration, tLog, y);
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
- access.on("finish", () => {
46
- res(true);
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
- logWriter.writeFileSync(`${testResourceConfiguration.fs}/exitcode`, numberOfFailures.toString());
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, logWriter) {
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, logWriter, testResourceRequirement, testSpecification);
36
+ super(input, classySuites, classyGivens, classyWhens, classyThens, classyChecks, testResourceRequirement, testSpecification
37
+ // puppetMaster
38
+ );
35
39
  }
36
40
  }
@@ -2,59 +2,53 @@ import { DefaultTestInterface, defaultTestResourceRequirement, } from "./index.j
2
2
  import { BaseSuite, BaseGiven, BaseWhen, BaseThen, BaseCheck, } from "./abstractBase.js";
3
3
  import { ClassBuilder } from "./classBuilder.js";
4
4
  export default class Testeranto extends ClassBuilder {
5
- constructor(input, testSpecification, testImplementation, testResourceRequirement = defaultTestResourceRequirement, logWriter, testInterface) {
5
+ constructor(input, testSpecification, testImplementation, testResourceRequirement = defaultTestResourceRequirement, testInterface
6
+ // puppetMaster: PM
7
+ ) {
6
8
  const fullTestInterface = DefaultTestInterface(testInterface);
7
9
  super(testImplementation, testSpecification, input, class extends BaseSuite {
10
+ afterAll(store, artifactory, pm) {
11
+ // const pagesHandler = {
12
+ // get(target, prop) {
13
+ // console.log(`Getting pages property ${prop}`);
14
+ // return target[prop];
15
+ // },
16
+ // };
17
+ // const browserHandler = {
18
+ // get(target, prop) {
19
+ // console.log(`Getting browser property ${prop}`);
20
+ // if (prop === "pages") {
21
+ // // return target[prop];
22
+ // return new Proxy(target[prop], pagesHandler);
23
+ // } else {
24
+ // return target[prop];
25
+ // }
26
+ // },
27
+ // };
28
+ // const proxy = new Proxy(utils.browser, browserHandler);
29
+ return fullTestInterface.afterAll(store, (fPath, value) => {
30
+ artifactory(`afterAll4-${this.name}/${fPath}`, value);
31
+ }, pm);
32
+ }
8
33
  assertThat(t) {
9
34
  fullTestInterface.assertThis(t);
10
35
  }
11
- async setup(s, artifactory, tr, utils) {
36
+ async setup(s, artifactory, tr, pm) {
12
37
  return (fullTestInterface.beforeAll ||
13
- (async (input, artifactory, tr, utils) => input))(s, this.testResourceConfiguration, artifactory, utils);
38
+ (async (input, artifactory, tr, pm) => input))(s, this.testResourceConfiguration, artifactory, pm);
14
39
  }
15
40
  }, class Given extends BaseGiven {
16
- async givenThat(subject, testResource, artifactory, initializer) {
41
+ async givenThat(subject, testResource, artifactory, initializer, pm) {
17
42
  return fullTestInterface.beforeEach(subject, initializer, (fPath, value) =>
18
43
  // TODO does not work?
19
- artifactory(`beforeEach/${fPath}`, value), testResource, this.initialValues
20
- // utils,
21
- );
44
+ artifactory(`beforeEach/${fPath}`, value), testResource, this.initialValues, pm);
22
45
  }
23
- afterEach(store, key, artifactory, utils) {
24
- return new Promise((res) => res(fullTestInterface.afterEach(store, key, (fPath, value) => artifactory(`after/${fPath}`, value), utils)));
25
- }
26
- afterAll(store, artifactory, utils) {
27
- const pagesHandler = {
28
- get(target, prop) {
29
- console.log(`Getting pages property ${prop}`);
30
- return target[prop];
31
- },
32
- };
33
- const browserHandler = {
34
- get(target, prop) {
35
- console.log(`Getting browser property ${prop}`);
36
- if (prop === "pages") {
37
- // return target[prop];
38
- return new Proxy(target[prop], pagesHandler);
39
- }
40
- else {
41
- return target[prop];
42
- }
43
- },
44
- };
45
- const proxy = new Proxy(utils.browser, browserHandler);
46
- return fullTestInterface.afterAll(store, (fPath, value) => {
47
- artifactory(`afterAll4-${this.name}/${fPath}`, value);
48
- }, utils
49
- // {
50
- // ...utils,
51
- // browser: proxy,
52
- // }
53
- );
46
+ afterEach(store, key, artifactory, pm) {
47
+ return new Promise((res) => res(fullTestInterface.afterEach(store, key, (fPath, value) => artifactory(`after/${fPath}`, value), pm)));
54
48
  }
55
49
  }, class When extends BaseWhen {
56
- async andWhen(store, whenCB, testResource) {
57
- return await fullTestInterface.andWhen(store, whenCB, testResource);
50
+ async andWhen(store, whenCB, testResource, pm) {
51
+ return await fullTestInterface.andWhen(store, whenCB, testResource, pm);
58
52
  }
59
53
  }, class Then extends BaseThen {
60
54
  async butThen(store, thenCB, testResourceConfiguration) {
@@ -65,14 +59,16 @@ export default class Testeranto extends ClassBuilder {
65
59
  super(name, features, checkCallback, whens, thens);
66
60
  this.initialValues = initialValues;
67
61
  }
68
- async checkThat(subject, testResourceConfiguration, artifactory) {
69
- return fullTestInterface.beforeEach(subject, this.initialValues, (fPath, value) => artifactory(`before/${fPath}`, value), testResourceConfiguration, this.initialValues);
62
+ async checkThat(subject, testResourceConfiguration, artifactory, pm) {
63
+ return fullTestInterface.beforeEach(subject, this.initialValues, (fPath, value) => artifactory(`before/${fPath}`, value), testResourceConfiguration, this.initialValues, pm);
70
64
  }
71
- afterEach(store, key, artifactory, utils) {
65
+ afterEach(store, key, artifactory, pm) {
72
66
  return new Promise((res) => res(fullTestInterface.afterEach(store, key, (fPath, value) =>
73
67
  // TODO does not work?
74
- artifactory(`afterEach2-${this.name}/${fPath}`, value), utils)));
68
+ artifactory(`afterEach2-${this.name}/${fPath}`, value), pm)));
75
69
  }
76
- }, testResourceRequirement, logWriter);
70
+ }, testResourceRequirement
71
+ // puppetMaster
72
+ );
77
73
  }
78
74
  }
@@ -1,6 +1,7 @@
1
+ // import { INodeUtils, ITestInterface, IUtils, IWebUtils } from "./types.js";
1
2
  export const BaseTestInterface = {
2
3
  beforeAll: async (s) => s,
3
- beforeEach: async function (subject, initialValues, testResource) {
4
+ beforeEach: async function (subject, initialValues, x, testResource, pm) {
4
5
  return subject;
5
6
  },
6
7
  afterEach: async (s) => s,
@@ -1,14 +1,15 @@
1
- import puppeteer from "puppeteer-core";
2
- import { NodeWriter } from "./NodeWriter";
3
- import puppeteerConfiger from "./puppeteerConfiger";
4
- window.NodeWriter = NodeWriter;
5
- window.browser = new Promise(async (res, rej) => {
6
- const browser = await puppeteerConfiger("2999").then(async (json) => {
7
- const b = await puppeteer.connect({
8
- browserWSEndpoint: json.webSocketDebuggerUrl,
9
- defaultViewport: null,
10
- });
11
- console.log("connected!", b.isConnected());
12
- return res(b);
13
- });
14
- });
1
+ "use strict";
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
+ // });