testeranto 0.70.0 → 0.74.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/README.md +9 -18
- package/dist/common/Node.js +7 -34
- package/dist/common/PM/index.js +71 -0
- package/dist/common/PM/main.js +370 -0
- package/dist/common/PM/node.js +84 -0
- package/dist/common/PM/web.js +129 -0
- package/dist/common/Project.js +20 -2
- package/dist/common/Puppeteer.js +109 -0
- package/dist/common/Reporter.js +119 -0
- package/dist/common/Scheduler.js +1 -0
- package/dist/common/SubPackages/puppeteer.js +3 -1
- package/dist/common/SubPackages/react/jsx/index.js +14 -2
- package/dist/common/SubPackages/react-dom/component/web.js +98 -45
- package/dist/common/SubPackages/react-test-renderer/jsx/index.js +0 -1
- package/dist/common/Web.js +24 -44
- package/dist/common/esbuildConfigs/web.js +3 -1
- package/dist/common/lib/abstractBase.js +189 -41
- package/dist/common/lib/basebuilder.js +56 -29
- package/dist/common/lib/classBuilder.js +6 -2
- package/dist/common/lib/core.js +41 -45
- package/dist/common/lib/index.js +2 -1
- package/dist/common/preload.js +14 -18
- package/dist/common/tsconfig.common.tsbuildinfo +1 -1
- package/dist/module/Node.js +7 -34
- package/dist/module/PM/index.js +67 -0
- package/dist/module/PM/main.js +340 -0
- package/dist/module/PM/node.js +77 -0
- package/dist/module/PM/web.js +122 -0
- package/dist/module/Project.js +20 -2
- package/dist/module/Puppeteer.js +104 -0
- package/dist/module/Reporter.js +114 -0
- package/dist/module/Scheduler.js +1 -0
- package/dist/module/SubPackages/puppeteer.js +3 -1
- package/dist/module/SubPackages/react/jsx/index.js +11 -2
- package/dist/module/SubPackages/react/jsx/node.js +1 -1
- package/dist/module/SubPackages/react-dom/component/web.js +98 -45
- package/dist/module/SubPackages/react-test-renderer/jsx/index.js +0 -1
- package/dist/module/Web.js +24 -44
- package/dist/module/esbuildConfigs/web.js +3 -1
- package/dist/module/lib/abstractBase.js +189 -41
- package/dist/module/lib/basebuilder.js +56 -29
- package/dist/module/lib/classBuilder.js +6 -2
- package/dist/module/lib/core.js +41 -45
- package/dist/module/lib/index.js +2 -1
- package/dist/module/preload.js +15 -14
- package/dist/module/tsconfig.module.tsbuildinfo +1 -1
- package/dist/prebuild/Report.css +1616 -584
- package/dist/prebuild/Report.js +2635 -2506
- package/dist/types/PM/index.d.ts +19 -0
- package/dist/types/PM/main.d.ts +26 -0
- package/dist/types/PM/node.d.ts +25 -0
- package/dist/types/PM/web.d.ts +24 -0
- package/dist/types/Reporter.d.ts +1 -0
- package/dist/types/Scheduler.d.ts +0 -0
- package/dist/types/SubPackages/react/jsx/index.d.ts +2 -5
- package/dist/types/SubPackages/react-dom/component/web.d.ts +1 -1
- package/dist/types/lib/abstractBase.d.ts +13 -12
- package/dist/types/lib/basebuilder.d.ts +4 -2
- package/dist/types/lib/classBuilder.d.ts +2 -2
- package/dist/types/lib/core.d.ts +4 -4
- package/dist/types/lib/index.d.ts +6 -5
- package/dist/types/lib/types.d.ts +16 -24
- package/dist/types/preload.d.ts +0 -1
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/package.json +3 -5
- package/src/Node.ts +8 -47
- package/src/PM/index.ts +102 -0
- package/src/PM/main.ts +452 -0
- package/src/PM/node.ts +122 -0
- package/src/PM/web.ts +162 -0
- package/src/Project.ts +21 -2
- package/src/Puppeteer.ts +131 -0
- package/src/Report.tsx +160 -46
- package/src/Reporter.ts +134 -0
- package/src/Scheduler.ts +0 -0
- package/src/SubPackages/puppeteer.ts +3 -3
- package/src/SubPackages/react/jsx/index.ts +13 -3
- package/src/SubPackages/react/jsx/node.ts +5 -8
- package/src/SubPackages/react-dom/component/web.ts +126 -67
- package/src/SubPackages/react-test-renderer/jsx/index.ts +0 -1
- package/src/Web.ts +25 -69
- package/src/esbuildConfigs/web.ts +4 -2
- package/src/lib/abstractBase.ts +260 -65
- package/src/lib/basebuilder.ts +121 -100
- package/src/lib/classBuilder.ts +5 -4
- package/src/lib/core.ts +58 -59
- package/src/lib/index.ts +10 -9
- package/src/lib/types.ts +18 -27
- package/src/preload.ts +14 -14
- package/dist/common/NodeWriter.js +0 -54
- package/dist/common/electron.js +0 -266
- package/dist/module/NodeWriter.js +0 -48
- package/dist/module/electron.js +0 -261
- package/dist/types/NodeWriter.d.ts +0 -2
- package/src/NodeWriter.ts +0 -72
- package/src/electron.ts +0 -317
- package/yarn-error.log +0 -3144
- /package/dist/types/{electron.d.ts → Puppeteer.d.ts} +0 -0
package/src/PM/node.ts
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import puppeteer from "puppeteer-core";
|
|
4
|
+
import { PassThrough } from "stream";
|
|
5
|
+
|
|
6
|
+
import { ITLog, ITTestResourceConfiguration } from "../lib";
|
|
7
|
+
|
|
8
|
+
import { PM } from "./index.js";
|
|
9
|
+
|
|
10
|
+
type IFPaths = string[];
|
|
11
|
+
const fPaths: IFPaths = [];
|
|
12
|
+
|
|
13
|
+
type PuppetMasterServer = Record<string, Promise<any>>;
|
|
14
|
+
|
|
15
|
+
export class PM_Node extends PM {
|
|
16
|
+
server: PuppetMasterServer;
|
|
17
|
+
testResourceConfiguration: ITTestResourceConfiguration;
|
|
18
|
+
|
|
19
|
+
constructor(t: ITTestResourceConfiguration) {
|
|
20
|
+
super();
|
|
21
|
+
this.server = {};
|
|
22
|
+
this.testResourceConfiguration = t;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
existsSync(destFolder: string): boolean {
|
|
26
|
+
return globalThis["existsSync"](
|
|
27
|
+
this.testResourceConfiguration.fs + "/" + destFolder
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
mkdirSync() {
|
|
32
|
+
return globalThis["mkdirSync"](this.testResourceConfiguration.fs + "/");
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
write(writeObject: { uid: number }, contents: string) {
|
|
36
|
+
return globalThis["write"](writeObject.uid, contents);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
writeFileSync(filepath: string, contents: string) {
|
|
40
|
+
return globalThis["writeFileSync"](
|
|
41
|
+
this.testResourceConfiguration.fs + "/" + filepath,
|
|
42
|
+
contents,
|
|
43
|
+
this.testResourceConfiguration.name
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
createWriteStream(filepath: string): any {
|
|
48
|
+
return globalThis["createWriteStream"](
|
|
49
|
+
this.testResourceConfiguration.fs + "/" + filepath,
|
|
50
|
+
this.testResourceConfiguration.name
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
end(writeObject: { uid: number }) {
|
|
55
|
+
return globalThis["end"](writeObject.uid);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
customclose() {
|
|
59
|
+
globalThis["customclose"](
|
|
60
|
+
this.testResourceConfiguration.fs,
|
|
61
|
+
this.testResourceConfiguration.name
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
testArtiFactoryfileWriter(tLog: ITLog, callback: (Promise) => void) {
|
|
66
|
+
return (fPath, value: string | Buffer | PassThrough) => {
|
|
67
|
+
callback(
|
|
68
|
+
new Promise<void>((res, rej) => {
|
|
69
|
+
tLog("testArtiFactory =>", fPath);
|
|
70
|
+
|
|
71
|
+
const cleanPath = path.resolve(fPath);
|
|
72
|
+
fPaths.push(cleanPath.replace(process.cwd(), ``));
|
|
73
|
+
|
|
74
|
+
const targetDir = cleanPath.split("/").slice(0, -1).join("/");
|
|
75
|
+
|
|
76
|
+
fs.mkdir(targetDir, { recursive: true }, async (error) => {
|
|
77
|
+
if (error) {
|
|
78
|
+
console.error(`❗️testArtiFactory failed`, targetDir, error);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
fs.writeFileSync(
|
|
82
|
+
path.resolve(
|
|
83
|
+
targetDir.split("/").slice(0, -1).join("/"),
|
|
84
|
+
"manifest"
|
|
85
|
+
),
|
|
86
|
+
fPaths.join(`\n`),
|
|
87
|
+
{
|
|
88
|
+
encoding: "utf-8",
|
|
89
|
+
}
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
if (Buffer.isBuffer(value)) {
|
|
93
|
+
fs.writeFileSync(fPath, value, "binary");
|
|
94
|
+
res();
|
|
95
|
+
} else if (`string` === typeof value) {
|
|
96
|
+
fs.writeFileSync(fPath, value.toString(), {
|
|
97
|
+
encoding: "utf-8",
|
|
98
|
+
});
|
|
99
|
+
res();
|
|
100
|
+
} else {
|
|
101
|
+
/* @ts-ignore:next-line */
|
|
102
|
+
const pipeStream: PassThrough = value;
|
|
103
|
+
const myFile = fs.createWriteStream(fPath);
|
|
104
|
+
pipeStream.pipe(myFile);
|
|
105
|
+
pipeStream.on("close", () => {
|
|
106
|
+
myFile.close();
|
|
107
|
+
res();
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
})
|
|
112
|
+
);
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// launch(options?: PuppeteerLaunchOptions): Promise<Browser>;
|
|
117
|
+
startPuppeteer(options?: any): Promise<any> {
|
|
118
|
+
return puppeteer.connect(options).then((b) => {
|
|
119
|
+
this.browser = b;
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
}
|
package/src/PM/web.ts
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { PassThrough } from "stream";
|
|
2
|
+
import puppeteer from "puppeteer-core/lib/esm/puppeteer/puppeteer-core-browser.js";
|
|
3
|
+
|
|
4
|
+
import { ITLog, ITTestResourceConfiguration } from "../lib";
|
|
5
|
+
import { PM } from "./index.js";
|
|
6
|
+
|
|
7
|
+
type PuppetMasterServer = Record<string, Promise<any>>;
|
|
8
|
+
|
|
9
|
+
export class PM_Web extends PM {
|
|
10
|
+
server: PuppetMasterServer;
|
|
11
|
+
|
|
12
|
+
constructor(t: ITTestResourceConfiguration) {
|
|
13
|
+
super();
|
|
14
|
+
this.server = {};
|
|
15
|
+
this.testResourceConfiguration = t;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
existsSync(destFolder: string): boolean {
|
|
19
|
+
return window["existsSync"](destFolder);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
mkdirSync() {
|
|
23
|
+
return window["mkdirSync"](this.testResourceConfiguration.fs + "/");
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
write(writeObject: { uid: number }, contents: string) {
|
|
27
|
+
return window["write"](writeObject.uid, contents);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
writeFileSync(filepath: string, contents: string) {
|
|
31
|
+
return window["writeFileSync"](
|
|
32
|
+
this.testResourceConfiguration.fs + "/" + filepath,
|
|
33
|
+
contents,
|
|
34
|
+
this.testResourceConfiguration.name
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
createWriteStream(filepath: string): any {
|
|
39
|
+
return window["createWriteStream"](
|
|
40
|
+
this.testResourceConfiguration.fs + "/" + filepath,
|
|
41
|
+
this.testResourceConfiguration.name
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
end(writeObject: { uid: number }) {
|
|
46
|
+
return window["end"](writeObject.uid);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
customclose() {
|
|
50
|
+
window["customclose"](
|
|
51
|
+
this.testResourceConfiguration.fs,
|
|
52
|
+
this.testResourceConfiguration.name
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
testArtiFactoryfileWriter(tLog: ITLog, callback: (Promise) => void) {
|
|
57
|
+
return (fPath, value: string | Buffer | PassThrough) => {
|
|
58
|
+
callback(
|
|
59
|
+
new Promise<void>((res, rej) => {
|
|
60
|
+
tLog("testArtiFactory =>", fPath);
|
|
61
|
+
|
|
62
|
+
// const cleanPath = path.resolve(fPath);
|
|
63
|
+
// fPaths.push(cleanPath.replace(process.cwd(), ``));
|
|
64
|
+
|
|
65
|
+
// const targetDir = cleanPath.split("/").slice(0, -1).join("/");
|
|
66
|
+
|
|
67
|
+
// fs.mkdir(targetDir, { recursive: true }, async (error) => {
|
|
68
|
+
// if (error) {
|
|
69
|
+
// console.error(`❗️testArtiFactory failed`, targetDir, error);
|
|
70
|
+
// }
|
|
71
|
+
|
|
72
|
+
// fs.writeFileSync(
|
|
73
|
+
// path.resolve(
|
|
74
|
+
// targetDir.split("/").slice(0, -1).join("/"),
|
|
75
|
+
// "manifest"
|
|
76
|
+
// ),
|
|
77
|
+
// fPaths.join(`\n`),
|
|
78
|
+
// {
|
|
79
|
+
// encoding: "utf-8",
|
|
80
|
+
// }
|
|
81
|
+
// );
|
|
82
|
+
|
|
83
|
+
// if (Buffer.isBuffer(value)) {
|
|
84
|
+
// fs.writeFileSync(fPath, value, "binary");
|
|
85
|
+
// res();
|
|
86
|
+
// } else if (`string` === typeof value) {
|
|
87
|
+
// fs.writeFileSync(fPath, value.toString(), {
|
|
88
|
+
// encoding: "utf-8",
|
|
89
|
+
// });
|
|
90
|
+
// res();
|
|
91
|
+
// } else {
|
|
92
|
+
// /* @ts-ignore:next-line */
|
|
93
|
+
// const pipeStream: PassThrough = value;
|
|
94
|
+
// const myFile = fs.createWriteStream(fPath);
|
|
95
|
+
// pipeStream.pipe(myFile);
|
|
96
|
+
// pipeStream.on("close", () => {
|
|
97
|
+
// myFile.close();
|
|
98
|
+
// res();
|
|
99
|
+
// });
|
|
100
|
+
// }
|
|
101
|
+
// });
|
|
102
|
+
})
|
|
103
|
+
);
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
startPuppeteer(options, destFolder: string): Promise<any> {
|
|
108
|
+
const name = this.testResourceConfiguration.name;
|
|
109
|
+
|
|
110
|
+
return fetch(`http://localhost:3234/json/version`)
|
|
111
|
+
.then((v) => {
|
|
112
|
+
return v.json();
|
|
113
|
+
})
|
|
114
|
+
.then((json) => {
|
|
115
|
+
return puppeteer
|
|
116
|
+
.connect({
|
|
117
|
+
browserWSEndpoint: json.webSocketDebuggerUrl,
|
|
118
|
+
})
|
|
119
|
+
.then((b) => {
|
|
120
|
+
this.browser = b;
|
|
121
|
+
const handler2 = {
|
|
122
|
+
get(target, prop, receiver) {
|
|
123
|
+
if (prop === "screenshot") {
|
|
124
|
+
return async (x) => {
|
|
125
|
+
return await window["custom-screenshot"](
|
|
126
|
+
{
|
|
127
|
+
...x,
|
|
128
|
+
// path: destFolder + "/" + x.path,
|
|
129
|
+
path: x.path,
|
|
130
|
+
},
|
|
131
|
+
name
|
|
132
|
+
);
|
|
133
|
+
};
|
|
134
|
+
} else if (prop === "mainFrame") {
|
|
135
|
+
return () => target[prop](...arguments);
|
|
136
|
+
} else {
|
|
137
|
+
return Reflect.get(...arguments);
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
};
|
|
141
|
+
const handler1 = {
|
|
142
|
+
get(target, prop, receiver) {
|
|
143
|
+
if (prop === "pages") {
|
|
144
|
+
return async () => {
|
|
145
|
+
return target.pages().then((pages) => {
|
|
146
|
+
return pages.map((p) => {
|
|
147
|
+
return new Proxy(p, handler2);
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
return Reflect.get(...arguments);
|
|
154
|
+
},
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
const proxy3 = new Proxy(this.browser, handler1);
|
|
158
|
+
this.browser = proxy3;
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
}
|
package/src/Project.ts
CHANGED
|
@@ -109,6 +109,25 @@ export class ITProject {
|
|
|
109
109
|
|
|
110
110
|
const [nodeEntryPoints, webEntryPoints] = getRunnables(this.config.tests);
|
|
111
111
|
|
|
112
|
+
// nodeEntryPoints.forEach((nep) => {
|
|
113
|
+
// const f = `${process.cwd()}/${nep}`;
|
|
114
|
+
// console.log("nep", f);
|
|
115
|
+
// import(f).then((module) => {
|
|
116
|
+
// return module.default.then((defaultModule) => {
|
|
117
|
+
// console.log("defaultModule", defaultModule);
|
|
118
|
+
// // defaultModule
|
|
119
|
+
// // .receiveTestResourceConfig(argz)
|
|
120
|
+
// // .then((x) => {
|
|
121
|
+
// // console.log("then", x);
|
|
122
|
+
// // return x;
|
|
123
|
+
// // })
|
|
124
|
+
// // .catch((e) => {
|
|
125
|
+
// // console.log("catch", e);
|
|
126
|
+
// // });
|
|
127
|
+
// });
|
|
128
|
+
// });
|
|
129
|
+
// });
|
|
130
|
+
|
|
112
131
|
glob(`./${config.outdir}/chunk-*.mjs`, { ignore: "node_modules/**" }).then(
|
|
113
132
|
(chunks) => {
|
|
114
133
|
chunks.forEach((chunk) => {
|
|
@@ -213,8 +232,8 @@ const getRunnables = (
|
|
|
213
232
|
pt[1].add(cv[0]);
|
|
214
233
|
}
|
|
215
234
|
|
|
216
|
-
if (cv[
|
|
217
|
-
getRunnables(cv[
|
|
235
|
+
if (cv[3].length) {
|
|
236
|
+
getRunnables(cv[3], payload);
|
|
218
237
|
}
|
|
219
238
|
|
|
220
239
|
return pt;
|
package/src/Puppeteer.ts
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import readline from "readline";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import { jsonc } from "jsonc";
|
|
5
|
+
import { v4 as uuidv4 } from "uuid";
|
|
6
|
+
|
|
7
|
+
import { IBuiltConfig, IRunTime } from "./lib/types";
|
|
8
|
+
|
|
9
|
+
import { PM_Main } from "./PM/main.js";
|
|
10
|
+
|
|
11
|
+
var mode: "DEV" | "PROD" = process.argv[2] === "-dev" ? "DEV" : "PROD";
|
|
12
|
+
|
|
13
|
+
const node2web: Record<string, string[]> = {};
|
|
14
|
+
const web2node: Record<string, string[]> = {};
|
|
15
|
+
const childProcesses: Record<string, "loaded" | "running" | "done"> = {};
|
|
16
|
+
|
|
17
|
+
readline.emitKeypressEvents(process.stdin);
|
|
18
|
+
if (process.stdin.isTTY) process.stdin.setRawMode(true);
|
|
19
|
+
|
|
20
|
+
console.log("\n Puppeteer is running. Press 'q' to quit\n");
|
|
21
|
+
process.stdin.on("keypress", (str, key) => {
|
|
22
|
+
if (key.name === "q") {
|
|
23
|
+
process.exit();
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
const main = async () => {
|
|
28
|
+
const configs = jsonc.parse(
|
|
29
|
+
(await fs.readFileSync("./docs/testeranto.json")).toString()
|
|
30
|
+
) as IBuiltConfig;
|
|
31
|
+
|
|
32
|
+
const pm = new PM_Main(configs);
|
|
33
|
+
|
|
34
|
+
await pm.startPuppeteer(
|
|
35
|
+
{
|
|
36
|
+
waitForInitialPage: false,
|
|
37
|
+
executablePath: "/opt/homebrew/bin/chromium",
|
|
38
|
+
headless: true,
|
|
39
|
+
dumpio: true,
|
|
40
|
+
args: [
|
|
41
|
+
"--allow-file-access-from-files",
|
|
42
|
+
"--allow-running-insecure-content",
|
|
43
|
+
"--auto-open-devtools-for-tabs",
|
|
44
|
+
"--disable-dev-shm-usage",
|
|
45
|
+
"--disable-extensions",
|
|
46
|
+
"--disable-gpu",
|
|
47
|
+
"--disable-setuid-sandbox",
|
|
48
|
+
"--disable-site-isolation-trials",
|
|
49
|
+
"--disable-web-security",
|
|
50
|
+
"--disable-web-security",
|
|
51
|
+
"--no-first-run",
|
|
52
|
+
"--no-sandbox",
|
|
53
|
+
"--no-startup-window",
|
|
54
|
+
// "--no-zygote",
|
|
55
|
+
"--reduce-security-for-testing",
|
|
56
|
+
"--remote-allow-origins=*",
|
|
57
|
+
"--unsafely-treat-insecure-origin-as-secure=*",
|
|
58
|
+
// "--disable-features=IsolateOrigins",
|
|
59
|
+
// "--remote-allow-origins=ws://localhost:3234",
|
|
60
|
+
// "--single-process",
|
|
61
|
+
// "--unsafely-treat-insecure-origin-as-secure",
|
|
62
|
+
// "--unsafely-treat-insecure-origin-as-secure=ws://192.168.0.101:3234",
|
|
63
|
+
`--remote-debugging-port=3234`,
|
|
64
|
+
|
|
65
|
+
// "--disk-cache-dir=/dev/null",
|
|
66
|
+
// "--disk-cache-size=1",
|
|
67
|
+
// "--start-maximized",
|
|
68
|
+
],
|
|
69
|
+
},
|
|
70
|
+
"."
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
const destinationOfRuntime = (f: string, r: IRunTime) => {
|
|
74
|
+
return path
|
|
75
|
+
.normalize(`${configs.buildDir}/${r}/${f}`)
|
|
76
|
+
.split(".")
|
|
77
|
+
.slice(0, -1)
|
|
78
|
+
.join(".");
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
configs.tests.forEach(([test, runtime, secondaryArtifacts]) => {
|
|
82
|
+
if (runtime === "node") {
|
|
83
|
+
pm.launchNode(test, destinationOfRuntime(test, "node"));
|
|
84
|
+
} else if (runtime === "web") {
|
|
85
|
+
pm.launchWeb(test, destinationOfRuntime(test, "web"));
|
|
86
|
+
} else {
|
|
87
|
+
console.error("runtime makes no sense", runtime);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
console.log("ready and watching for changes...", configs.buildDir);
|
|
92
|
+
fs.watch(
|
|
93
|
+
configs.buildDir,
|
|
94
|
+
{
|
|
95
|
+
recursive: true,
|
|
96
|
+
},
|
|
97
|
+
(eventType, changedFile) => {
|
|
98
|
+
if (changedFile) {
|
|
99
|
+
configs.tests.forEach(([test, runtime, secondaryArtifacts]) => {
|
|
100
|
+
if (eventType === "change" || eventType === "rename") {
|
|
101
|
+
if (
|
|
102
|
+
changedFile ===
|
|
103
|
+
test
|
|
104
|
+
.replace("./", "node/")
|
|
105
|
+
.split(".")
|
|
106
|
+
.slice(0, -1)
|
|
107
|
+
.concat("mjs")
|
|
108
|
+
.join(".")
|
|
109
|
+
) {
|
|
110
|
+
pm.launchNode(test, destinationOfRuntime(test, "node"));
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (
|
|
114
|
+
changedFile ===
|
|
115
|
+
test
|
|
116
|
+
.replace("./", "web/")
|
|
117
|
+
.split(".")
|
|
118
|
+
.slice(0, -1)
|
|
119
|
+
.concat("mjs")
|
|
120
|
+
.join(".")
|
|
121
|
+
) {
|
|
122
|
+
pm.launchWeb(test, destinationOfRuntime(test, "web"));
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
);
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
main();
|