testeranto 0.113.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 -2
  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 +7 -6
  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
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.promptPather = exports.bddExitCodePather = exports.bddPather = exports.lintExitCodePather = exports.lintPather = exports.tscExitCodePather = exports.tscPather = exports.destinationOfRuntime = void 0;
6
+ exports.promptPather = exports.bddPather = exports.lintPather = exports.tscPather = exports.destinationOfRuntime = void 0;
7
7
  const path_1 = __importDefault(require("path"));
8
8
  const destinationOfRuntime = (f, r, configs) => {
9
9
  return path_1.default
@@ -13,31 +13,19 @@ const destinationOfRuntime = (f, r, configs) => {
13
13
  .join(".");
14
14
  };
15
15
  exports.destinationOfRuntime = destinationOfRuntime;
16
- const tscPather = (entryPoint, platform) => {
17
- return path_1.default.join("./docs/", platform, entryPoint.split(".").slice(0, -1).join("."), `type_errors.txt`);
16
+ const tscPather = (entryPoint, platform, projectName) => {
17
+ return path_1.default.join("testeranto", "reports", projectName, entryPoint.split(".").slice(0, -1).join("."), platform, `type_errors.txt`);
18
18
  };
19
19
  exports.tscPather = tscPather;
20
- const tscExitCodePather = (entryPoint, platform) => {
21
- return path_1.default.join("./docs/", platform, entryPoint.split(".").slice(0, -1).join("."), `type_errors.txt`);
22
- };
23
- exports.tscExitCodePather = tscExitCodePather;
24
- const lintPather = (entryPoint, platform) => {
25
- return path_1.default.join("./docs/", platform, entryPoint.split(".").slice(0, -1).join("."), `lint_errors.json`);
20
+ const lintPather = (entryPoint, platform, projectName) => {
21
+ return path_1.default.join("testeranto", "reports", projectName, entryPoint.split(".").slice(0, -1).join("."), platform, `lint_errors.json`);
26
22
  };
27
23
  exports.lintPather = lintPather;
28
- const lintExitCodePather = (entryPoint, platform) => {
29
- return path_1.default.join("./docs/", platform, entryPoint.split(".").slice(0, -1).join("."), `lint_errors.txt`);
30
- };
31
- exports.lintExitCodePather = lintExitCodePather;
32
- const bddPather = (entryPoint, platform) => {
33
- return path_1.default.join("./docs/", platform, entryPoint.split(".").slice(0, -1).join("."), `tests.json`);
24
+ const bddPather = (entryPoint, platform, projectName) => {
25
+ return path_1.default.join("testeranto", "reports", projectName, entryPoint.split(".").slice(0, -1).join("."), platform, `tests.json`);
34
26
  };
35
27
  exports.bddPather = bddPather;
36
- const bddExitCodePather = (entryPoint, platform) => {
37
- return path_1.default.join("./docs/", platform, entryPoint.split(".").slice(0, -1).join("."), `bdd_errors.txt`);
38
- };
39
- exports.bddExitCodePather = bddExitCodePather;
40
- const promptPather = (entryPoint, platform) => {
41
- return path_1.default.join("./docs/", platform, entryPoint.split(".").slice(0, -1).join("."), `prompt.txt`);
28
+ const promptPather = (entryPoint, platform, projectName) => {
29
+ return path_1.default.join("testeranto", "reports", projectName, entryPoint.split(".").slice(0, -1).join("."), platform, `prompt.txt`);
42
30
  };
43
31
  exports.promptPather = promptPather;
@@ -1,63 +1,57 @@
1
1
  import fs from "fs";
2
- export default async (partialConfig) => {
3
- const config = Object.assign(Object.assign({}, partialConfig), { buildDir: process.cwd() + "/" + partialConfig.outdir });
4
- try {
5
- fs.mkdirSync(`${process.cwd()}/${config.outdir}`);
6
- }
7
- catch (_a) {
8
- // console.log()
9
- }
10
- fs.writeFileSync(`${config.outdir}/index.html`, `
11
- <!DOCTYPE html>
12
- <html lang="en">
13
-
14
- <head>
15
- <meta name="description" content="Webpage description goes here" />
16
- <meta charset="utf-8" />
17
- <title>kokomoBay - testeranto</title>
18
- <meta name="viewport" content="width=device-width, initial-scale=1" />
19
- <meta name="author" content="" />
20
-
21
- <link rel="stylesheet" href="/kokomoBay/docs/ReportClient.css" />
22
- <script type="module" src="/kokomoBay/docs/ReportClient.js"></script>
23
-
24
- </head>
25
-
26
- <body>
27
- <div id="root">
28
- react is loading
29
- </div>
30
- </body>
31
-
32
- </html>
33
- `);
34
- fs.copyFileSync(`node_modules/testeranto/dist/prebuild/ReportClient.js`, `${config.outdir}/ReportClient.js`);
35
- fs.copyFileSync(`node_modules/testeranto/dist/prebuild/ReportClient.css`, `${config.outdir}/ReportClient.css`);
36
- fs.copyFileSync(`node_modules/testeranto/dist/prebuild/TestReport.js`, `${config.outdir}/TestReport.js`);
37
- fs.copyFileSync(`node_modules/testeranto/dist/prebuild/TestReport.css`, `${config.outdir}/TestReport.css`);
38
- fs.writeFileSync(`${config.outdir}/testeranto.json`, JSON.stringify(Object.assign(Object.assign({}, config), { buildDir: process.cwd() + "/" + config.outdir }), null, 2));
39
- try {
40
- fs.mkdirSync(`${process.cwd()}/${config.outdir}/node`);
41
- }
42
- catch (_b) {
43
- // console.log()
44
- }
45
- try {
46
- fs.mkdirSync(`${process.cwd()}/${config.outdir}/web`);
47
- }
48
- catch (_c) {
49
- // console.log()
50
- }
51
- try {
52
- fs.mkdirSync(`${process.cwd()}/${config.outdir}/features`);
53
- }
54
- catch (_d) {
55
- // console.log()
56
- }
57
- try {
58
- fs.mkdirSync(`${process.cwd()}/${config.outdir}/ts`);
59
- }
60
- catch (_e) {
61
- // console.log()
62
- }
2
+ export default async () => {
3
+ [
4
+ `testeranto/`,
5
+ `testeranto/bundles/`,
6
+ `testeranto/bundles/node`,
7
+ `testeranto/bundles/web`,
8
+ `testeranto/reports`,
9
+ `testeranto/reports/`,
10
+ `testeranto/features/`,
11
+ ].forEach((f) => {
12
+ try {
13
+ fs.mkdirSync(`${process.cwd()}/${f}`);
14
+ }
15
+ catch (e) {
16
+ // console.error(e);
17
+ }
18
+ });
19
+ // fs.writeFileSync(
20
+ // `${process.cwd()}/testeranto/index.html`,
21
+ // `
22
+ // <!DOCTYPE html>
23
+ // <html lang="en">
24
+ // <head>
25
+ // <meta name="description" content="Webpage description goes here" />
26
+ // <meta charset="utf-8" />
27
+ // <title>kokomoBay - testeranto</title>
28
+ // <meta name="viewport" content="width=device-width, initial-scale=1" />
29
+ // <meta name="author" content="" />
30
+ // <script type="module" src="/kokomoBay/testeranto/Project.js"></script>
31
+ // </head>
32
+ // <body>
33
+ // <div id="root">
34
+ // react is loading
35
+ // </div>
36
+ // </body>
37
+ // </html>
38
+ // `
39
+ // );
40
+ fs.copyFileSync(`node_modules/testeranto/dist/prebuild/Project.js`, `testeranto/Project.js`);
41
+ fs.copyFileSync(`node_modules/testeranto/dist/prebuild/ReportClient.js`, `testeranto/ReportClient.js`);
42
+ fs.copyFileSync(`node_modules/testeranto/dist/prebuild/Project.css`, `testeranto/Project.css`);
43
+ fs.copyFileSync(`node_modules/testeranto/dist/prebuild/ReportClient.css`, `testeranto/ReportClient.css`);
44
+ fs.copyFileSync(`node_modules/testeranto/dist/prebuild/TestReport.js`, `testeranto/TestReport.js`);
45
+ fs.copyFileSync(`node_modules/testeranto/dist/prebuild/TestReport.css`, `testeranto/TestReport.css`);
46
+ // fs.writeFileSync(
47
+ // `${config.outdir}/testeranto.json`,
48
+ // JSON.stringify(
49
+ // {
50
+ // ...config,
51
+ // buildDir: process.cwd() + "/" + config.outdir,
52
+ // },
53
+ // null,
54
+ // 2
55
+ // )
56
+ // );
63
57
  };
@@ -0,0 +1,226 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+ import { PM } from "./index.js";
4
+ const fileStreams3 = [];
5
+ const fPaths = [];
6
+ const files = {};
7
+ const recorders = {};
8
+ const screenshots = {};
9
+ export class PM_Base extends PM {
10
+ constructor(configs) {
11
+ super();
12
+ this.server = {};
13
+ this.configs = configs;
14
+ globalThis["waitForSelector"] = async (pageKey, sel) => {
15
+ const page = (await this.browser.pages()).find(
16
+ /* @ts-ignore:next-line */
17
+ (p) => p.mainFrame()._id === pageKey);
18
+ await (page === null || page === void 0 ? void 0 : page.waitForSelector(sel));
19
+ };
20
+ globalThis["screencastStop"] = async (path) => {
21
+ return recorders[path].stop();
22
+ };
23
+ globalThis["closePage"] = async (pageKey) => {
24
+ const page = (await this.browser.pages()).find(
25
+ /* @ts-ignore:next-line */
26
+ (p) => p.mainFrame()._id === pageKey);
27
+ /* @ts-ignore:next-line */
28
+ return page.close();
29
+ };
30
+ globalThis["goto"] = async (pageKey, url) => {
31
+ const page = (await this.browser.pages()).find(
32
+ /* @ts-ignore:next-line */
33
+ (p) => p.mainFrame()._id === pageKey);
34
+ await (page === null || page === void 0 ? void 0 : page.goto(url));
35
+ return;
36
+ };
37
+ globalThis["newPage"] = () => {
38
+ return this.browser.newPage();
39
+ };
40
+ globalThis["pages"] = () => {
41
+ return this.browser.pages();
42
+ };
43
+ globalThis["mkdirSync"] = (fp) => {
44
+ if (!fs.existsSync(fp)) {
45
+ return fs.mkdirSync(fp, {
46
+ recursive: true,
47
+ });
48
+ }
49
+ return false;
50
+ };
51
+ globalThis["writeFileSync"] = (filepath, contents, testName) => {
52
+ fs.mkdirSync(path.dirname(filepath), {
53
+ recursive: true,
54
+ });
55
+ if (!files[testName]) {
56
+ files[testName] = new Set();
57
+ }
58
+ files[testName].add(filepath);
59
+ return fs.writeFileSync(filepath, contents);
60
+ };
61
+ globalThis["createWriteStream"] = (filepath, testName) => {
62
+ const f = fs.createWriteStream(filepath);
63
+ fileStreams3.push(f);
64
+ // files.add(filepath);
65
+ if (!files[testName]) {
66
+ files[testName] = new Set();
67
+ }
68
+ files[testName].add(filepath);
69
+ return Object.assign(Object.assign({}, JSON.parse(JSON.stringify(f))), { uid: fileStreams3.length - 1 });
70
+ };
71
+ globalThis["write"] = (uid, contents) => {
72
+ fileStreams3[uid].write(contents);
73
+ };
74
+ globalThis["end"] = (uid) => {
75
+ fileStreams3[uid].end();
76
+ };
77
+ globalThis["customScreenShot"] = async (opts, pageKey, testName) => {
78
+ const page = (await this.browser.pages()).find(
79
+ /* @ts-ignore:next-line */
80
+ (p) => p.mainFrame()._id === pageKey);
81
+ const p = opts.path;
82
+ const dir = path.dirname(p);
83
+ fs.mkdirSync(dir, {
84
+ recursive: true,
85
+ });
86
+ if (!files[opts.path]) {
87
+ files[opts.path] = new Set();
88
+ }
89
+ files[opts.path].add(opts.path);
90
+ /* @ts-ignore:next-line */
91
+ const sPromise = page.screenshot(Object.assign(Object.assign({}, opts), { path: p }));
92
+ if (!screenshots[opts.path]) {
93
+ screenshots[opts.path] = [];
94
+ }
95
+ screenshots[opts.path].push(sPromise);
96
+ await sPromise;
97
+ return sPromise;
98
+ };
99
+ globalThis["screencast"] = async (opts, pageKey) => {
100
+ const page = (await this.browser.pages()).find(
101
+ /* @ts-ignore:next-line */
102
+ (p) => p.mainFrame()._id === pageKey);
103
+ const p = opts.path;
104
+ const dir = path.dirname(p);
105
+ fs.mkdirSync(dir, {
106
+ recursive: true,
107
+ });
108
+ const recorder = await (page === null || page === void 0 ? void 0 : page.screencast(Object.assign(Object.assign({}, opts), {
109
+ /* @ts-ignore:next-line */
110
+ path: p })));
111
+ /* @ts-ignore:next-line */
112
+ recorders[opts.path] = recorder;
113
+ return opts.path;
114
+ };
115
+ }
116
+ customclose() {
117
+ throw new Error("Method not implemented.");
118
+ }
119
+ waitForSelector(p, s) {
120
+ throw new Error("Method not implemented.");
121
+ }
122
+ closePage(p) {
123
+ throw new Error("Method not implemented.");
124
+ }
125
+ newPage() {
126
+ throw new Error("Method not implemented.");
127
+ }
128
+ goto(p, url) {
129
+ throw new Error("Method not implemented.");
130
+ }
131
+ $(selector) {
132
+ throw new Error("Method not implemented.");
133
+ }
134
+ screencast(opts) {
135
+ throw new Error("Method not implemented.");
136
+ }
137
+ /* @ts-ignore:next-line */
138
+ customScreenShot(opts, cdpPage) {
139
+ throw new Error("Method not implemented.");
140
+ }
141
+ end(accessObject) {
142
+ throw new Error("Method not implemented.");
143
+ }
144
+ existsSync(destFolder) {
145
+ return fs.existsSync(destFolder);
146
+ }
147
+ async mkdirSync(fp) {
148
+ if (!fs.existsSync(fp)) {
149
+ return fs.mkdirSync(fp, {
150
+ recursive: true,
151
+ });
152
+ }
153
+ return false;
154
+ }
155
+ writeFileSync(fp, contents) {
156
+ fs.writeFileSync(fp, contents);
157
+ }
158
+ createWriteStream(filepath) {
159
+ return fs.createWriteStream(filepath);
160
+ }
161
+ testArtiFactoryfileWriter(tLog, callback) {
162
+ return (fPath, value) => {
163
+ callback(new Promise((res, rej) => {
164
+ tLog("testArtiFactory =>", fPath);
165
+ const cleanPath = path.resolve(fPath);
166
+ fPaths.push(cleanPath.replace(process.cwd(), ``));
167
+ const targetDir = cleanPath.split("/").slice(0, -1).join("/");
168
+ fs.mkdir(targetDir, { recursive: true }, async (error) => {
169
+ if (error) {
170
+ console.error(`❗️testArtiFactory failed`, targetDir, error);
171
+ }
172
+ fs.writeFileSync(path.resolve(targetDir.split("/").slice(0, -1).join("/"), "manifest"), fPaths.join(`\n`), {
173
+ encoding: "utf-8",
174
+ });
175
+ if (Buffer.isBuffer(value)) {
176
+ fs.writeFileSync(fPath, value, "binary");
177
+ res();
178
+ }
179
+ else if (`string` === typeof value) {
180
+ fs.writeFileSync(fPath, value.toString(), {
181
+ encoding: "utf-8",
182
+ });
183
+ res();
184
+ }
185
+ else {
186
+ /* @ts-ignore:next-line */
187
+ const pipeStream = value;
188
+ const myFile = fs.createWriteStream(fPath);
189
+ pipeStream.pipe(myFile);
190
+ pipeStream.on("close", () => {
191
+ myFile.close();
192
+ res();
193
+ });
194
+ }
195
+ });
196
+ }));
197
+ };
198
+ }
199
+ write(accessObject, contents) {
200
+ throw new Error("Method not implemented.");
201
+ }
202
+ page() {
203
+ throw new Error("Method not implemented.");
204
+ }
205
+ click(selector) {
206
+ throw new Error("Method not implemented.");
207
+ }
208
+ focusOn(selector) {
209
+ throw new Error("Method not implemented.");
210
+ }
211
+ typeInto(value) {
212
+ throw new Error("Method not implemented.");
213
+ }
214
+ getValue(value) {
215
+ throw new Error("Method not implemented.");
216
+ }
217
+ getAttribute(selector, attribute) {
218
+ throw new Error("Method not implemented.");
219
+ }
220
+ isDisabled(selector) {
221
+ throw new Error("Method not implemented.");
222
+ }
223
+ screencastStop(s) {
224
+ throw new Error("Method not implemented.");
225
+ }
226
+ }