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
@@ -0,0 +1,167 @@
1
+ import { PM } from "./index.js";
2
+ import puppeteer from "puppeteer-core/lib/esm/puppeteer/puppeteer-core-browser.js";
3
+ function waitForFunctionCall() {
4
+ return new Promise((resolve) => {
5
+ window["myFunction"] = () => {
6
+ // Do something when myFunction is called
7
+ console.log("myFunction was called!");
8
+ resolve(); // Resolve the promise
9
+ };
10
+ });
11
+ }
12
+ const files = new Set();
13
+ export class PM_Web extends PM {
14
+ // testResourceConfiguration: ITTestResourceConfiguration;
15
+ constructor(t) {
16
+ super();
17
+ this.server = {};
18
+ this.testResourceConfiguration = t;
19
+ }
20
+ existsSync(destFolder) {
21
+ return window["existsSync"](destFolder);
22
+ }
23
+ mkdirSync() {
24
+ return window["mkdirSync"](this.testResourceConfiguration.fs + "/");
25
+ }
26
+ write(writeObject, contents) {
27
+ return window["write"](writeObject.uid, contents);
28
+ }
29
+ writeFileSync(filepath, contents) {
30
+ console.log("WEB writeFileSync", filepath);
31
+ files.add(filepath);
32
+ return window["writeFileSync"](this.testResourceConfiguration.fs + "/" + filepath, contents);
33
+ }
34
+ createWriteStream(filepath) {
35
+ files.add(filepath);
36
+ return window["createWriteStream"](this.testResourceConfiguration.fs + "/" + filepath);
37
+ }
38
+ end(writeObject) {
39
+ return window["end"](writeObject.uid);
40
+ }
41
+ customclose() {
42
+ window["writeFileSync"](this.testResourceConfiguration.fs + "/manifest.json",
43
+ // files.entries()
44
+ JSON.stringify(Array.from(files))).then(() => {
45
+ window["customclose"]();
46
+ });
47
+ }
48
+ testArtiFactoryfileWriter(tLog, callback) {
49
+ return (fPath, value) => {
50
+ callback(new Promise((res, rej) => {
51
+ tLog("testArtiFactory =>", fPath);
52
+ // const cleanPath = path.resolve(fPath);
53
+ // fPaths.push(cleanPath.replace(process.cwd(), ``));
54
+ // const targetDir = cleanPath.split("/").slice(0, -1).join("/");
55
+ // fs.mkdir(targetDir, { recursive: true }, async (error) => {
56
+ // if (error) {
57
+ // console.error(`❗️testArtiFactory failed`, targetDir, error);
58
+ // }
59
+ // fs.writeFileSync(
60
+ // path.resolve(
61
+ // targetDir.split("/").slice(0, -1).join("/"),
62
+ // "manifest"
63
+ // ),
64
+ // fPaths.join(`\n`),
65
+ // {
66
+ // encoding: "utf-8",
67
+ // }
68
+ // );
69
+ // if (Buffer.isBuffer(value)) {
70
+ // fs.writeFileSync(fPath, value, "binary");
71
+ // res();
72
+ // } else if (`string` === typeof value) {
73
+ // fs.writeFileSync(fPath, value.toString(), {
74
+ // encoding: "utf-8",
75
+ // });
76
+ // res();
77
+ // } else {
78
+ // /* @ts-ignore:next-line */
79
+ // const pipeStream: PassThrough = value;
80
+ // const myFile = fs.createWriteStream(fPath);
81
+ // pipeStream.pipe(myFile);
82
+ // pipeStream.on("close", () => {
83
+ // myFile.close();
84
+ // res();
85
+ // });
86
+ // }
87
+ // });
88
+ }));
89
+ };
90
+ }
91
+ startPuppeteer(options, destFolder) {
92
+ return fetch(`http://localhost:3234/json/version`)
93
+ .then((v) => {
94
+ return v.json();
95
+ })
96
+ .then((json) => {
97
+ console.log("found endpoint", json.webSocketDebuggerUrl);
98
+ return puppeteer
99
+ .connect({
100
+ browserWSEndpoint: json.webSocketDebuggerUrl,
101
+ })
102
+ .then((b) => {
103
+ this.browser = b;
104
+ const handler2 = {
105
+ get(target, prop, receiver) {
106
+ if (prop === "screenshot") {
107
+ return async (x) => {
108
+ // debugger;
109
+ files.add(x.path);
110
+ console.log("aloha", files);
111
+ return await window["custom-screenshot"](Object.assign(Object.assign({}, x), { path: destFolder + "/" + x.path }));
112
+ };
113
+ }
114
+ else if (prop === "mainFrame") {
115
+ return () => target[prop](...arguments);
116
+ }
117
+ else {
118
+ return Reflect.get(...arguments);
119
+ }
120
+ },
121
+ };
122
+ const handler1 = {
123
+ get(target, prop, receiver) {
124
+ if (prop === "pages") {
125
+ return async () => {
126
+ return target.pages().then((pages) => {
127
+ return pages.map((p) => {
128
+ return new Proxy(p, handler2);
129
+ });
130
+ });
131
+ };
132
+ }
133
+ return Reflect.get(...arguments);
134
+ },
135
+ };
136
+ const proxy3 = new Proxy(this.browser, handler1);
137
+ this.browser = proxy3;
138
+ });
139
+ });
140
+ // console.log("connecting to ws://localhost:3234/devtools/browser/RANDOM");
141
+ // return puppeteer
142
+ // .connect({
143
+ // ...options,
144
+ // })
145
+ // .finally(() => {
146
+ // console.log("idk");
147
+ // });
148
+ // return new Promise<Browser>(async (res, rej) => {
149
+ // console.log("connecting with options", options);
150
+ // this.browser = await puppeteer.connect({
151
+ // ...options,
152
+ // });
153
+ // res(this.browser);
154
+ // });
155
+ }
156
+ }
157
+ // class PuppetMasterServer extends AbstractPuppetMaster {
158
+ // // constructor(...z: []) {
159
+ // // super(...z);
160
+ // // }
161
+ // // // pages(): Promise<Page[]>;
162
+ // // pages(): Promise<Page[]> {
163
+ // // return new Promise<Page[]>((res, rej) => {
164
+ // // res(super.pages());
165
+ // // });
166
+ // // }
167
+ // }
@@ -70,6 +70,24 @@ export class ITProject {
70
70
  .then((x) => fs.writeFileSync(htmlFilePath, webHtmlFrame(jsfilePath, htmlFilePath)));
71
71
  })));
