testeranto 0.114.1 → 0.121.1

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 (87) hide show
  1. package/README.md +6 -1
  2. package/bundle.js +1 -1
  3. package/dist/common/Init.js +55 -61
  4. package/dist/common/PM/base.js +233 -0
  5. package/dist/common/PM/main.js +217 -434
  6. package/dist/common/build.js +113 -92
  7. package/dist/common/defaultConfig.js +2 -2
  8. package/dist/common/esbuildConfigs/index.js +1 -1
  9. package/dist/common/esbuildConfigs/inputFilesPlugin.js +7 -3
  10. package/dist/common/esbuildConfigs/node.js +5 -3
  11. package/dist/common/esbuildConfigs/web.js +3 -3
  12. package/dist/common/init-docs.js +2 -46
  13. package/dist/common/lib/abstractBase.js +60 -54
  14. package/dist/common/lib/basebuilder.js +7 -8
  15. package/dist/common/lib/classBuilder.js +8 -5
  16. package/dist/common/lib/core.js +6 -18
  17. package/dist/common/lib/index.js +6 -1
  18. package/dist/common/run.js +10 -2
  19. package/dist/common/tsconfig.common.tsbuildinfo +1 -1
  20. package/dist/common/utils.js +9 -21
  21. package/dist/module/Init.js +55 -61
  22. package/dist/module/PM/base.js +226 -0
  23. package/dist/module/PM/main.js +218 -435
  24. package/dist/module/Project.js +117 -0
  25. package/dist/module/TestReport.js +13 -4
  26. package/dist/module/build.js +113 -92
  27. package/dist/module/defaultConfig.js +2 -2
  28. package/dist/module/esbuildConfigs/index.js +1 -1
  29. package/dist/module/esbuildConfigs/inputFilesPlugin.js +7 -3
  30. package/dist/module/esbuildConfigs/node.js +5 -3
  31. package/dist/module/esbuildConfigs/web.js +3 -3
  32. package/dist/module/init-docs.js +2 -13
  33. package/dist/module/lib/abstractBase.js +60 -54
  34. package/dist/module/lib/basebuilder.js +7 -8
  35. package/dist/module/lib/classBuilder.js +8 -5
  36. package/dist/module/lib/core.js +6 -18
  37. package/dist/module/lib/index.js +6 -1
  38. package/dist/module/run.js +10 -2
  39. package/dist/module/tsconfig.module.tsbuildinfo +1 -1
  40. package/dist/module/utils.js +8 -17
  41. package/dist/prebuild/Project.css +11367 -0
  42. package/dist/prebuild/Project.js +24640 -0
  43. package/dist/prebuild/ReportClient.js +1 -1
  44. package/dist/prebuild/TestReport.js +9 -11
  45. package/dist/prebuild/build.mjs +142 -81
  46. package/dist/prebuild/init-docs.mjs +28 -83
  47. package/dist/prebuild/run.mjs +618 -537
  48. package/dist/tsconfig.tsbuildinfo +1 -1
  49. package/dist/types/Init.d.ts +1 -1
  50. package/dist/types/PM/base.d.ts +38 -0
  51. package/dist/types/PM/main.d.ts +20 -44
  52. package/dist/types/esbuildConfigs/inputFilesPlugin.d.ts +1 -1
  53. package/dist/types/esbuildConfigs/node.d.ts +1 -1
  54. package/dist/types/esbuildConfigs/web.d.ts +1 -1
  55. package/dist/types/lib/abstractBase.d.ts +19 -11
  56. package/dist/types/lib/basebuilder.d.ts +1 -2
  57. package/dist/types/lib/index.d.ts +3 -3
  58. package/dist/types/lib/types.d.ts +2 -5
  59. package/dist/types/tsconfig.types.tsbuildinfo +1 -1
  60. package/dist/types/utils.d.ts +4 -7
  61. package/package.json +6 -5
  62. package/src/Init.ts +60 -68
  63. package/src/PM/base.ts +301 -0
  64. package/src/PM/main.ts +276 -567
  65. package/src/Project.tsx +197 -0
  66. package/src/ReportClient.tsx +1 -1
  67. package/src/TestReport.tsx +30 -15
  68. package/src/build.ts +140 -104
  69. package/src/defaultConfig.ts +2 -2
  70. package/src/esbuildConfigs/index.ts +1 -1
  71. package/src/esbuildConfigs/inputFilesPlugin.ts +7 -6
  72. package/src/esbuildConfigs/node.ts +5 -3
  73. package/src/esbuildConfigs/web.ts +4 -3
  74. package/src/init-docs.ts +2 -15
  75. package/src/lib/abstractBase.ts +113 -93
  76. package/src/lib/basebuilder.ts +8 -9
  77. package/src/lib/classBuilder.ts +11 -10
  78. package/src/lib/core.ts +15 -27
  79. package/src/lib/index.ts +13 -6
  80. package/src/lib/types.ts +3 -8
  81. package/src/run.ts +21 -5
  82. package/src/utils.ts +27 -39
  83. package/tsc.log +12 -23
  84. package/dist/common/puppeteerConfiger.js +0 -24
  85. package/dist/module/puppeteerConfiger.js +0 -19
  86. package/dist/types/puppeteerConfiger.d.ts +0 -4
  87. package/src/puppeteerConfiger.ts +0 -26
