testeranto 0.73.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.
package/src/PM/web.ts CHANGED
@@ -1,28 +1,13 @@
1
1
  import { PassThrough } from "stream";
2
- import { ITLog, ITTestResourceConfiguration } from "../lib";
3
- import { PM } from "./index.js";
4
2
  import puppeteer from "puppeteer-core/lib/esm/puppeteer/puppeteer-core-browser.js";
5
3
 
6
- // type IFPaths = string[];
7
- // const fPaths: IFPaths = [];
4
+ import { ITLog, ITTestResourceConfiguration } from "../lib";
5
+ import { PM } from "./index.js";
8
6
 
9
7
  type PuppetMasterServer = Record<string, Promise<any>>;
10
8
 
11
- function waitForFunctionCall() {
12
- return new Promise<void>((resolve) => {
13
- window["myFunction"] = () => {
14
- // Do something when myFunction is called
15
- console.log("myFunction was called!");
16
- resolve(); // Resolve the promise
17
- };
18
- });
19
- }
20
-
21
- const files = new Set<string>();
22
-
23
9
  export class PM_Web extends PM {
24
10
  server: PuppetMasterServer;
25
- // testResourceConfiguration: ITTestResourceConfiguration;
26
11
 
27
12
  constructor(t: ITTestResourceConfiguration) {
28
13
  super();
@@ -43,18 +28,17 @@ export class PM_Web extends PM {
43
28
  }
44
29
 
45
30
  writeFileSync(filepath: string, contents: string) {
46
- console.log("WEB writeFileSync", filepath);
47
- files.add(filepath);
48
31
  return window["writeFileSync"](
49
32
  this.testResourceConfiguration.fs + "/" + filepath,
50
- contents
33
+ contents,
34
+ this.testResourceConfiguration.name
51
35
  );
52
36
  }
53
37
 
54
38
  createWriteStream(filepath: string): any {
55
- files.add(filepath);
56
39
  return window["createWriteStream"](
57
- this.testResourceConfiguration.fs + "/" + filepath
40
+ this.testResourceConfiguration.fs + "/" + filepath,
41
+ this.testResourceConfiguration.name
58
42
  );
59
43
  }
60
44
 
@@ -63,13 +47,10 @@ export class PM_Web extends PM {
63
47
  }
64
48
 
65
49
  customclose() {
66
- window["writeFileSync"](
67
- this.testResourceConfiguration.fs + "/manifest.json",
68
- // files.entries()
69
- JSON.stringify(Array.from(files))
70
- ).then(() => {
71
- window["customclose"]();
72
- });
50
+ window["customclose"](
51
+ this.testResourceConfiguration.fs,
52
+ this.testResourceConfiguration.name
53
+ );
73
54
  }
74
55
 
75
56
  testArtiFactoryfileWriter(tLog: ITLog, callback: (Promise) => void) {
@@ -124,12 +105,13 @@ export class PM_Web extends PM {
124
105
  }
125
106
 
126
107
  startPuppeteer(options, destFolder: string): Promise<any> {
108
+ const name = this.testResourceConfiguration.name;
109
+
127
110
  return fetch(`http://localhost:3234/json/version`)
128
111
  .then((v) => {
129
112
  return v.json();
130
113
  })
131
114
  .then((json) => {
132
- console.log("found endpoint", json.webSocketDebuggerUrl);
133
115
  return puppeteer
134
116
  .connect({
135
117
  browserWSEndpoint: json.webSocketDebuggerUrl,
@@ -140,13 +122,14 @@ export class PM_Web extends PM {
140
122
  get(target, prop, receiver) {
141
123
  if (prop === "screenshot") {
142
124
  return async (x) => {
143
- // debugger;
144
- files.add(x.path);
145
- console.log("aloha", files);
146
- return await window["custom-screenshot"]({
147
- ...x,
148
- path: destFolder + "/" + x.path,
149
- });
125
+ return await window["custom-screenshot"](
126
+ {
127
+ ...x,
128
+ // path: destFolder + "/" + x.path,
129
+ path: x.path,
130
+ },
131
+ name
132
+ );
150
133
  };
151
134
  } else if (prop === "mainFrame") {
152
135
  return () => target[prop](...arguments);
@@ -175,323 +158,5 @@ export class PM_Web extends PM {
175
158
  this.browser = proxy3;
176
159
  });
177
160
  });
178
- // console.log("connecting to ws://localhost:3234/devtools/browser/RANDOM");
179
-
180
- // return puppeteer
181
- // .connect({
182
- // ...options,
183
- // })
184
- // .finally(() => {
185
- // console.log("idk");
186
- // });
187
- // return new Promise<Browser>(async (res, rej) => {
188
- // console.log("connecting with options", options);
189
- // this.browser = await puppeteer.connect({
190
- // ...options,
191
- // });
192
- // res(this.browser);
193
- // });
194
161
  }
195
-
196
- // launchNode = (src: string, dest: string) => {
197
- // console.log("launchNode", src);
198
- // // childProcesses[src] = "running";
199
- // const destFolder = dest.replace(".mjs", "");
200
-
201
- // const argz = JSON.stringify({
202
- // scheduled: true,
203
- // name: src,
204
- // ports: [3333],
205
- // // fs: path.resolve(configs.buildDir, "web", destFolder + "/"),
206
- // // fs: destFolder,
207
- // fs: ".",
208
- // });
209
-
210
- // const builtfile = dest + ".mjs";
211
- // console.log("importing and running ", builtfile);
212
- // // import(builtfile).then(async (v) => {
213
- // // console.log("v", (await v.default).receiveTestResourceConfig(argz));
214
- // // });
215
-
216
- // // console.log("launchNode", src, dest, " -> ", destFolder, argz);
217
-
218
- // // const child = utilityProcess.fork(dest + ".mjs", [argz], {
219
- // // cwd: destFolder,
220
- // // stdio: "pipe",
221
- // // });
222
- // // const nodeGuid = uuidv4();
223
- // // nodeChildren[nodeGuid] = child;
224
-
225
- // // if (!fs.existsSync(destFolder)) {
226
- // // fs.mkdirSync(destFolder, { recursive: true });
227
- // // }
228
-
229
- // // fs.rmSync(`${destFolder}/stdout.log`, { force: true });
230
- // // fs.rmSync(`${destFolder}/stderr.log`, { force: true });
231
- // // const stdout = fs.createWriteStream(`${destFolder}/stdout.log`);
232
- // // const stderr = fs.createWriteStream(`${destFolder}/stderr.log`);
233
-
234
- // // child
235
- // // .on("message", (data) => {
236
- // // console.log("from child", JSON.stringify(data));
237
- // // if (data.launchWeb) {
238
- // // const guid = uuidv4();
239
- // // const webChild = launchWebSecondary(process.cwd() + data.launchWeb);
240
- // // // child.postMessage({ webLaunched: guid });
241
-
242
- // // webChild.webContents.on("did-finish-load", () => {
243
- // // // webChild.webContents.send("message", "hello world");
244
- // // child.postMessage({ webLaunched: guid });
245
- // // webChildren[guid] = webChild;
246
- // // node2web[nodeGuid] = [...(node2web[nodeGuid] || []), guid];
247
- // // });
248
- // // }
249
- // // if (data.teardown) {
250
- // // webChildren[data.teardown].close();
251
- // // delete webChildren[data.teardown];
252
- // // node2web[nodeGuid] = node2web[nodeGuid].filter(
253
- // // (x) => x !== data.teardown
254
- // // );
255
- // // }
256
- // // })
257
- // // .on("exit", (data) => {
258
- // // stdout.close();
259
- // // stderr.close();
260
- // // console.log(`ending node ${src}`);
261
- // // onDone(src);
262
- // // });
263
-
264
- // // child.stdout?.pipe(stdout);
265
- // // child.stderr?.pipe(stderr);
266
- // };
267
-
268
- // const launchWebSecondary = (htmlFile: string): BrowserWindow => {
269
- // console.log("launchWebSecondary", htmlFile);
270
- // const subWin = new BrowserWindow({
271
- // show: false,
272
-
273
- // webPreferences: {
274
- // nodeIntegration: true,
275
- // nodeIntegrationInWorker: true,
276
- // contextIsolation: false,
277
- // preload: path.join(app.getAppPath(), "preload.js"),
278
- // offscreen: false,
279
- // devTools: true,
280
- // },
281
- // });
282
- // remoteMain.enable(subWin.webContents);
283
- // subWin.webContents.openDevTools();
284
- // subWin.loadFile(htmlFile);
285
- // return subWin;
286
-
287
- // // const uuid = uuidv4();
288
- // // windows[uuid] = subWin;
289
- // // return uuid;
290
- // };
291
-
292
- // const launchWeb = (t: string, dest: string) => {
293
- // console.log("launchWeb", t);
294
- // childProcesses[t] = "running";
295
- // const destFolder = dest.replace(".mjs", "");
296
-
297
- // const subWin = new BrowserWindow({
298
- // show: true,
299
- // webPreferences: {
300
- // nodeIntegration: true,
301
- // nodeIntegrationInWorker: true,
302
- // contextIsolation: false,
303
- // preload: path.join(app.getAppPath(), "preload.js"),
304
- // offscreen: false,
305
- // devTools: true,
306
- // },
307
- // });
308
-
309
- // webChildren[uuidv4()] = subWin;
310
-
311
- // remoteMain.enable(subWin.webContents);
312
-
313
- // const webArgz = JSON.stringify({
314
- // name: dest,
315
- // ports: [].toString(),
316
- // fs: destFolder,
317
- // });
318
-
319
- // // console.log("webArgz", webArgz);
320
- // subWin.loadFile(`${dest}.html`, {
321
- // query: {
322
- // requesting: encodeURIComponent(webArgz),
323
- // },
324
- // });
325
-
326
- // if (!fs.existsSync(destFolder)) {
327
- // fs.mkdirSync(destFolder, { recursive: true });
328
- // }
329
- // const stdout = fs.createWriteStream(`${destFolder}/stdout.log`);
330
-
331
- // subWin.webContents.on(
332
- // "console-message",
333
- // (event, level, message, line, sourceId) => {
334
- // stdout.write(
335
- // JSON.stringify(
336
- // {
337
- // event,
338
- // level,
339
- // message: JSON.stringify(message),
340
- // line,
341
- // sourceId,
342
- // },
343
- // null,
344
- // 2
345
- // )
346
- // );
347
- // stdout.write("\n");
348
- // }
349
- // );
350
- // subWin.on("closed", () => {
351
- // stdout.close();
352
- // console.log(`ending web ${t}`);
353
- // // childProcesses[t] = "done";
354
- // onDone(t);
355
- // });
356
- // ipcMain.on("message", (message, data) => {
357
- // console.log("ipcMain message: " + JSON.stringify(data));
358
- // // process.exit();
359
- // });
360
- // };
361
-
362
- // return await import("${dest}.mjs");
363
-
364
- // launchWeb = (t: string, dest: string) => {
365
- // console.log("launchWeb", t, dest);
366
- // // childProcesses[t] = "running";
367
- // const destFolder = dest.replace(".mjs", "");
368
-
369
- // const webArgz = JSON.stringify({
370
- // name: dest,
371
- // ports: [].toString(),
372
- // fs: destFolder,
373
- // });
374
-
375
- // const evaluation = `import('${dest}.mjs').then(async (x) => {
376
- // console.log(x);
377
- // })`;
378
-
379
- // // console.log("evaluation", evaluation);
380
-
381
- // // const y = browser
382
- // // .newPage()
383
- // // .then(async (page) => {
384
- // // // const codeString = "1 + 1";
385
- // // await page.goto(
386
- // // // "file:///Users/adam/Code/kokomoBay/docs/web/src/LoginPage/react/web.test.html"
387
- // // `file://${`${dest}.html`}`
388
- // // );
389
- // // // page.url
390
- // // // page.setContent(`
391
-
392
- // // // <!DOCTYPE html>
393
- // // // <html lang="en">
394
-
395
- // // // <head>
396
-
397
- // // // </head>
398
-
399
- // // // <body>
400
- // // // <h1>/Users/adam/Code/kokomoBay/docs/web/src/LoginPage/react/web.test.html</h1>
401
- // // // <div id="root">
402
-
403
- // // // </div>
404
- // // // </body>
405
-
406
- // // // <footer></footer>
407
-
408
- // // // </html>
409
- // // // `);
410
- // // // return await page.evaluate((code) => eval(code), evaluation);
411
-
412
- // // return await page.evaluate(evaluation);
413
- // // // return await page.evaluate(async () => {
414
- // // // return await import(dest);
415
- // // // });
416
- // // })
417
- // // .then((x) => {
418
- // // console.log("mark1", x);
419
- // // });
420
- // // .then((x) => {
421
- // // console.log("mark0", x);
422
- // // })
423
- // // .catch((z) => {
424
- // // console.log("mark2", z);
425
- // // });
426
-
427
- // // const subWin = new BrowserWindow({
428
- // // show: true,
429
- // // webPreferences: {
430
- // // nodeIntegration: true,
431
- // // nodeIntegrationInWorker: true,
432
- // // contextIsolation: false,
433
- // // preload: path.join(app.getAppPath(), "preload.js"),
434
- // // offscreen: false,
435
- // // devTools: true,
436
- // // },
437
- // // });
438
-
439
- // // webChildren[uuidv4()] = subWin;
440
-
441
- // // remoteMain.enable(subWin.webContents);
442
-
443
- // // // console.log("webArgz", webArgz);
444
- // // subWin.loadFile(`${dest}.html`, {
445
- // // query: {
446
- // // requesting: encodeURIComponent(webArgz),
447
- // // },
448
- // // });
449
-
450
- // // if (!fs.existsSync(destFolder)) {
451
- // // fs.mkdirSync(destFolder, { recursive: true });
452
- // // }
453
- // // const stdout = fs.createWriteStream(`${destFolder}/stdout.log`);
454
-
455
- // // subWin.webContents.on(
456
- // // "console-message",
457
- // // (event, level, message, line, sourceId) => {
458
- // // stdout.write(
459
- // // JSON.stringify(
460
- // // {
461
- // // event,
462
- // // level,
463
- // // message: JSON.stringify(message),
464
- // // line,
465
- // // sourceId,
466
- // // },
467
- // // null,
468
- // // 2
469
- // // )
470
- // // );
471
- // // stdout.write("\n");
472
- // // }
473
- // // );
474
- // // subWin.on("closed", () => {
475
- // // stdout.close();
476
- // // console.log(`ending web ${t}`);
477
- // // // childProcesses[t] = "done";
478
- // // onDone(t);
479
- // // });
480
- // // ipcMain.on("message", (message, data) => {
481
- // // console.log("ipcMain message: " + JSON.stringify(data));
482
- // // // process.exit();
483
- // // });
484
- // };
485
162
  }
486
-
487
- // class PuppetMasterServer extends AbstractPuppetMaster {
488
- // // constructor(...z: []) {
489
- // // super(...z);
490
- // // }
491
- // // // pages(): Promise<Page[]>;
492
- // // pages(): Promise<Page[]> {
493
- // // return new Promise<Page[]>((res, rej) => {
494
- // // res(super.pages());
495
- // // });
496
- // // }
497
- // }
package/src/Report.tsx CHANGED
@@ -429,7 +429,7 @@ footer {
429
429
  <Tab eventKey="tests" title="tests">
430
430
  <Tab.Container id="left-tabs-example5" defaultActiveKey="feature-0">
431
431
  <Row>
432
- <Col sm={2}>
432
+ <Col sm={4}>
433
433
  {/* <Tree tests={features.tests} /> */}
434
434
  <Nav variant="pills" className="flex-column">
435
435
  {
@@ -443,7 +443,7 @@ footer {
443
443
  }
444
444
  </Nav>
445
445
  </Col>
446
- <Col sm={6}>
446
+ <Col sm={4}>
447
447
  <Tab.Content>
448
448
 
449
449
  {
@@ -2,9 +2,11 @@ import { CElement } from "react";
2
2
 
3
3
  import {
4
4
  IBaseTest,
5
+ IPartialInterface,
5
6
  ITestImplementation,
6
7
  ITestSpecification,
7
8
  } from "../../../Types";
9
+ import React from "react";
8
10
 
9
11
  export type IWhenShape = any;
10
12
  export type IThenShape = any;
@@ -20,10 +22,18 @@ export type ITestImpl<ITestShape extends IBaseTest> =
20
22
  export type ITestSpec<ITestShape extends IBaseTest> =
21
23
  ITestSpecification<ITestShape>;
22
24
 
23
- export const testInterface = {
24
- beforeEach: async (x, ndx, testRsource, artificer): Promise<IStore> => {
25
+ export const testInterface: IPartialInterface<any> = {
26
+ // beforeAll: async (proto, testResource, artificer, pm): Promise<IStore> => {
27
+ // return React.createElement(proto);
28
+ // // return new Promise((resolve, rej) => {
29
+ // // resolve(x());
30
+ // // });
31
+ // },
32
+ beforeEach: async (subject, initializer, artificer): Promise<IStore> => {
25
33
  return new Promise((resolve, rej) => {
26
- resolve(x());
34
+ const x = React.createElement(subject);
35
+ console.log("react-element", x);
36
+ resolve(x);
27
37
  });
28
38
  },
29
39
  andWhen: function (s: IStore, whenCB): Promise<ISelection> {
package/src/Web.ts CHANGED
@@ -34,8 +34,6 @@ class WebTesteranto<TestShape extends IBaseTest> extends Testeranto<TestShape> {
34
34
  const pm = new PM_Web(t);
35
35
  const { failed, artifacts, logPromise } =
36
36
  await this.testJobs[0].receiveTestResourceConfig(pm);
37
-
38
- console.log("test is done, awaiting test result write to fs");
39
37
  pm.customclose();
40
38
  // Promise.all([...artifacts, logPromise]).then(async () => {
41
39
  // console.log("hello world");
@@ -365,7 +365,7 @@ export abstract class BaseGiven<ITestShape extends IBaseTest> {
365
365
  // window["custom-screenshot"].toString()
366
366
  // );
367
367
 
368
- return await window["custom-screenshot"]({
368
+ return await pTarget[pProp]({
369
369
  ...x,
370
370
  path:
371
371
  `${testResourceConfiguration.fs}/suite-${suiteNdx}/given-${key}/afterEach` +