testeranto 0.73.0 → 0.75.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/dist/common/Node.js +1 -8
- package/dist/common/PM/main.js +65 -56
- package/dist/common/PM/node.js +4 -96
- package/dist/common/PM/web.js +8 -53
- package/dist/common/SubPackages/react/jsx/index.js +14 -2
- package/dist/common/Web.js +0 -1
- package/dist/common/lib/abstractBase.js +1 -1
- package/dist/common/tsconfig.common.tsbuildinfo +1 -1
- package/dist/module/Node.js +1 -8
- package/dist/module/PM/main.js +65 -56
- package/dist/module/PM/node.js +3 -94
- package/dist/module/PM/web.js +8 -53
- package/dist/module/SubPackages/react/jsx/index.js +11 -2
- package/dist/module/Web.js +0 -1
- package/dist/module/lib/abstractBase.js +1 -1
- package/dist/module/tsconfig.module.tsbuildinfo +1 -1
- package/dist/prebuild/Report.js +2 -2
- package/dist/types/PM/node.d.ts +0 -1
- package/dist/types/SubPackages/react/jsx/index.d.ts +2 -5
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/Node.ts +1 -15
- package/src/PM/main.ts +119 -87
- package/src/PM/node.ts +10 -403
- package/src/PM/web.ts +20 -355
- package/src/Report.tsx +2 -2
- package/src/SubPackages/react/jsx/index.ts +13 -3
- package/src/Web.ts +0 -2
- package/src/lib/abstractBase.ts +1 -1
package/package.json
CHANGED
package/src/Node.ts
CHANGED
|
@@ -33,26 +33,12 @@ class NodeTesteranto<
|
|
|
33
33
|
);
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
async receiveTestResourceConfig(
|
|
37
|
-
// t: ITestJob,
|
|
38
|
-
partialTestResource: string
|
|
39
|
-
) {
|
|
40
|
-
console.log(
|
|
41
|
-
"receiveTestResourceConfig!!",
|
|
42
|
-
this.testJobs[0].receiveTestResourceConfig
|
|
43
|
-
);
|
|
44
|
-
|
|
36
|
+
async receiveTestResourceConfig(partialTestResource: string) {
|
|
45
37
|
const t: ITTestResourceConfiguration = JSON.parse(partialTestResource);
|
|
46
38
|
const pm = new PM_Node(t);
|
|
47
39
|
const { failed, artifacts, logPromise } =
|
|
48
40
|
await this.testJobs[0].receiveTestResourceConfig(pm);
|
|
49
|
-
|
|
50
|
-
console.log("test is done, awaiting test result write to fs");
|
|
51
41
|
pm.customclose();
|
|
52
|
-
|
|
53
|
-
// Promise.all([...artifacts, logPromise]).then(async () => {
|
|
54
|
-
// // process.exit((await failed) ? 1 : 0);
|
|
55
|
-
// });
|
|
56
42
|
}
|
|
57
43
|
}
|
|
58
44
|
|
package/src/PM/main.ts
CHANGED
|
@@ -3,33 +3,25 @@ import path from "path";
|
|
|
3
3
|
import puppeteer, { ScreenshotOptions } from "puppeteer-core";
|
|
4
4
|
import { PassThrough } from "stream";
|
|
5
5
|
|
|
6
|
-
import { ITLog
|
|
6
|
+
import { ITLog } from "../lib";
|
|
7
7
|
import { IBuiltConfig } from "../lib/types";
|
|
8
8
|
|
|
9
9
|
import { PM } from "./index.js";
|
|
10
10
|
|
|
11
11
|
type IFPaths = string[];
|
|
12
|
-
const fPaths: IFPaths = [];
|
|
13
12
|
|
|
13
|
+
const fPaths: IFPaths = [];
|
|
14
14
|
const fileStreams3: fs.WriteStream[] = [];
|
|
15
|
-
const
|
|
16
|
-
const
|
|
15
|
+
const files: Record<string, Set<string>> = {}; // = new Set<string>();
|
|
16
|
+
const screenshots: Record<string, Promise<Uint8Array>[]> = {};
|
|
17
17
|
|
|
18
18
|
export class PM_Main extends PM {
|
|
19
19
|
configs: IBuiltConfig;
|
|
20
|
-
|
|
21
20
|
ports: Record<number, boolean>;
|
|
22
21
|
queue: any[];
|
|
23
22
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
constructor(
|
|
27
|
-
configs: IBuiltConfig
|
|
28
|
-
// testResourceConfig: ITTestResourceConfiguration
|
|
29
|
-
) {
|
|
23
|
+
constructor(configs: IBuiltConfig) {
|
|
30
24
|
super();
|
|
31
|
-
// this.testResourceConfiguration = testResourceConfig;
|
|
32
|
-
// console.log("mkdirsync4", testResourceConfig);
|
|
33
25
|
this.server = {};
|
|
34
26
|
this.configs = configs;
|
|
35
27
|
this.ports = {};
|
|
@@ -46,20 +38,32 @@ export class PM_Main extends PM {
|
|
|
46
38
|
return false;
|
|
47
39
|
};
|
|
48
40
|
|
|
49
|
-
globalThis["writeFileSync"] = (
|
|
41
|
+
globalThis["writeFileSync"] = (
|
|
42
|
+
filepath: string,
|
|
43
|
+
contents: string,
|
|
44
|
+
testName: string
|
|
45
|
+
) => {
|
|
50
46
|
// Create directories if they don't exist
|
|
51
|
-
const dir = path.dirname(
|
|
52
|
-
|
|
47
|
+
const dir = path.dirname(filepath.split("/").slice(0, -1).join("/"));
|
|
48
|
+
|
|
53
49
|
fs.mkdirSync(dir, {
|
|
54
50
|
recursive: true,
|
|
55
51
|
});
|
|
56
|
-
|
|
52
|
+
if (!files[testName]) {
|
|
53
|
+
files[testName] = new Set();
|
|
54
|
+
}
|
|
55
|
+
files[testName].add(filepath);
|
|
56
|
+
return fs.writeFileSync(filepath, contents);
|
|
57
57
|
};
|
|
58
58
|
|
|
59
|
-
globalThis["createWriteStream"] = (filepath: string) => {
|
|
59
|
+
globalThis["createWriteStream"] = (filepath: string, testName: string) => {
|
|
60
60
|
const f = fs.createWriteStream(filepath);
|
|
61
61
|
fileStreams3.push(f);
|
|
62
|
-
|
|
62
|
+
// files.add(filepath);
|
|
63
|
+
if (!files[testName]) {
|
|
64
|
+
files[testName] = new Set();
|
|
65
|
+
}
|
|
66
|
+
files[testName].add(filepath);
|
|
63
67
|
return {
|
|
64
68
|
...JSON.parse(JSON.stringify(f)),
|
|
65
69
|
uid: fileStreams3.length - 1,
|
|
@@ -67,8 +71,6 @@ export class PM_Main extends PM {
|
|
|
67
71
|
};
|
|
68
72
|
|
|
69
73
|
globalThis["write"] = (uid: number, contents: string) => {
|
|
70
|
-
console.log("write", uid, contents);
|
|
71
|
-
// process.exit();
|
|
72
74
|
fileStreams3[uid].write(contents);
|
|
73
75
|
};
|
|
74
76
|
|
|
@@ -76,7 +78,22 @@ export class PM_Main extends PM {
|
|
|
76
78
|
fileStreams3[uid].end();
|
|
77
79
|
};
|
|
78
80
|
|
|
79
|
-
globalThis["customclose"] = () => {
|
|
81
|
+
globalThis["customclose"] = (p: string, testName: string) => {
|
|
82
|
+
if (!files[testName]) {
|
|
83
|
+
files[testName] = new Set();
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
fs.writeFileSync(
|
|
87
|
+
p + "/manifest.json",
|
|
88
|
+
JSON.stringify(Array.from(files[testName]))
|
|
89
|
+
);
|
|
90
|
+
delete files[testName];
|
|
91
|
+
// globalThis["writeFileSync"](
|
|
92
|
+
// p + "/manifest.json",
|
|
93
|
+
// // files.entries()
|
|
94
|
+
// JSON.stringify(Array.from(files[testName]))
|
|
95
|
+
// );
|
|
96
|
+
|
|
80
97
|
// fileStreams3[uid].end();
|
|
81
98
|
};
|
|
82
99
|
// page.exposeFunction("customclose", () => {
|
|
@@ -106,7 +123,7 @@ export class PM_Main extends PM {
|
|
|
106
123
|
|
|
107
124
|
launchNode = async (src: string, dest: string) => {
|
|
108
125
|
console.log("launchNode", src);
|
|
109
|
-
|
|
126
|
+
|
|
110
127
|
const destFolder = dest.replace(".mjs", "");
|
|
111
128
|
|
|
112
129
|
let argz = "";
|
|
@@ -121,7 +138,6 @@ export class PM_Main extends PM {
|
|
|
121
138
|
}
|
|
122
139
|
const testConfigResource = testConfig[2];
|
|
123
140
|
|
|
124
|
-
console.log("mark22 testConfigResource", testConfigResource);
|
|
125
141
|
let portsToUse: string[] = [];
|
|
126
142
|
if (testConfigResource.ports === 0) {
|
|
127
143
|
argz = JSON.stringify({
|
|
@@ -183,9 +199,7 @@ export class PM_Main extends PM {
|
|
|
183
199
|
|
|
184
200
|
launchWeb = (t: string, dest: string) => {
|
|
185
201
|
console.log("launchWeb", t, dest);
|
|
186
|
-
const testResourceConfiguration = this.testResourceConfiguration;
|
|
187
202
|
|
|
188
|
-
// childProcesses[t] = "running";
|
|
189
203
|
const destFolder = dest.replace(".mjs", "");
|
|
190
204
|
|
|
191
205
|
const webArgz = JSON.stringify({
|
|
@@ -206,7 +220,7 @@ export class PM_Main extends PM {
|
|
|
206
220
|
|
|
207
221
|
const fileStreams2: fs.WriteStream[] = [];
|
|
208
222
|
|
|
209
|
-
const screenshots2: Promise<any>[] = [];
|
|
223
|
+
// const screenshots2: Promise<any>[] = [];
|
|
210
224
|
const doneFileStream2: Promise<any>[] = [];
|
|
211
225
|
|
|
212
226
|
this.browser
|
|
@@ -214,58 +228,59 @@ export class PM_Main extends PM {
|
|
|
214
228
|
.then((page) => {
|
|
215
229
|
page.exposeFunction(
|
|
216
230
|
"custom-screenshot",
|
|
217
|
-
async (ssOpts: ScreenshotOptions) => {
|
|
231
|
+
async (ssOpts: ScreenshotOptions, testName: string) => {
|
|
232
|
+
console.log("main.ts browser custom-screenshot", testName);
|
|
218
233
|
const p = ssOpts.path as string;
|
|
219
|
-
console.log("custom-screenshot", ssOpts);
|
|
220
234
|
const dir = path.dirname(p);
|
|
221
|
-
console.log("dir", dir);
|
|
222
235
|
fs.mkdirSync(dir, {
|
|
223
236
|
recursive: true,
|
|
224
237
|
});
|
|
225
|
-
|
|
238
|
+
files[testName].add(ssOpts.path as string);
|
|
239
|
+
|
|
240
|
+
const sPromise = page.screenshot({
|
|
226
241
|
...ssOpts,
|
|
227
242
|
path: p,
|
|
228
243
|
});
|
|
229
244
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
//
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
// ...ssOpts,
|
|
238
|
-
// path: p,
|
|
239
|
-
// });
|
|
240
|
-
// await sPromise;
|
|
245
|
+
if (!screenshots[testName]) {
|
|
246
|
+
screenshots[testName] = [];
|
|
247
|
+
}
|
|
248
|
+
screenshots[testName].push(sPromise);
|
|
249
|
+
// sPromise.then(())
|
|
250
|
+
await sPromise;
|
|
251
|
+
return sPromise;
|
|
241
252
|
// page.evaluate(`window["screenshot done"]`);
|
|
242
253
|
}
|
|
243
254
|
);
|
|
244
255
|
|
|
245
|
-
page.exposeFunction(
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
console.log("dir", dir);
|
|
250
|
-
fs.mkdirSync(dir, {
|
|
251
|
-
recursive: true,
|
|
252
|
-
});
|
|
253
|
-
// return fs.writeFileSync(fp, contents);
|
|
256
|
+
page.exposeFunction(
|
|
257
|
+
"writeFileSync",
|
|
258
|
+
(fp: string, contents: string, testName: string) => {
|
|
259
|
+
const dir = path.dirname(fp);
|
|
254
260
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
261
|
+
fs.mkdirSync(dir, {
|
|
262
|
+
recursive: true,
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
const p = new Promise<string>(async (res, rej) => {
|
|
266
|
+
fs.writeFileSync(fp, contents);
|
|
267
|
+
res(fp);
|
|
268
|
+
});
|
|
269
|
+
doneFileStream2.push(p);
|
|
270
|
+
|
|
271
|
+
if (!files[testName]) {
|
|
272
|
+
files[testName] = new Set();
|
|
273
|
+
}
|
|
274
|
+
files[testName].add(fp);
|
|
275
|
+
return p;
|
|
276
|
+
}
|
|
277
|
+
);
|
|
262
278
|
|
|
263
279
|
page.exposeFunction("existsSync", (fp: string, contents: string) => {
|
|
264
280
|
return fs.existsSync(fp);
|
|
265
281
|
});
|
|
266
282
|
|
|
267
283
|
page.exposeFunction("mkdirSync", (fp: string) => {
|
|
268
|
-
console.log("mkdirsync", fp);
|
|
269
284
|
if (!fs.existsSync(fp)) {
|
|
270
285
|
return fs.mkdirSync(fp, {
|
|
271
286
|
recursive: true,
|
|
@@ -274,22 +289,30 @@ export class PM_Main extends PM {
|
|
|
274
289
|
return false;
|
|
275
290
|
});
|
|
276
291
|
|
|
277
|
-
page.exposeFunction(
|
|
278
|
-
|
|
292
|
+
page.exposeFunction(
|
|
293
|
+
"createWriteStream",
|
|
294
|
+
(fp: string, testName: string) => {
|
|
295
|
+
const f = fs.createWriteStream(fp);
|
|
279
296
|
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
297
|
+
if (!files[testName]) {
|
|
298
|
+
files[testName] = new Set();
|
|
299
|
+
}
|
|
300
|
+
files[testName].add(fp);
|
|
301
|
+
|
|
302
|
+
const p = new Promise<string>((res, rej) => {
|
|
303
|
+
res(fp);
|
|
304
|
+
});
|
|
305
|
+
doneFileStream2.push(p);
|
|
306
|
+
f.on("close", async () => {
|
|
307
|
+
await p;
|
|
308
|
+
});
|
|
309
|
+
fileStreams2.push(f);
|
|
310
|
+
return {
|
|
311
|
+
...JSON.parse(JSON.stringify(f)),
|
|
312
|
+
uid: fileStreams2.length - 1,
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
);
|
|
293
316
|
|
|
294
317
|
page.exposeFunction("write", async (uid: number, contents: string) => {
|
|
295
318
|
return fileStreams2[uid].write(contents);
|
|
@@ -299,14 +322,30 @@ export class PM_Main extends PM {
|
|
|
299
322
|
return fileStreams2[uid].end();
|
|
300
323
|
});
|
|
301
324
|
|
|
302
|
-
page.exposeFunction("customclose", () => {
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
325
|
+
page.exposeFunction("customclose", (p: string, testName: string) => {
|
|
326
|
+
fs.writeFileSync(
|
|
327
|
+
p + "/manifest.json",
|
|
328
|
+
JSON.stringify(Array.from(files[testName]))
|
|
329
|
+
);
|
|
330
|
+
delete files[testName];
|
|
331
|
+
|
|
332
|
+
Promise.all(screenshots[testName] || []).then(() => {
|
|
333
|
+
delete screenshots[testName];
|
|
306
334
|
page.close();
|
|
307
335
|
});
|
|
308
336
|
|
|
309
|
-
//
|
|
337
|
+
// globalThis["writeFileSync"](
|
|
338
|
+
// p + "/manifest.json",
|
|
339
|
+
// // files.entries()
|
|
340
|
+
// JSON.stringify(Array.from(files[testName]))
|
|
341
|
+
// );
|
|
342
|
+
|
|
343
|
+
// console.log("closing doneFileStream2", doneFileStream2);
|
|
344
|
+
// console.log("closing doneFileStream2", doneFileStream2);
|
|
345
|
+
// Promise.all([...doneFileStream2, ...screenshots2]).then(() => {
|
|
346
|
+
// page.close();
|
|
347
|
+
// });
|
|
348
|
+
|
|
310
349
|
// Promise.all(screenshots).then(() => {
|
|
311
350
|
// page.close();
|
|
312
351
|
// });
|
|
@@ -321,20 +360,13 @@ export class PM_Main extends PM {
|
|
|
321
360
|
return page;
|
|
322
361
|
})
|
|
323
362
|
.then(async (page) => {
|
|
324
|
-
await page.goto(`file://${`${dest}.html`}`, {
|
|
325
|
-
// waitUntil: "load",
|
|
326
|
-
// timeout: 0,
|
|
327
|
-
});
|
|
363
|
+
await page.goto(`file://${`${dest}.html`}`, {});
|
|
328
364
|
|
|
329
365
|
page.evaluate(evaluation).finally(() => {
|
|
330
366
|
console.log("evaluation failed.", dest);
|
|
331
367
|
});
|
|
332
368
|
|
|
333
369
|
return page;
|
|
334
|
-
})
|
|
335
|
-
.then((page) => {
|
|
336
|
-
// console.log("qwe", page);
|
|
337
|
-
// page.close();
|
|
338
370
|
});
|
|
339
371
|
};
|
|
340
372
|
|