testeranto 0.70.0 → 0.73.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/README.md +9 -18
  2. package/dist/common/Node.js +14 -34
  3. package/dist/common/PM/index.js +71 -0
  4. package/dist/common/PM/main.js +361 -0
  5. package/dist/common/PM/node.js +176 -0
  6. package/dist/common/PM/web.js +174 -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-dom/component/web.js +98 -45
  13. package/dist/common/SubPackages/react-test-renderer/jsx/index.js +0 -1
  14. package/dist/common/Web.js +24 -43
  15. package/dist/common/esbuildConfigs/web.js +3 -1
  16. package/dist/common/lib/abstractBase.js +189 -41
  17. package/dist/common/lib/basebuilder.js +56 -29
  18. package/dist/common/lib/classBuilder.js +6 -2
  19. package/dist/common/lib/core.js +41 -45
  20. package/dist/common/lib/index.js +2 -1
  21. package/dist/common/preload.js +14 -18
  22. package/dist/common/tsconfig.common.tsbuildinfo +1 -1
  23. package/dist/module/Node.js +14 -34
  24. package/dist/module/PM/index.js +67 -0
  25. package/dist/module/PM/main.js +331 -0
  26. package/dist/module/PM/node.js +168 -0
  27. package/dist/module/PM/web.js +167 -0
  28. package/dist/module/Project.js +20 -2
  29. package/dist/module/Puppeteer.js +104 -0
  30. package/dist/module/Reporter.js +114 -0
  31. package/dist/module/Scheduler.js +1 -0
  32. package/dist/module/SubPackages/puppeteer.js +3 -1
  33. package/dist/module/SubPackages/react/jsx/node.js +1 -1
  34. package/dist/module/SubPackages/react-dom/component/web.js +98 -45
  35. package/dist/module/SubPackages/react-test-renderer/jsx/index.js +0 -1
  36. package/dist/module/Web.js +24 -43
  37. package/dist/module/esbuildConfigs/web.js +3 -1
  38. package/dist/module/lib/abstractBase.js +189 -41
  39. package/dist/module/lib/basebuilder.js +56 -29
  40. package/dist/module/lib/classBuilder.js +6 -2
  41. package/dist/module/lib/core.js +41 -45
  42. package/dist/module/lib/index.js +2 -1
  43. package/dist/module/preload.js +15 -14
  44. package/dist/module/tsconfig.module.tsbuildinfo +1 -1
  45. package/dist/prebuild/Report.css +1616 -584
  46. package/dist/prebuild/Report.js +2635 -2506
  47. package/dist/types/PM/index.d.ts +19 -0
  48. package/dist/types/PM/main.d.ts +28 -0
  49. package/dist/types/PM/node.d.ts +26 -0
  50. package/dist/types/PM/web.d.ts +24 -0
  51. package/dist/types/Reporter.d.ts +1 -0
  52. package/dist/types/Scheduler.d.ts +0 -0
  53. package/dist/types/SubPackages/react-dom/component/web.d.ts +1 -1
  54. package/dist/types/lib/abstractBase.d.ts +13 -12
  55. package/dist/types/lib/basebuilder.d.ts +4 -2
  56. package/dist/types/lib/classBuilder.d.ts +2 -2
  57. package/dist/types/lib/core.d.ts +4 -4
  58. package/dist/types/lib/index.d.ts +6 -5
  59. package/dist/types/lib/types.d.ts +16 -24
  60. package/dist/types/preload.d.ts +0 -1
  61. package/dist/types/tsconfig.types.tsbuildinfo +1 -1
  62. package/package.json +3 -5
  63. package/src/Node.ts +18 -43
  64. package/src/PM/index.ts +102 -0
  65. package/src/PM/main.ts +420 -0
  66. package/src/PM/node.ts +515 -0
  67. package/src/PM/web.ts +497 -0
  68. package/src/Project.ts +21 -2
  69. package/src/Puppeteer.ts +131 -0
  70. package/src/Report.tsx +158 -44
  71. package/src/Reporter.ts +134 -0
  72. package/src/Scheduler.ts +0 -0
  73. package/src/SubPackages/puppeteer.ts +3 -3
  74. package/src/SubPackages/react/jsx/node.ts +5 -8
  75. package/src/SubPackages/react-dom/component/web.ts +126 -67
  76. package/src/SubPackages/react-test-renderer/jsx/index.ts +0 -1
  77. package/src/Web.ts +25 -67
  78. package/src/esbuildConfigs/web.ts +4 -2
  79. package/src/lib/abstractBase.ts +260 -65
  80. package/src/lib/basebuilder.ts +121 -100
  81. package/src/lib/classBuilder.ts +5 -4
  82. package/src/lib/core.ts +58 -59
  83. package/src/lib/index.ts +10 -9
  84. package/src/lib/types.ts +18 -27
  85. package/src/preload.ts +14 -14
  86. package/dist/common/NodeWriter.js +0 -54
  87. package/dist/common/electron.js +0 -266
  88. package/dist/module/NodeWriter.js +0 -48
  89. package/dist/module/electron.js +0 -261
  90. package/dist/types/NodeWriter.d.ts +0 -2
  91. package/src/NodeWriter.ts +0 -72
  92. package/src/electron.ts +0 -317
  93. package/yarn-error.log +0 -3144
  94. /package/dist/types/{electron.d.ts → Puppeteer.d.ts} +0 -0