72
72
  const [nodeEntryPoints, webEntryPoints] = getRunnables(this.config.tests);
73
+ // nodeEntryPoints.forEach((nep) => {
74
+ // const f = `${process.cwd()}/${nep}`;
75
+ // console.log("nep", f);
76
+ // import(f).then((module) => {
77
+ // return module.default.then((defaultModule) => {
78
+ // console.log("defaultModule", defaultModule);
79
+ // // defaultModule
80
+ // // .receiveTestResourceConfig(argz)
81
+ // // .then((x) => {
82
+ // // console.log("then", x);
83
+ // // return x;
84
+ // // })
85
+ // // .catch((e) => {
86
+ // // console.log("catch", e);
87
+ // // });
88
+ // });
89
+ // });
90
+ // });
73
91
  glob(`./${config.outdir}/chunk-*.mjs`, { ignore: "node_modules/**" }).then((chunks) => {
74
92
  chunks.forEach((chunk) => {
75
93
  fs.unlinkSync(chunk);
@@ -149,8 +167,8 @@ const getRunnables = (tests, payload = [new Set(), new Set()]) => {
149
167
  else if (cv[1] === "web") {
150
168
  pt[1].add(cv[0]);
151
169
  }
152
- if (cv[2].length) {
153
- getRunnables(cv[2], payload);
170
+ if (cv[3].length) {
171
+ getRunnables(cv[3], payload);
154
172
  }
155
173
  return pt;
156
174
  }, payload);
@@ -0,0 +1,104 @@
1
+ import readline from "readline";
2
+ import fs from "fs";
3
+ import path from "path";
4
+ import { jsonc } from "jsonc";
5
+ import { PM_Main } from "./PM/main.js";
6
+ var mode = process.argv[2] === "-dev" ? "DEV" : "PROD";
7
+ const node2web = {};
8
+ const web2node = {};
9
+ const childProcesses = {};
10
+ readline.emitKeypressEvents(process.stdin);
11
+ if (process.stdin.isTTY)
12
+ process.stdin.setRawMode(true);
13
+ console.log("\n Puppeteer is running. Press 'q' to quit\n");
14
+ process.stdin.on("keypress", (str, key) => {
15
+ if (key.name === "q") {
16
+ process.exit();
17
+ }
18
+ });
19
+ const main = async () => {
20
+ const configs = jsonc.parse((await fs.readFileSync("./docs/testeranto.json")).toString());
21
+ const pm = new PM_Main(configs);
22
+ await pm.startPuppeteer({
23
+ waitForInitialPage: false,
24
+ executablePath: "/opt/homebrew/bin/chromium",
25
+ headless: true,
26
+ dumpio: true,
27
+ args: [
28
+ "--allow-file-access-from-files",
29
+ "--allow-running-insecure-content",
30
+ "--auto-open-devtools-for-tabs",
31
+ "--disable-dev-shm-usage",
32
+ "--disable-extensions",
33
+ "--disable-gpu",
34
+ "--disable-setuid-sandbox",
35
+ "--disable-site-isolation-trials",
36
+ "--disable-web-security",
37
+ "--disable-web-security",
38
+ "--no-first-run",
39
+ "--no-sandbox",
40
+ "--no-startup-window",
41
+ // "--no-zygote",
42
+ "--reduce-security-for-testing",
43
+ "--remote-allow-origins=*",
44
+ "--unsafely-treat-insecure-origin-as-secure=*",
45
+ // "--disable-features=IsolateOrigins",
46
+ // "--remote-allow-origins=ws://localhost:3234",
47
+ // "--single-process",
48
+ // "--unsafely-treat-insecure-origin-as-secure",
49
+ // "--unsafely-treat-insecure-origin-as-secure=ws://192.168.0.101:3234",
50
+ `--remote-debugging-port=3234`,
51
+ // "--disk-cache-dir=/dev/null",
52
+ // "--disk-cache-size=1",
53
+ // "--start-maximized",
54
+ ],
55
+ }, ".");
56
+ const destinationOfRuntime = (f, r) => {
57
+ return path
58
+ .normalize(`${configs.buildDir}/${r}/${f}`)
59
+ .split(".")
60
+ .slice(0, -1)
61
+ .join(".");
62
+ };
63
+ configs.tests.forEach(([test, runtime, secondaryArtifacts]) => {
64
+ if (runtime === "node") {
65
+ pm.launchNode(test, destinationOfRuntime(test, "node"));
66
+ }
67
+ else if (runtime === "web") {
68
+ pm.launchWeb(test, destinationOfRuntime(test, "web"));
69
+ }
70
+ else {
71
+ console.error("runtime makes no sense", runtime);
72
+ }
73
+ });
74
+ console.log("ready and watching for changes...", configs.buildDir);
75
+ fs.watch(configs.buildDir, {
76
+ recursive: true,
77
+ }, (eventType, changedFile) => {
78
+ if (changedFile) {
79
+ configs.tests.forEach(([test, runtime, secondaryArtifacts]) => {
80
+ if (eventType === "change" || eventType === "rename") {
81
+ if (changedFile ===
82
+ test
83
+ .replace("./", "node/")
84
+ .split(".")
85
+ .slice(0, -1)
86
+ .concat("mjs")
87
+ .join(".")) {
88
+ pm.launchNode(test, destinationOfRuntime(test, "node"));
89
+ }
90
+ if (changedFile ===
91
+ test
92
+ .replace("./", "web/")
93
+ .split(".")
94
+ .slice(0, -1)
95
+ .concat("mjs")
96
+ .join(".")) {
97
+ pm.launchWeb(test, destinationOfRuntime(test, "web"));
98
+ }
99
+ }
100
+ });
101
+ }
102
+ });
103
+ };
104
+ main();
@@ -0,0 +1,114 @@
1
+ import readline from "readline";
2
+ import fs from "fs";
3
+ import { jsonc } from "jsonc";
4
+ import puppeteer from "puppeteer-core";
5
+ // import { PM_Main } from "./PM/main.js";
6
+ // var mode: "DEV" | "PROD" = process.argv[2] === "-dev" ? "DEV" : "PROD";
7
+ // const node2web: Record<string, string[]> = {};
8
+ // const web2node: Record<string, string[]> = {};
9
+ // const childProcesses: Record<string, "loaded" | "running" | "done"> = {};
10
+ readline.emitKeypressEvents(process.stdin);
11
+ if (process.stdin.isTTY)
12
+ process.stdin.setRawMode(true);
13
+ console.log("\n Puppeteer is running. Press 'q' to quit\n");
14
+ process.stdin.on("keypress", (str, key) => {
15
+ if (key.name === "q") {
16
+ process.exit();
17
+ }
18
+ });
19
+ const main = async () => {
20
+ const configs = jsonc.parse((await fs.readFileSync("./docs/testeranto.json")).toString());
21
+ // const pm = new PM_Main(configs);
22
+ // await puppeteer.launch(options);
23
+ const browser = await puppeteer.launch({
24
+ waitForInitialPage: false,
25
+ executablePath: "/opt/homebrew/bin/chromium",
26
+ headless: false,
27
+ args: [
28
+ "--allow-file-access-from-files",
29
+ "--allow-running-insecure-content",
30
+ // "--auto-open-devtools-for-tabs",
31
+ "--disable-dev-shm-usage",
32
+ "--disable-extensions",
33
+ "--disable-gpu",
34
+ "--disable-setuid-sandbox",
35
+ "--disable-site-isolation-trials",
36
+ "--disable-web-security",
37
+ "--disable-web-security",
38
+ "--no-first-run",
39
+ "--no-sandbox",
40
+ "--no-startup-window",
41
+ "--no-zygote",
42
+ "--reduce-security-for-testing",
43
+ "--remote-allow-origins=*",
44
+ // "--remote-allow-origins=ws://localhost:3234",
45
+ "--unsafely-treat-insecure-origin-as-secure=*",
46
+ // "--disable-features=IsolateOrigins",
47
+ // "--single-process",
48
+ // "--unsafely-treat-insecure-origin-as-secure",
49
+ // "--unsafely-treat-insecure-origin-as-secure=ws://192.168.0.101:3234",
50
+ // `--remote-debugging-port=3234`,
51
+ ],
52
+ }
53
+ // "."
54
+ );
55
+ console.log("Creating new page...");
56
+ const page = await browser.newPage();
57
+ await page.setViewport({ width: 0, height: 0 });
58
+ console.log("Requesting url...");
59
+ await page.goto(`file://${process.cwd()}/docs/report.html`);
60
+ // const destinationOfRuntime = (f: string, r: IRunTime) => {
61
+ // return path
62
+ // .normalize(`${configs.buildDir}/${r}/${f}`)
63
+ // .split(".")
64
+ // .slice(0, -1)
65
+ // .join(".");
66
+ // };
67
+ // configs.tests.forEach(([test, runtime, secondaryArtifacts]) => {
68
+ // if (runtime === "node") {
69
+ // pm.launchNode(test, destinationOfRuntime(test, "node"));
70
+ // } else if (runtime === "web") {
71
+ // pm.launchWeb(test, destinationOfRuntime(test, "web"));
72
+ // } else {
73
+ // console.error("runtime makes no sense", runtime);
74
+ // }
75
+ // });
76
+ // console.log("ready and watching for changes...", configs.buildDir);
77
+ // fs.watch(
78
+ // configs.buildDir,
79
+ // {
80
+ // recursive: true,
81
+ // },
82
+ // (eventType, changedFile) => {
83
+ // if (changedFile) {
84
+ // configs.tests.forEach(([test, runtime, secondaryArtifacts]) => {
85
+ // if (eventType === "change" || eventType === "rename") {
86
+ // if (
87
+ // changedFile ===
88
+ // test
89
+ // .replace("./", "node/")
90
+ // .split(".")
91
+ // .slice(0, -1)
92
+ // .concat("mjs")
93
+ // .join(".")
94
+ // ) {
95
+ // pm.launchNode(test, destinationOfRuntime(test, "node"));
96
+ // }
97
+ // if (
98
+ // changedFile ===
99
+ // test
100
+ // .replace("./", "web/")
101
+ // .split(".")
102
+ // .slice(0, -1)
103
+ // .concat("mjs")
104
+ // .join(".")
105
+ // ) {
106
+ // pm.launchWeb(test, destinationOfRuntime(test, "web"));
107
+ // }
108
+ // }
109
+ // });
110
+ // }
111
+ // }
112
+ // );
113
+ };
114
+ main();
@@ -0,0 +1 @@
1
+ "use strict";
@@ -2,7 +2,9 @@ import React from "react";
2
2
  import Testeranto from "../Node.js";
3
3
  export default (testInput, testSpecifications, testImplementations, testInterface) => {
4
4
  return Testeranto(testInput, testSpecifications, testImplementations, Object.assign({ beforeAll(x) {
5
- process.parentPort.postMessage(`/docs/web/src/ClassicalComponent/test.html`);
5
+ // process.parentPort.postMessage(
6
+ // `/docs/web/src/ClassicalComponent/test.html`
7
+ // );
6
8
  return x;
7
9
  }, beforeEach: async () => {
8
10
  return new Promise((resolve, rej) => {
@@ -1,5 +1,5 @@
1
1
  import Testeranto from "../../../Node.js";
2
- import { testInterface as baseInterface } from "./index.js";
2
+ import { testInterface as baseInterface, } from "./index.js";
3
3
  export default (testImplementations, testSpecifications, testInput, testInterface) => {
4
4
  return Testeranto(testInput, testSpecifications, testImplementations, Object.assign(Object.assign({}, baseInterface), testInterface));
5
5
  };
@@ -2,54 +2,107 @@ import { createElement } from "react";
2
2
  import ReactDom from "react-dom/client";
3
3
  import Testeranto from "../../../Web.js";
4
4
  export default (testInput, testSpecifications, testImplementations) => {
5
+ class TesterantoComponent extends testInput {
6
+ constructor(props) {
7
+ super(props);
8
+ this.done = props.done;
9
+ }
10
+ componentDidMount() {
11
+ super.componentDidMount && super.componentDidMount();
12
+ return this.done(this);
13
+ }
14
+ }
15
+ const t = Testeranto(testInput, testSpecifications, testImplementations, {
16
+ beforeAll: async (initialProps, artificer) => {
17
+ console.log("mark5", initialProps);
18
+ return await new Promise((resolve, rej) => {
19
+ const htmlElement = document.getElementById("root");
20
+ if (htmlElement) {
21
+ const domRoot = ReactDom.createRoot(htmlElement);
22
+ // Ignore these type errors
23
+ domRoot.render(createElement(TesterantoComponent, Object.assign(Object.assign({}, initialProps), { done: (reactElement) => {
24
+ resolve({
25
+ htmlElement,
26
+ reactElement,
27
+ domRoot,
28
+ });
29
+ } }), []));
30
+ // resolve({ htmlElement });
31
+ }
32
+ });
33
+ },
34
+ // beforeEach: async (
35
+ // s,
36
+ // initializer,
37
+ // testResource,
38
+ // artificer,
39
+ // initialValues
40
+ // ): Promise<IStore> => {
41
+ // return new Promise((resolve, rej) => {
42
+ // console.log("beforeEach" + TesterantoComponent);
43
+ // // const domRoot = ReactDom.createRoot(htmlElement);
44
+ // // // Ignore these type errors
45
+ // // domRoot.render(
46
+ // // createElement(
47
+ // // TesterantoComponent,
48
+ // // {
49
+ // // ...initializer,
50
+ // // done: (reactElement) => {
51
+ // // resolve({
52
+ // // htmlElement,
53
+ // // reactElement,
54
+ // // domRoot,
55
+ // // });
56
+ // // },
57
+ // // },
58
+ // // []
59
+ // // )
60
+ // // );
61
+ // });
62
+ // },
63
+ andWhen: function (s, whenCB) {
64
+ return whenCB(s);
65
+ },
66
+ butThen: async function (s, thenCB) {
67
+ return thenCB(s);
68
+ },
69
+ afterEach: async function (store, ndx, artificer, utils) {
70
+ console.log("afterEach", store);
71
+ utils.writeFileSync("aftereachlog", store.toString());
72
+ const page = (await utils.browser.pages()).filter((x) => {
73
+ const parsedUrl = new URL(x.url());
74
+ parsedUrl.search = "";
75
+ const strippedUrl = parsedUrl.toString();
76
+ return (strippedUrl ===
77
+ "file:///Users/adam/Code/kokomoBay/docs/web/src/ClassicalComponent/react-dom/client.web.test.html");
78
+ // return true;
79
+ })[0];
80
+ const x = await page.screenshot({
81
+ path: "afterEachLog.jpg",
82
+ });
83
+ console.log("x", x);
84
+ // debugger;
85
+ // const div_root = document.getElementById("root");
86
+ // store.domRoot && store.domRoot.unmount(); //React 18
87
+ // store.remove();
88
+ // store.htmlElement.remove();
89
+ // store.htmlElement = document.createElement("root");
90
+ return store;
91
+ },
92
+ afterAll: async (store, artificer, utils) => {
93
+ // setTimeout(() => {
94
+ // console.log("This will run after 1 second");
95
+ // }, 1000); // 1000 milliseconds = 1 second
96
+ // store.htmlElement.remove();
97
+ // store.htmlElement = document.createElement("root");
98
+ return store;
99
+ },
100
+ });
5
101
  document.addEventListener("DOMContentLoaded", function () {
6
102
  const elem = document.getElementById("root");
7
103
  if (elem) {
8
- class TesterantoComponent extends testInput {
9
- constructor(props) {
10
- super(props);
11
- this.done = props.done;
12
- }
13
- componentDidMount() {
14
- super.componentDidMount && super.componentDidMount();
15
- return this.done(this);
16
- }
17
- }
18
- return Testeranto(testInput, testSpecifications, testImplementations, {
19
- beforeAll: async (initialProps, artificer) => {
20
- console.log("mark5", initialProps);
21
- return await new Promise((resolve, rej) => {
22
- const elem = document.getElementById("root");
23
- if (elem) {
24
- resolve({ htmlElement: elem });
25
- }
26
- });
27
- },
28
- beforeEach: async ({ htmlElement }, initializer, testResource, artificer, initialValues) => {
29
- return new Promise((resolve, rej) => {
30
- // console.log("beforeEach" + JSON.stringify(initializer) + JSON.stringify(initialValues));
31
- // Ignore these type errors
32
- ReactDom.createRoot(htmlElement).render(createElement(TesterantoComponent, Object.assign(Object.assign({}, initializer), { done: (reactElement) => {
33
- resolve({
34
- htmlElement,
35
- reactElement,
36
- });
37
- } }), []));
38
- });
39
- },
40
- andWhen: function (s, whenCB) {
41
- return whenCB(s);
42
- },
43
- butThen: async function (s) {
44
- return s;
45
- },
46
- afterEach: async function (store, ndx, artificer) {
47
- return {};
48
- },
49
- afterAll: (store, artificer) => {
50
- return;
51
- },
52
- });
104
+ return t;
53
105
  }
54
106
  });
107
+ return t;
55
108
  };
@@ -6,7 +6,6 @@ export const testInterface = {
6
6
  return thenCB(s);
7
7
  },
8
8
  beforeEach: function (CComponent, props) {
9
- console.log("ASDASDx");
10
9
  let component;
11
10
  act(() => {
12
11
  component = renderer.create(React.createElement(CComponent, props, []));