@@ -6,10 +6,7 @@ export type ISummary = Record<string, {
6
6
  prompt?: string | "?";
7
7
  }>;
8
8
  export declare const destinationOfRuntime: (f: string, r: IRunTime, configs: IBuiltConfig) => string;
9
- export declare const tscPather: (entryPoint: string, platform: "web" | "node") => string;
10
- export declare const tscExitCodePather: (entryPoint: string, platform: "web" | "node") => string;
11
- export declare const lintPather: (entryPoint: string, platform: "web" | "node") => string;
12
- export declare const lintExitCodePather: (entryPoint: string, platform: "web" | "node") => string;
13
- export declare const bddPather: (entryPoint: string, platform: "web" | "node") => string;
14
- export declare const bddExitCodePather: (entryPoint: string, platform: "web" | "node") => string;
15
- export declare const promptPather: (entryPoint: string, platform: "web" | "node") => string;
9
+ export declare const tscPather: (entryPoint: string, platform: "web" | "node", projectName: string) => string;
10
+ export declare const lintPather: (entryPoint: string, platform: "web" | "node", projectName: string) => string;
11
+ export declare const bddPather: (entryPoint: string, platform: "web" | "node", projectName: string) => string;
12
+ export declare const promptPather: (entryPoint: string, platform: "web" | "node", projectName: string) => string;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "testeranto",
3
3
  "description": "the AI powered BDD test framework for typescript projects",
4
- "version": "0.114.1",
4
+ "version": "0.121.1",
5
5
  "engines": {
6
6
  "node": "18.18.0"
7
7
  },
@@ -22,16 +22,16 @@
22
22
  "require": "./dist/common/SubPackages/puppeteer.js"
23
23
  },
24
24
  "./src/SubPackages/react/jsx/index": {
25
- "import": "./dist/module/SubPackages/react/jsx/index.js",
26
- "require": "./dist/common/SubPackages/react/jsx/index.js"
25
+ "import": "./src/SubPackages/react/jsx/index.ts",
26
+ "require": "./src/SubPackages/react/jsx/index.ts"
27
27
  },
28
28
  "./src/SubPackages/react/jsx/web": {
29
29
  "import": "./src/SubPackages/react/jsx/web.ts",
30
30
  "require": "./src/SubPackages/react/jsx/web.ts"
31
31
  },
32
32
  "./src/SubPackages/react/jsx/node": {
33
- "import": "./dist/module/SubPackages/react/jsx/node.js",
34
- "require": "./dist/common/SubPackages/react/jsx/node.js"
33
+ "import": "./src/SubPackages/react/jsx/node.ts",
34
+ "require": "./src/SubPackages/react/jsx/node.ts"
35
35
  },