package/src/Report.tsx CHANGED
@@ -11,7 +11,7 @@ import { Sigma, RandomizeNodePositions, RelativeSize } from 'react-sigma';
11
11
  import 'bootstrap/dist/css/bootstrap.min.css';
12
12
 
13
13
  import { TesterantoFeatures } from "./Features.js";
14
- import { ITestTypes } from "./lib/types.js";
14
+ import { IRunTime, ITestTypes } from "./lib/types.js";
15
15
 
16
16
  type IGraphData = {
17
17
  nodes: { id: string, label: string }[],
@@ -45,14 +45,34 @@ document.addEventListener("DOMContentLoaded", function () {
45
45
  });
46
46
 
47
47
  const Report = () => {
48
+
49
+ const [state, setState] = useState<{
50
+ tests: ITestTypes[],
51
+ buildDir: string,
52
+ features: TesterantoFeatures
53
+ results: any
54
+ }>({
55
+ tests: [],
56
+ buildDir: "",
57
+ features: new TesterantoFeatures({}, {
58
+ undirected: [],
59
+ directed: [],
60
+ dags: []
61
+ }),
62
+ results: {}
63
+ });
64
+
48
65
  const [tests, setTests] = useState<
49
66
  {
50
- tests: ITestTypes[]
67
+ tests: ITestTypes[],
68
+ buildDir: string,
51
69
  }
52
70
 
53
71
  >({
54
- tests: []
72
+ tests: [],
73
+ buildDir: ""
55
74
  });
75
+
56
76
  const [features, setFeatures] = useState<TesterantoFeatures>(
57
77
  new TesterantoFeatures({}, {
58
78
  undirected: [],
@@ -61,34 +81,102 @@ const Report = () => {
61
81
  })
62
82
  );
63
83
 
64
- useEffect(() => {
65
- const importFeatures = async () => {
66
- const module = await import('features.test.js');
67
- console.log("imported features", module.default);
68
- setFeatures(module.default);
69
- };
70
- importFeatures();
71
- }, []);
84
+ const [results, setResults] = useState<Record<string, { exitcode, log, testresults, manifest }>>(
85
+ {}
86
+ );
72
87
 
88
+ const importState = async () => {
89
+ const features = await import('features.test.js');
90
+ const config = await (await fetch("./testeranto.json")).json();
91
+ const results = await Promise.all(config.tests.map((test) => {
92
+ return new Promise(async (res, rej) => {
93
+ const src: string = test[0];
94
+ const runtime: IRunTime = test[1];
95
+ const s: string = [tests.buildDir, runtime as string].concat(src.split(".").slice(0, - 1).join(".")).join("/");
96
+ const exitcode = await (await fetch(config.buildDir + "/" + s + "/exitcode")).text()
97
+ const log = await (await fetch(config.buildDir + "/" + s + "/log.txt")).text()
98
+ const testresults = await (await fetch(config.buildDir + "/" + s + "/tests.json")).json()
99
+ const manifest = await (await fetch(config.buildDir + "/" + s + "/manifest.json")).json()
100
+
101
+ res({ src, exitcode, log, testresults, manifest })
102
+ })
103
+ }))
104
+ // const results = await config.tests.reduce(async (p, test) => {
105
+ // const src: string = test[0];
106
+ // const runtime: IRunTime = test[1];
107
+ // console.log(runtime)
108
+ // const s: string = [tests.buildDir, runtime as string].concat(src.split(".").slice(0, - 1).join(".")).join("/");
109
+ // // const srr
110
+ // console.log("s", s)
111
+
112
+ // const exitcode = await (await fetch(config.buildDir + "/" + s + "/exitcode")).text()
113
+ // const log = await (await fetch(config.buildDir + "/" + s + "/log.txt")).text()
114
+ // const testresults = await (await fetch(config.buildDir + "/" + s + "/tests.json")).text()
115
+
116
+ // // setResults({ src, exitcode, log, testresults })
117
+ // // console.log("a", await a.text())
118
+ // p[src] = { exitcode, log, testresults }
119
+ // return p
120
+ // }, {});
121
+
122
+ console.log("results", results)
123
+
124
+
125
+ setState({ tests: config.tests as any, results, features: features as any, buildDir: config.buildDir })
126
+ };
127
+
128
+ const importFeatures = async () => {
129
+ const module = await import('features.test.js');
130
+ setFeatures(module.default);
131
+ };
132
+
133
+ const importTests = async () => {
134
+ const x = await fetch("./testeranto.json")
135
+ const y = await x.json();
136
+ setTests(y as any);
137
+ };
138
+
139
+ useEffect(() => { importState(); }, []);
140
+
141
+ useEffect(() => { importFeatures(); }, []);
142
+ useEffect(() => { importTests(); }, []);
73
143
 
74
144
  useEffect(() => {
75
- const importTests = async () => {
76
- const x = await fetch("./testeranto.json")
77
- const y = await x.json();
78
- console.log("imported tests", y);
79
- setTests(y as any);
145
+ const collateResults = async () => {
146
+ console.log("collating", tests, features);
147
+ const r = tests.tests.reduce(async (p, test) => {
148
+ const src: string = test[0];
149
+ const runtime: IRunTime = test[1];
150
+ console.log(runtime)
151
+ const s: string = [tests.buildDir, runtime as string].concat(src.split(".").slice(0, - 1).join(".")).join("/");
152
+ // const srr
153
+ // console.log(s)
154
+
155
+ const exitcode = await (await fetch(s + "/exitcode")).text()
156
+ const log = await (await fetch(s + "/log.txt")).text()
157
+ const testresults = await (await fetch(s + "/tests.json")).text()
158
+
159
+ // setResults({ src, exitcode, log, testresults })
160
+ // console.log("a", await a.text())
161
+ p[src] = { exitcode, log, testresults }
162
+ }, {});
163
+
164
+ setResults(r);
165
+ // const x = await fetch("./testeranto.json")
166
+ // const y = await x.json();
167
+ // setTests(y as any);
80
168
  // const module = await import('tests.json', {
81
169
  // with: {
82
170
  // type: 'json'
83
171
  // }
84
172
  // });
85
173
  // console.log("imported tests", module.default);
86
- // setTests(module.default);
174
+ // setResults("foo");
87
175
  };
88
-
89
- importTests();
176
+ collateResults();
90
177
  }, []);
91
178
 
179
+ console.log("state.results", state.results);
92
180
 
93
181
  return (
94
182
  <div>
@@ -96,6 +184,7 @@ const Report = () => {
96
184
  {`
97
185
  pre, code, p {
98
186
  max-width: 30rem;
187
+ text-wrap: auto;
99
188
  }
100
189
  footer {
101
190
  background-color: lightgray;
@@ -108,11 +197,16 @@ footer {
108
197
  `}
109
198
  </style>
110
199
 
111
- {features && tests && < Tabs defaultActiveKey="home" >
200
+ {features && tests && < Tabs defaultActiveKey="config" >
201
+
202
+
112
203
 
113
- <Tab eventKey="home" title="config">
114
- <pre>{JSON.stringify(features, null, 2)}</pre>
115
- <pre>{JSON.stringify(tests, null, 2)}</pre>
204
+ <Tab eventKey="config" title="config">
205
+ <pre>{JSON.stringify(state, null, 2)}</pre>
206
+ </Tab>
207
+
208
+ <Tab eventKey="results" title="results">
209
+ <pre>{JSON.stringify(state.results, null, 2)}</pre>
116
210
  </Tab>
117
211
 
118
212
  <Tab eventKey="features" title="features">
@@ -168,7 +262,7 @@ footer {
168
262
  </Tab>
169
263
 
170
264
  <Tab eventKey="feature.tests" title="tests">
171
- <pre id="theProps">{JSON.stringify(tests, null, 2)}</pre>
265
+ <pre id="theProps">{JSON.stringify(tests.tests, null, 2)}</pre>
172
266
  </Tab>
173
267
  </Tabs>
174
268
  </Col>
@@ -221,7 +315,7 @@ footer {
221
315
  </Tab>
222
316
 
223
317
  <Tab eventKey="feature.tests" title="tests">
224
- <pre id="theProps">{JSON.stringify(tests, null, 2)}</pre>
318
+ <pre id="theProps">{JSON.stringify(tests.tests, null, 2)}</pre>
225
319
  </Tab>
226
320
  </Tabs>
227
321
  </Col>
@@ -270,7 +364,7 @@ footer {
270
364
  </Tab>
271
365
 
272
366
  <Tab eventKey="feature.tests" title="tests">
273
- <pre id="theProps">{JSON.stringify(tests, null, 2)}</pre>
367
+ <pre id="theProps">{JSON.stringify(tests.tests, null, 2)}</pre>
274
368
  </Tab>
275
369
  </Tabs>
276
370
  </Col>
@@ -317,7 +411,7 @@ footer {
317
411
  </Tab>
318
412
 
319
413
  <Tab eventKey="feature.tests" title="tests">
320
- <pre id="theProps">{JSON.stringify(tests, null, 2)}</pre>
414
+ <pre id="theProps">{JSON.stringify(tests.tests, null, 2)}</pre>
321
415
  </Tab>
322
416
  </Tabs>
323
417
  </Col>
@@ -332,33 +426,53 @@ footer {
332
426
  </Tab.Container>
333
427
  </Tab>
334
428
 
335
- <Tab eventKey="results" title="tests">
429
+ <Tab eventKey="tests" title="tests">
336
430
  <Tab.Container id="left-tabs-example5" defaultActiveKey="feature-0">
337
431
  <Row>
338
432
  <Col sm={2}>
339
433
  {/* <Tree tests={features.tests} /> */}
340
- {/* <Nav variant="pills" className="flex-column">
341
- {
342
- features.tests.map((t, ndx) =>
343
- <Nav.Item key={ndx}>
344
- <Nav.Link eventKey={`test-${ndx}`}>
345
- {t[0]} - {t[1]}
346
- </Nav.Link>
347
- </Nav.Item>
348
- )
349
- }
350
- </Nav> */}
434
+ <Nav variant="pills" className="flex-column">
435
+ {
436
+ tests.tests.map((t, ndx) =>
437
+ <Nav.Item key={ndx}>
438
+ <Nav.Link eventKey={`test-${ndx}`}>
439
+ {t[0]} - {t[1]}
440
+ </Nav.Link>
441
+ </Nav.Item>
442
+ )
443
+ }
444
+ </Nav>
351
445
  </Col>
352
446
  <Col sm={6}>
353
447
  <Tab.Content>
354
- {/* {tests.tests.map((t, ndx) => {
355
- return (
356
- <Tab.Pane eventKey={`feature-${ndx}`} key={ndx}>
357
- <pre>{JSON.stringify(t, null, 2)}</pre>
448
+
449
+ {
450
+ tests.tests.map((t, ndx) =>
451
+ <Tab.Pane eventKey={`test-${ndx}`}>
452
+ {/* <pre>{JSON.stringify(t, null, 2)}</pre> */}
453
+ {/* <pre>{JSON.stringify(state.results, null, 2)}</pre> */}
454
+ <pre>{JSON.stringify(Object.entries(state.results).filter(([k, v]: [string, { src: string }]) => {
455
+ console.log(v.src, tests.tests[ndx][0])
456
+ return v.src === tests.tests[ndx][0]
457
+ }), null, 2)}</pre>
458
+
459
+ {/* {tests.tests.map((t, ndx) => {
460
+ return (
461
+ <Tab.Pane eventKey={`feature-${ndx}`} key={ndx}>
462
+ <pre>{JSON.stringify(t, null, 2)}</pre>
463
+ </Tab.Pane>
464
+ )
465
+ }
466
+ )} */}
467
+
358
468
  </Tab.Pane>
469
+
359
470
  )
360
471
  }
361
- )} */}
472
+
473
+
474
+
475
+
362
476
  </Tab.Content>
363
477
  </Col>
364
478
 
@@ -0,0 +1,134 @@
1
+ import readline from "readline";
2
+ import fs from "fs";
3
+ import { jsonc } from "jsonc";
4
+ import puppeteer from "puppeteer-core";
5
+
6
+ import { IBuiltConfig, IRunTime } from "./lib/types";
7
+
8
+ // import { PM_Main } from "./PM/main.js";
9
+
10
+ // var mode: "DEV" | "PROD" = process.argv[2] === "-dev" ? "DEV" : "PROD";
11
+
12
+ // const node2web: Record<string, string[]> = {};
13
+ // const web2node: Record<string, string[]> = {};
14
+ // const childProcesses: Record<string, "loaded" | "running" | "done"> = {};
15
+
16
+ readline.emitKeypressEvents(process.stdin);
17
+ if (process.stdin.isTTY) process.stdin.setRawMode(true);
18
+
19
+ console.log("\n Puppeteer is running. Press 'q' to quit\n");
20
+ process.stdin.on("keypress", (str, key) => {
21
+ if (key.name === "q") {
22
+ process.exit();
23
+ }
24
+ });
25
+
26
+ const main = async () => {
27
+ const configs = jsonc.parse(
28
+ (await fs.readFileSync("./docs/testeranto.json")).toString()
29
+ ) as IBuiltConfig;
30
+
31
+ // const pm = new PM_Main(configs);
32
+
33
+ // await puppeteer.launch(options);
34
+ const browser = await puppeteer.launch(
35
+ {
36
+ waitForInitialPage: false,
37
+ executablePath: "/opt/homebrew/bin/chromium",
38
+ headless: false,
39
+ args: [
40
+ "--allow-file-access-from-files",
41
+ "--allow-running-insecure-content",
42
+ // "--auto-open-devtools-for-tabs",
43
+ "--disable-dev-shm-usage",
44
+ "--disable-extensions",
45
+ "--disable-gpu",
46
+ "--disable-setuid-sandbox",
47
+ "--disable-site-isolation-trials",
48
+ "--disable-web-security",
49
+ "--disable-web-security",
50
+ "--no-first-run",
51
+ "--no-sandbox",
52
+ "--no-startup-window",
53
+ "--no-zygote",
54
+ "--reduce-security-for-testing",
55
+ "--remote-allow-origins=*",
56
+ // "--remote-allow-origins=ws://localhost:3234",
57
+ "--unsafely-treat-insecure-origin-as-secure=*",
58
+ // "--disable-features=IsolateOrigins",
59
+ // "--single-process",
60
+ // "--unsafely-treat-insecure-origin-as-secure",
61
+ // "--unsafely-treat-insecure-origin-as-secure=ws://192.168.0.101:3234",
62
+ // `--remote-debugging-port=3234`,
63
+ ],
64
+ }
65
+ // "."
66
+ );
67
+
68
+ console.log("Creating new page...");
69
+ const page = await browser.newPage();
70
+
71
+ await page.setViewport({ width: 0, height: 0 });
72
+
73
+ console.log("Requesting url...");
74
+ await page.goto(`file://${process.cwd()}/docs/report.html`);
75
+
76
+ // const destinationOfRuntime = (f: string, r: IRunTime) => {
77
+ // return path
78
+ // .normalize(`${configs.buildDir}/${r}/${f}`)
79
+ // .split(".")
80
+ // .slice(0, -1)
81
+ // .join(".");
82
+ // };
83
+
84
+ // configs.tests.forEach(([test, runtime, secondaryArtifacts]) => {
85
+ // if (runtime === "node") {
86
+ // pm.launchNode(test, destinationOfRuntime(test, "node"));
87
+ // } else if (runtime === "web") {
88
+ // pm.launchWeb(test, destinationOfRuntime(test, "web"));
89
+ // } else {
90
+ // console.error("runtime makes no sense", runtime);
91
+ // }
92
+ // });
93
+
94
+ // console.log("ready and watching for changes...", configs.buildDir);
95
+ // fs.watch(
96
+ // configs.buildDir,
97
+ // {
98
+ // recursive: true,
99
+ // },
100
+ // (eventType, changedFile) => {
101
+ // if (changedFile) {
102
+ // configs.tests.forEach(([test, runtime, secondaryArtifacts]) => {
103
+ // if (eventType === "change" || eventType === "rename") {
104
+ // if (
105
+ // changedFile ===
106
+ // test
107
+ // .replace("./", "node/")
108
+ // .split(".")
109
+ // .slice(0, -1)
110
+ // .concat("mjs")
111
+ // .join(".")
112
+ // ) {
113
+ // pm.launchNode(test, destinationOfRuntime(test, "node"));
114
+ // }
115
+
116
+ // if (
117
+ // changedFile ===
118
+ // test
119
+ // .replace("./", "web/")
120
+ // .split(".")
121
+ // .slice(0, -1)
122
+ // .concat("mjs")
123
+ // .join(".")
124
+ // ) {
125
+ // pm.launchWeb(test, destinationOfRuntime(test, "web"));
126
+ // }
127
+ // }
128
+ // });
129
+ // }
130
+ // }
131
+ // );
132
+ };
133
+
134
+ main();
File without changes
@@ -30,9 +30,9 @@ export default <ITestShape extends IBaseTest>(
30
30
  testImplementations,
31
31
  {
32
32
  beforeAll(x) {
33
- process.parentPort.postMessage(
34
- `/docs/web/src/ClassicalComponent/test.html`
35
- );
33
+ // process.parentPort.postMessage(
34
+ // `/docs/web/src/ClassicalComponent/test.html`
35
+ // );
36
36
 
37
37
  return x;
38
38
  },
@@ -5,25 +5,22 @@ import {
5
5
  ITestImpl,
6
6
  ITestSpec,
7
7
  IInput,
8
-
9
- testInterface as baseInterface
8
+ testInterface as baseInterface,
10
9
  } from "./index.js";
11
10
 
12
11
  export default <ITestShape extends IBaseTest>(
13
12
  testImplementations: ITestImpl<ITestShape>,
14
13
  testSpecifications: ITestSpec<ITestShape>,
15
14
  testInput: IInput,
16
- testInterface: IPartialInterface<ITestShape>,
15
+ testInterface: IPartialInterface<ITestShape>
17
16
  ) => {
18
- return Testeranto<
19
- ITestShape
20
- >(
17
+ return Testeranto<ITestShape>(
21
18
  testInput,
22
19
  testSpecifications,
23
20
  testImplementations,
24
21
  {
25
22
  ...baseInterface,
26
- ...testInterface
23
+ ...testInterface,
27
24
  }
28
- )
25
+ );
29
26
  };
@@ -18,10 +18,13 @@ type ISelection = {
18
18
  type IStore = {
19
19
  htmlElement: HTMLElement;
20
20
  reactElement: any; //CElement<any, any>,
21
+ domRoot: ReactDom.Root;
21
22
  };
22
23
 
23
24
  type ISubject = {
24
25
  htmlElement: HTMLElement;
26
+ reactElement: any; //CElement<any, any>,
27
+ domRoot: ReactDom.Root;
25
28
  };
26
29
 
27
30
  export default <ITestShape extends IBaseTest, IWhen, IGiven>(
@@ -29,76 +32,132 @@ export default <ITestShape extends IBaseTest, IWhen, IGiven>(
29
32
  testSpecifications: ITestSpecification<ITestShape>,
30
33
  testImplementations: ITestImplementation<ITestShape, any>
31
34
  ) => {
35
+ class TesterantoComponent extends testInput {
36
+ done: (t: TesterantoComponent) => void;
37
+ constructor(props) {
38
+ super(props);
39
+ this.done = props.done;
40
+ }
41
+ componentDidMount() {
42
+ super.componentDidMount && super.componentDidMount();
43
+ return this.done(this);
44
+ }
45
+ }
46
+
47
+ const t = Testeranto<ITestShape>(
48
+ testInput,
49
+ testSpecifications,
50
+ testImplementations,
51
+ {
52
+ beforeAll: async (initialProps, artificer): Promise<ISubject> => {
53
+ console.log("mark5", initialProps);
54
+ return await new Promise((resolve, rej) => {
55
+ const htmlElement = document.getElementById("root");
56
+ if (htmlElement) {
57
+ const domRoot = ReactDom.createRoot(htmlElement);
58
+ // Ignore these type errors
59
+ domRoot.render(
60
+ createElement(
61
+ TesterantoComponent,
62
+ {
63
+ ...initialProps,
64
+ done: (reactElement) => {
65
+ resolve({
66
+ htmlElement,
67
+ reactElement,
68
+ domRoot,
69
+ });
70
+ },
71
+ },
72
+ []
73
+ )
74
+ );
75
+
76
+ // resolve({ htmlElement });
77
+ }
78
+ });
79
+ },
80
+ // beforeEach: async (
81
+ // s,
82
+ // initializer,
83
+ // testResource,
84
+ // artificer,
85
+ // initialValues
86
+ // ): Promise<IStore> => {
87
+ // return new Promise((resolve, rej) => {
88
+ // console.log("beforeEach" + TesterantoComponent);
89
+
90
+ // // const domRoot = ReactDom.createRoot(htmlElement);
91
+ // // // Ignore these type errors
92
+ // // domRoot.render(
93
+ // // createElement(
94
+ // // TesterantoComponent,
95
+ // // {
96
+ // // ...initializer,
97
+ // // done: (reactElement) => {
98
+ // // resolve({
99
+ // // htmlElement,
100
+ // // reactElement,
101
+ // // domRoot,
102
+ // // });
103
+ // // },
104
+ // // },
105
+ // // []
106
+ // // )
107
+ // // );
108
+ // });
109
+ // },
110
+ andWhen: function (s: IStore, whenCB): Promise<ISelection> {
111
+ return whenCB(s);
112
+ },
113
+ butThen: async function (s: IStore, thenCB): Promise<ISelection> {
114
+ return thenCB(s);
115
+ },
116
+ afterEach: async function (store: IStore, ndx, artificer, utils) {
117
+ console.log("afterEach", store);
118
+ utils.writeFileSync("aftereachlog", store.toString());
119
+
120
+ const page = (await utils.browser.pages()).filter((x) => {
121
+ const parsedUrl = new URL(x.url());
122
+ parsedUrl.search = "";
123
+ const strippedUrl = parsedUrl.toString();
124
+
125
+ return (
126
+ strippedUrl ===
127
+ "file:///Users/adam/Code/kokomoBay/docs/web/src/ClassicalComponent/react-dom/client.web.test.html"
128
+ );
129
+ // return true;
130
+ })[0];
131
+
132
+ const x = await page.screenshot({
133
+ path: "afterEachLog.jpg",
134
+ });
135
+ console.log("x", x);
136
+ // debugger;
137
+ // const div_root = document.getElementById("root");
138
+ // store.domRoot && store.domRoot.unmount(); //React 18
139
+ // store.remove();
140
+ // store.htmlElement.remove();
141
+ // store.htmlElement = document.createElement("root");
142
+ return store;
143
+ },
144
+ afterAll: async (store: IStore, artificer, utils) => {
145
+ // setTimeout(() => {
146
+ // console.log("This will run after 1 second");
147
+ // }, 1000); // 1000 milliseconds = 1 second
148
+ // store.htmlElement.remove();
149
+ // store.htmlElement = document.createElement("root");
150
+ return store;
151
+ },
152
+ }
153
+ );
154
+
32
155
  document.addEventListener("DOMContentLoaded", function () {
33
156
  const elem = document.getElementById("root");
34
157
  if (elem) {
35
- class TesterantoComponent extends testInput {
36
- done: (t: TesterantoComponent) => void;
37
- constructor(props) {
38
- super(props);
39
- this.done = props.done;
40
- }
41
- componentDidMount() {
42
- super.componentDidMount && super.componentDidMount();
43
- return this.done(this);
44
- }
45
- }
46
-
47
- return Testeranto<ITestShape>(
48
- testInput,
49
- testSpecifications,
50
- testImplementations,
51
- {
52
- beforeAll: async (initialProps, artificer): Promise<ISubject> => {
53
- console.log("mark5", initialProps);
54
- return await new Promise((resolve, rej) => {
55
- const elem = document.getElementById("root");
56
- if (elem) {
57
- resolve({ htmlElement: elem });
58
- }
59
- });
60
- },
61
- beforeEach: async (
62
- { htmlElement },
63
- initializer,
64
- testResource,
65
- artificer,
66
- initialValues
67
- ): Promise<IStore> => {
68
- return new Promise((resolve, rej) => {
69
- // console.log("beforeEach" + JSON.stringify(initializer) + JSON.stringify(initialValues));
70
- // Ignore these type errors
71
- ReactDom.createRoot(htmlElement).render(
72
- createElement(
73
- TesterantoComponent,
74
- {
75
- ...initializer,
76
- done: (reactElement) => {
77
- resolve({
78
- htmlElement,
79
- reactElement,
80
- });
81
- },
82
- },
83
- []
84
- )
85
- );
86
- });
87
- },
88
- andWhen: function (s: IStore, whenCB): Promise<ISelection> {
89
- return whenCB(s);
90
- },
91
- butThen: async function (s: IStore): Promise<ISelection> {
92
- return s;
93
- },
94
- afterEach: async function (store: IStore, ndx, artificer) {
95
- return {};
96
- },
97
- afterAll: (store: IStore, artificer) => {
98
- return;
99
- },
100
- }
101
- );
158
+ return t;
102
159
  }
103
160
  });
161
+
162
+ return t;
104
163
  };