36
36
  "./src/SubPackages/react/component/index": {
37
37
  "import": "./dist/module/SubPackages/react/component/index.js",
@@ -242,6 +242,7 @@
242
242
  "fs-extra": "^11.2.0",
243
243
  "fs.promises.exists": "^1.1.4",
244
244
  "glob": "^10.3.12",
245
+ "is-path-inside": "^4.0.0",
245
246
  "iterm-tab": "^0.4.0",
246
247
  "live-server": "^1.2.2",
247
248
  "node-static": "^0.7.11",
package/src/Init.ts CHANGED
@@ -1,96 +1,88 @@
1
1
  import fs from "fs";
2
2
 
3
- export default async (partialConfig) => {
4
- const config = {
5
- ...partialConfig,
6
- buildDir: process.cwd() + "/" + partialConfig.outdir,
7
- };
3
+ export default async () => {
4
+ [
5
+ `testeranto/`,
6
+ `testeranto/bundles/`,
7
+ `testeranto/bundles/node`,
8
+ `testeranto/bundles/web`,
9
+ `testeranto/reports`,
10
+ `testeranto/reports/`,
11
+ `testeranto/features/`,
12
+ ].forEach((f) => {
13
+ try {
14
+ fs.mkdirSync(`${process.cwd()}/${f}`);
15
+ } catch (e) {
16
+ // console.error(e);
17
+ }
18
+ });
8
19
 
9
- try {
10
- fs.mkdirSync(`${process.cwd()}/${config.outdir}`);
11
- } catch {
12
- // console.log()
13
- }
20
+ // fs.writeFileSync(
21
+ // `${process.cwd()}/testeranto/index.html`,
22
+ // `
23
+ // <!DOCTYPE html>
24
+ // <html lang="en">
14
25
 
15
- fs.writeFileSync(
16
- `${config.outdir}/index.html`,
17
- `
18
- <!DOCTYPE html>
19
- <html lang="en">
26
+ // <head>
27
+ // <meta name="description" content="Webpage description goes here" />
28
+ // <meta charset="utf-8" />
29
+ // <title>kokomoBay - testeranto</title>
30
+ // <meta name="viewport" content="width=device-width, initial-scale=1" />
31
+ // <meta name="author" content="" />
20
32
 
21
- <head>
22
- <meta name="description" content="Webpage description goes here" />
23
- <meta charset="utf-8" />
24
- <title>kokomoBay - testeranto</title>
25
- <meta name="viewport" content="width=device-width, initial-scale=1" />
26
- <meta name="author" content="" />
33
+ // <script type="module" src="/kokomoBay/testeranto/Project.js"></script>
27
34
 
28
- <link rel="stylesheet" href="/kokomoBay/docs/ReportClient.css" />
29
- <script type="module" src="/kokomoBay/docs/ReportClient.js"></script>
35
+ // </head>
30
36
 
31
- </head>
37
+ // <body>
38
+ // <div id="root">
39
+ // react is loading
40
+ // </div>
41
+ // </body>
32
42
 
33
- <body>
34
- <div id="root">
35
- react is loading
36
- </div>
37
- </body>
43
+ // </html>
44
+ // `
45
+ // );
38
46
 
39
- </html>
40
- `
47
+ fs.copyFileSync(
48
+ `node_modules/testeranto/dist/prebuild/Project.js`,
49
+ `testeranto/Project.js`
41
50
  );
42
51
 
43
52
  fs.copyFileSync(
44
53
  `node_modules/testeranto/dist/prebuild/ReportClient.js`,
45
- `${config.outdir}/ReportClient.js`
54
+ `testeranto/ReportClient.js`
55
+ );
56
+
57
+ fs.copyFileSync(
58
+ `node_modules/testeranto/dist/prebuild/Project.css`,
59
+ `testeranto/Project.css`
46
60
  );
47
61
 
48
62
  fs.copyFileSync(
49
63
  `node_modules/testeranto/dist/prebuild/ReportClient.css`,
50
- `${config.outdir}/ReportClient.css`
64
+ `testeranto/ReportClient.css`
51
65
  );
52
66
 
53
67
  fs.copyFileSync(
54
68
  `node_modules/testeranto/dist/prebuild/TestReport.js`,
55
- `${config.outdir}/TestReport.js`
69
+ `testeranto/TestReport.js`
56
70
  );
57
71
 
58
72
  fs.copyFileSync(
59
73
  `node_modules/testeranto/dist/prebuild/TestReport.css`,
60
- `${config.outdir}/TestReport.css`
74
+ `testeranto/TestReport.css`
61
75
  );
62
76
 
63
- fs.writeFileSync(
64
- `${config.outdir}/testeranto.json`,
65
- JSON.stringify(
66
- {
67
- ...config,
68
- buildDir: process.cwd() + "/" + config.outdir,
69
- },
70
- null,
71
- 2
72
- )
73
- );
74
-
75
- try {
76
- fs.mkdirSync(`${process.cwd()}/${config.outdir}/node`);
77
- } catch {
78
- // console.log()
79
- }
80
-
81
- try {
82
- fs.mkdirSync(`${process.cwd()}/${config.outdir}/web`);
83
- } catch {
84
- // console.log()
85
- }
86
- try {
87
- fs.mkdirSync(`${process.cwd()}/${config.outdir}/features`);
88
- } catch {
89
- // console.log()
90
- }
91
- try {
92
- fs.mkdirSync(`${process.cwd()}/${config.outdir}/ts`);
93
- } catch {
94
- // console.log()
95
- }
77
+ // fs.writeFileSync(
78
+ // `${config.outdir}/testeranto.json`,
79
+ // JSON.stringify(
80
+ // {
81
+ // ...config,
82
+ // buildDir: process.cwd() + "/" + config.outdir,
83
+ // },
84
+ // null,
85
+ // 2
86
+ // )
87
+ // );
96
88
  };
package/src/PM/base.ts ADDED
@@ -0,0 +1,301 @@
1
+ import { CdpPage } from "puppeteer-core/lib/esm/puppeteer";
2
+ import fs from "fs";
3
+ import path from "path";
4
+ import { Browser, ScreenRecorder, ScreenshotOptions } from "puppeteer-core";
5
+ import { PassThrough } from "stream";
6
+
7
+ import { IBuiltConfig, ITLog } from "../lib/index.js";
8
+
9
+ import { PM } from "./index.js";
10
+
11
+ const fileStreams3: fs.WriteStream[] = [];
12
+ type IFPaths = string[];
13
+ const fPaths: IFPaths = [];
14
+ const files: Record<string, Set<string>> = {};
15
+ const recorders: Record<string, ScreenRecorder> = {};
16
+ const screenshots: Record<string, Promise<Uint8Array>[]> = {};
17
+
18
+ export abstract class PM_Base extends PM {
19
+ browser: Browser;
20
+ configs: IBuiltConfig;
21
+
22
+ constructor(configs: IBuiltConfig) {
23
+ super();
24
+ this.server = {};
25
+ this.configs = configs;
26
+
27
+ globalThis["waitForSelector"] = async (pageKey: string, sel: string) => {
28
+ const page = (await this.browser.pages()).find(
29
+ /* @ts-ignore:next-line */
30
+ (p) => p.mainFrame()._id === pageKey
31
+ );
32
+ await page?.waitForSelector(sel);
33
+ };
34
+
35
+ globalThis["screencastStop"] = async (path: string) => {
36
+ return recorders[path].stop();
37
+ };
38
+
39
+ globalThis["closePage"] = async (pageKey) => {
40
+ const page = (await this.browser.pages()).find(
41
+ /* @ts-ignore:next-line */
42
+ (p) => p.mainFrame()._id === pageKey
43
+ );
44
+ /* @ts-ignore:next-line */
45
+ return page.close();
46
+ };
47
+
48
+ globalThis["goto"] = async (pageKey: string, url: string) => {
49
+ const page = (await this.browser.pages()).find(
50
+ /* @ts-ignore:next-line */
51
+ (p) => p.mainFrame()._id === pageKey
52
+ );
53
+ await page?.goto(url);
54
+ return;
55
+ };
56
+
57
+ globalThis["newPage"] = () => {
58
+ return this.browser.newPage();
59
+ };
60
+
61
+ globalThis["pages"] = () => {
62
+ return this.browser.pages();
63
+ };
64
+
65
+ globalThis["mkdirSync"] = (fp: string) => {
66
+ if (!fs.existsSync(fp)) {
67
+ return fs.mkdirSync(fp, {
68
+ recursive: true,
69
+ });
70
+ }
71
+ return false;
72
+ };
73
+
74
+ globalThis["writeFileSync"] = (
75
+ filepath: string,
76
+ contents: string,
77
+ testName: string
78
+ ) => {
79
+ fs.mkdirSync(path.dirname(filepath), {
80
+ recursive: true,
81
+ });
82
+ if (!files[testName]) {
83
+ files[testName] = new Set();
84
+ }
85
+ files[testName].add(filepath);
86
+ return fs.writeFileSync(filepath, contents);
87
+ };
88
+
89
+ globalThis["createWriteStream"] = (filepath: string, testName: string) => {
90
+ const f = fs.createWriteStream(filepath);
91
+ fileStreams3.push(f);
92
+ // files.add(filepath);
93
+ if (!files[testName]) {
94
+ files[testName] = new Set();
95
+ }
96
+ files[testName].add(filepath);
97
+ return {
98
+ ...JSON.parse(JSON.stringify(f)),
99
+ uid: fileStreams3.length - 1,
100
+ };
101
+ };
102
+
103
+ globalThis["write"] = (uid: number, contents: string) => {
104
+ fileStreams3[uid].write(contents);
105
+ };
106
+
107
+ globalThis["end"] = (uid: number) => {
108
+ fileStreams3[uid].end();
109
+ };
110
+
111
+ globalThis["customScreenShot"] = async (
112
+ opts: { path: string },
113
+ pageKey: string,
114
+ testName: string
115
+ ) => {
116
+ const page = (await this.browser.pages()).find(
117
+ /* @ts-ignore:next-line */
118
+ (p) => p.mainFrame()._id === pageKey
119
+ );
120
+
121
+ const p = opts.path as string;
122
+ const dir = path.dirname(p);
123
+ fs.mkdirSync(dir, {
124
+ recursive: true,
125
+ });
126
+ if (!files[opts.path]) {
127
+ files[opts.path] = new Set();
128
+ }
129
+ files[opts.path].add(opts.path as string);
130
+
131
+ /* @ts-ignore:next-line */
132
+ const sPromise = page.screenshot({
133
+ ...opts,
134
+ path: p,
135
+ });
136
+
137
+ if (!screenshots[opts.path]) {
138
+ screenshots[opts.path] = [];
139
+ }
140
+ screenshots[opts.path].push(sPromise);
141
+
142
+ await sPromise;
143
+ return sPromise;
144
+ };
145
+
146
+ globalThis["screencast"] = async (
147
+ opts: ScreenshotOptions,
148
+ pageKey: string
149
+ ) => {
150
+ const page = (await this.browser.pages()).find(
151
+ /* @ts-ignore:next-line */
152
+ (p) => p.mainFrame()._id === pageKey
153
+ );
154
+
155
+ const p = opts.path as string;
156
+ const dir = path.dirname(p);
157
+ fs.mkdirSync(dir, {
158
+ recursive: true,
159
+ });
160
+
161
+ const recorder = await page?.screencast({
162
+ ...opts,
163
+ /* @ts-ignore:next-line */
164
+ path: p,
165
+ });
166
+
167
+ /* @ts-ignore:next-line */
168
+ recorders[opts.path] = recorder;
169
+
170
+ return opts.path;
171
+ };
172
+ }
173
+
174
+ customclose() {
175
+ throw new Error("Method not implemented.");
176
+ }
177
+ waitForSelector(p: string, s: string): any {
178
+ throw new Error("Method not implemented.");
179
+ }
180
+ closePage(p): any {
181
+ throw new Error("Method not implemented.");
182
+ }
183
+ newPage(): CdpPage {
184
+ throw new Error("Method not implemented.");
185
+ }
186
+ goto(p, url: string): any {
187
+ throw new Error("Method not implemented.");
188
+ }
189
+ $(selector: string): boolean {
190
+ throw new Error("Method not implemented.");
191
+ }
192
+ screencast(opts: object) {
193
+ throw new Error("Method not implemented.");
194
+ }
195
+ /* @ts-ignore:next-line */
196
+ customScreenShot(opts: object, cdpPage?: CdpPage) {
197
+ throw new Error("Method not implemented.");
198
+ }
199
+ end(accessObject: { uid: number }): boolean {
200
+ throw new Error("Method not implemented.");
201
+ }
202
+ existsSync(destFolder: string): boolean {
203
+ return fs.existsSync(destFolder);
204
+ }
205
+
206
+ async mkdirSync(fp: string) {
207
+ if (!fs.existsSync(fp)) {
208
+ return fs.mkdirSync(fp, {
209
+ recursive: true,
210
+ });
211
+ }
212
+ return false;
213
+ }
214
+
215
+ writeFileSync(fp: string, contents: string) {
216
+ fs.writeFileSync(fp, contents);
217
+ }
218
+
219
+ createWriteStream(filepath: string): fs.WriteStream {
220
+ return fs.createWriteStream(filepath);
221
+ }
222
+
223
+ testArtiFactoryfileWriter(tLog: ITLog, callback: (Promise) => void) {
224
+ return (fPath, value: string | Buffer | PassThrough) => {
225
+ callback(
226
+ new Promise<void>((res, rej) => {
227
+ tLog("testArtiFactory =>", fPath);
228
+
229
+ const cleanPath = path.resolve(fPath);
230
+ fPaths.push(cleanPath.replace(process.cwd(), ``));
231
+
232
+ const targetDir = cleanPath.split("/").slice(0, -1).join("/");
233
+
234
+ fs.mkdir(targetDir, { recursive: true }, async (error) => {
235
+ if (error) {
236
+ console.error(`❗️testArtiFactory failed`, targetDir, error);
237
+ }
238
+
239
+ fs.writeFileSync(
240
+ path.resolve(
241
+ targetDir.split("/").slice(0, -1).join("/"),
242
+ "manifest"
243
+ ),
244
+ fPaths.join(`\n`),
245
+ {
246
+ encoding: "utf-8",
247
+ }
248
+ );
249
+
250
+ if (Buffer.isBuffer(value)) {
251
+ fs.writeFileSync(fPath, value, "binary");
252
+ res();
253
+ } else if (`string` === typeof value) {
254
+ fs.writeFileSync(fPath, value.toString(), {
255
+ encoding: "utf-8",
256
+ });
257
+ res();
258
+ } else {
259
+ /* @ts-ignore:next-line */
260
+ const pipeStream: PassThrough = value;
261
+ const myFile = fs.createWriteStream(fPath);
262
+ pipeStream.pipe(myFile);
263
+ pipeStream.on("close", () => {
264
+ myFile.close();
265
+ res();
266
+ });
267
+ }
268
+ });
269
+ })
270
+ );
271
+ };
272
+ }
273
+
274
+ write(accessObject: { uid: number }, contents: string): boolean {
275
+ throw new Error("Method not implemented.");
276
+ }
277
+ page(): string | undefined {
278
+ throw new Error("Method not implemented.");
279
+ }
280
+ click(selector: string): string | undefined {
281
+ throw new Error("Method not implemented.");
282
+ }
283
+ focusOn(selector: string) {
284
+ throw new Error("Method not implemented.");
285
+ }
286
+ typeInto(value: string) {
287
+ throw new Error("Method not implemented.");
288
+ }
289
+ getValue(value: string) {
290
+ throw new Error("Method not implemented.");
291
+ }
292
+ getAttribute(selector: string, attribute: string) {
293
+ throw new Error("Method not implemented.");
294
+ }
295
+ isDisabled(selector: string): Promise<boolean> {
296
+ throw new Error("Method not implemented.");
297
+ }
298
+ screencastStop(s: string) {
299
+ throw new Error("Method not implemented.");
300
+ }
301
+ }