testeranto 0.110.0 → 0.111.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/package.json +1 -1
- package/src/PM/main.ts +418 -92
- package/src/ReportClient.tsx +38 -30
- package/src/run.ts +4 -371
- package/tsc.log +8 -6
- package/dist/common/Init.js +0 -68
- package/dist/common/Node.js +0 -27
- package/dist/common/PM/index.js +0 -7
- package/dist/common/PM/main.js +0 -984
- package/dist/common/PM/node.js +0 -128
- package/dist/common/PM/web.js +0 -121
- package/dist/common/ReportServer.js +0 -22
- package/dist/common/SubPackages/react/component/node.js +0 -19
- package/dist/common/SubPackages/react/component/web.js +0 -19
- package/dist/common/SubPackages/react/jsx/index.js +0 -21
- package/dist/common/SubPackages/react/jsx/node.js +0 -10
- package/dist/common/SubPackages/react/jsx/web.js +0 -10
- package/dist/common/SubPackages/react-dom/component/node.js +0 -88
- package/dist/common/SubPackages/react-dom/component/web.js +0 -67
- package/dist/common/SubPackages/react-dom/jsx/index.js +0 -2
- package/dist/common/SubPackages/react-dom/jsx/node.js +0 -39
- package/dist/common/SubPackages/react-dom/jsx/web.js +0 -128
- package/dist/common/SubPackages/react-test-renderer/MemoExoticComponent/node.js +0 -54
- package/dist/common/SubPackages/react-test-renderer/component/index.js +0 -2
- package/dist/common/SubPackages/react-test-renderer/component/interface.js +0 -70
- package/dist/common/SubPackages/react-test-renderer/component/node.js +0 -8
- package/dist/common/SubPackages/react-test-renderer/component/web.js +0 -8
- package/dist/common/SubPackages/react-test-renderer/fc/node.js +0 -60
- package/dist/common/SubPackages/react-test-renderer/fc/web.js +0 -60
- package/dist/common/SubPackages/react-test-renderer/jsx/index.js +0 -67
- package/dist/common/SubPackages/react-test-renderer/jsx/node.js +0 -10
- package/dist/common/SubPackages/react-test-renderer/jsx/web.js +0 -10
- package/dist/common/SubPackages/react-test-renderer/jsx-promised/index.js +0 -52
- package/dist/common/SubPackages/react-test-renderer/jsx-promised/node.js +0 -10
- package/dist/common/SubPackages/react-test-renderer/jsx-promised/web.js +0 -10
- package/dist/common/Types.js +0 -2
- package/dist/common/Web.js +0 -49
- package/dist/common/build.js +0 -222
- package/dist/common/defaultConfig.js +0 -20
- package/dist/common/esbuildConfigs/eslint-formatter-testeranto.js +0 -6
- package/dist/common/esbuildConfigs/featuresPlugin.js +0 -39
- package/dist/common/esbuildConfigs/index.js +0 -21
- package/dist/common/esbuildConfigs/inputFilesPlugin.js +0 -27
- package/dist/common/esbuildConfigs/node.js +0 -37
- package/dist/common/esbuildConfigs/web.js +0 -50
- package/dist/common/init-docs.js +0 -53
- package/dist/common/lib/abstractBase.js +0 -329
- package/dist/common/lib/basebuilder.js +0 -98
- package/dist/common/lib/classBuilder.js +0 -40
- package/dist/common/lib/core.js +0 -117
- package/dist/common/lib/index.js +0 -21
- package/dist/common/lib/types.js +0 -2
- package/dist/common/package.json +0 -3
- package/dist/common/puppeteerConfiger.js +0 -24
- package/dist/common/run.js +0 -297
- package/dist/common/tsconfig.common.tsbuildinfo +0 -1
- package/dist/common/utils.js +0 -43
- package/dist/common/web.html.js +0 -22
- package/dist/module/Footer.js +0 -4
- package/dist/module/Init.js +0 -63
- package/dist/module/Node.js +0 -20
- package/dist/module/PM/index.js +0 -3
- package/dist/module/PM/main.js +0 -944
- package/dist/module/PM/node.js +0 -121
- package/dist/module/PM/web.js +0 -117
- package/dist/module/ReportClient.js +0 -97
- package/dist/module/ReportServer.js +0 -17
- package/dist/module/SubPackages/react/component/node.js +0 -14
- package/dist/module/SubPackages/react/component/web.js +0 -14
- package/dist/module/SubPackages/react/jsx/index.js +0 -15
- package/dist/module/SubPackages/react/jsx/node.js +0 -5
- package/dist/module/SubPackages/react/jsx/web.js +0 -5
- package/dist/module/SubPackages/react-dom/component/node.js +0 -80
- package/dist/module/SubPackages/react-dom/component/web.js +0 -62
- package/dist/module/SubPackages/react-dom/jsx/index.js +0 -1
- package/dist/module/SubPackages/react-dom/jsx/node.js +0 -31
- package/dist/module/SubPackages/react-dom/jsx/web.js +0 -90
- package/dist/module/SubPackages/react-test-renderer/MemoExoticComponent/node.js +0 -16
- package/dist/module/SubPackages/react-test-renderer/component/index.js +0 -1
- package/dist/module/SubPackages/react-test-renderer/component/interface.js +0 -31
- package/dist/module/SubPackages/react-test-renderer/component/node.js +0 -3
- package/dist/module/SubPackages/react-test-renderer/component/web.js +0 -3
- package/dist/module/SubPackages/react-test-renderer/fc/node.js +0 -22
- package/dist/module/SubPackages/react-test-renderer/fc/web.js +0 -22
- package/dist/module/SubPackages/react-test-renderer/jsx/index.js +0 -28
- package/dist/module/SubPackages/react-test-renderer/jsx/node.js +0 -5
- package/dist/module/SubPackages/react-test-renderer/jsx/web.js +0 -5
- package/dist/module/SubPackages/react-test-renderer/jsx-promised/index.js +0 -16
- package/dist/module/SubPackages/react-test-renderer/jsx-promised/node.js +0 -5
- package/dist/module/SubPackages/react-test-renderer/jsx-promised/web.js +0 -5
- package/dist/module/TestReport.js +0 -91
- package/dist/module/Types.js +0 -1
- package/dist/module/Web.js +0 -42
- package/dist/module/build.js +0 -184
- package/dist/module/defaultConfig.js +0 -18
- package/dist/module/esbuildConfigs/eslint-formatter-testeranto.js +0 -3
- package/dist/module/esbuildConfigs/featuresPlugin.js +0 -34
- package/dist/module/esbuildConfigs/index.js +0 -19
- package/dist/module/esbuildConfigs/inputFilesPlugin.js +0 -22
- package/dist/module/esbuildConfigs/node.js +0 -32
- package/dist/module/esbuildConfigs/web.js +0 -45
- package/dist/module/init-docs.js +0 -15
- package/dist/module/lib/abstractBase.js +0 -321
- package/dist/module/lib/basebuilder.js +0 -94
- package/dist/module/lib/classBuilder.js +0 -36
- package/dist/module/lib/core.js +0 -114
- package/dist/module/lib/index.js +0 -17
- package/dist/module/lib/types.js +0 -1
- package/dist/module/package.json +0 -3
- package/dist/module/puppeteerConfiger.js +0 -19
- package/dist/module/run.js +0 -259
- package/dist/module/tsconfig.module.tsbuildinfo +0 -1
- package/dist/module/utils.js +0 -29
- package/dist/module/web.html.js +0 -20
- package/dist/prebuild/ReportClient.css +0 -11367
- package/dist/prebuild/ReportClient.js +0 -23641
- package/dist/prebuild/ReportServer.mjs +0 -16
- package/dist/prebuild/TestReport.css +0 -11367
- package/dist/prebuild/TestReport.js +0 -27484
- package/dist/prebuild/build.mjs +0 -376
- package/dist/prebuild/esbuildConfigs/eslint-formatter-testeranto.mjs +0 -9
- package/dist/prebuild/init-docs.mjs +0 -104
- package/dist/prebuild/run.mjs +0 -1190
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/dist/types/Init.d.ts +0 -2
- package/dist/types/Node.d.ts +0 -12
- package/dist/types/PM/index.d.ts +0 -34
- package/dist/types/PM/main.d.ts +0 -59
- package/dist/types/PM/node.d.ts +0 -40
- package/dist/types/PM/web.d.ts +0 -38
- package/dist/types/ReportServer.d.ts +0 -1
- package/dist/types/SubPackages/react/component/node.d.ts +0 -7
- package/dist/types/SubPackages/react/component/web.d.ts +0 -7
- package/dist/types/SubPackages/react/jsx/index.d.ts +0 -12
- package/dist/types/SubPackages/react/jsx/node.d.ts +0 -4
- package/dist/types/SubPackages/react/jsx/web.d.ts +0 -4
- package/dist/types/SubPackages/react-dom/component/node.d.ts +0 -11
- package/dist/types/SubPackages/react-dom/component/web.d.ts +0 -20
- package/dist/types/SubPackages/react-dom/jsx/index.d.ts +0 -6
- package/dist/types/SubPackages/react-dom/jsx/node.d.ts +0 -7
- package/dist/types/SubPackages/react-dom/jsx/web.d.ts +0 -5
- package/dist/types/SubPackages/react-test-renderer/MemoExoticComponent/node.d.ts +0 -6
- package/dist/types/SubPackages/react-test-renderer/component/index.d.ts +0 -13
- package/dist/types/SubPackages/react-test-renderer/component/interface.d.ts +0 -9
- package/dist/types/SubPackages/react-test-renderer/component/node.d.ts +0 -4
- package/dist/types/SubPackages/react-test-renderer/component/web.d.ts +0 -4
- package/dist/types/SubPackages/react-test-renderer/fc/node.d.ts +0 -8
- package/dist/types/SubPackages/react-test-renderer/fc/web.d.ts +0 -9
- package/dist/types/SubPackages/react-test-renderer/jsx/index.d.ts +0 -16
- package/dist/types/SubPackages/react-test-renderer/jsx/node.d.ts +0 -9
- package/dist/types/SubPackages/react-test-renderer/jsx/web.d.ts +0 -9
- package/dist/types/SubPackages/react-test-renderer/jsx-promised/index.d.ts +0 -15
- package/dist/types/SubPackages/react-test-renderer/jsx-promised/node.d.ts +0 -5
- package/dist/types/SubPackages/react-test-renderer/jsx-promised/web.d.ts +0 -5
- package/dist/types/Types.d.ts +0 -61
- package/dist/types/Web.d.ts +0 -9
- package/dist/types/build.d.ts +0 -1
- package/dist/types/defaultConfig.d.ts +0 -3
- package/dist/types/esbuildConfigs/eslint-formatter-testeranto.d.ts +0 -2
- package/dist/types/esbuildConfigs/featuresPlugin.d.ts +0 -5
- package/dist/types/esbuildConfigs/index.d.ts +0 -4
- package/dist/types/esbuildConfigs/inputFilesPlugin.d.ts +0 -6
- package/dist/types/esbuildConfigs/node.d.ts +0 -4
- package/dist/types/esbuildConfigs/web.d.ts +0 -4
- package/dist/types/init-docs.d.ts +0 -1
- package/dist/types/lib/abstractBase.d.ts +0 -110
- package/dist/types/lib/basebuilder.d.ts +0 -27
- package/dist/types/lib/classBuilder.d.ts +0 -7
- package/dist/types/lib/core.d.ts +0 -7
- package/dist/types/lib/index.d.ts +0 -83
- package/dist/types/lib/types.d.ts +0 -14
- package/dist/types/puppeteerConfiger.d.ts +0 -4
- package/dist/types/run.d.ts +0 -1
- package/dist/types/tsconfig.types.tsbuildinfo +0 -1
- package/dist/types/utils.d.ts +0 -9
- package/dist/types/web.html.d.ts +0 -2
package/dist/prebuild/run.mjs
DELETED
|
@@ -1,1190 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module';const require = createRequire(import.meta.url);
|
|
2
|
-
|
|
3
|
-
// src/run.ts
|
|
4
|
-
import ansiC2 from "ansi-colors";
|
|
5
|
-
import { watch } from "fs";
|
|
6
|
-
import path3 from "path";
|
|
7
|
-
import crypto from "node:crypto";
|
|
8
|
-
import fs2 from "fs";
|
|
9
|
-
import tsc from "tsc-prog";
|
|
10
|
-
import { ESLint } from "eslint";
|
|
11
|
-
import ts from "typescript";
|
|
12
|
-
import readline from "readline";
|
|
13
|
-
|
|
14
|
-
// src/PM/main.ts
|
|
15
|
-
import fs from "fs";
|
|
16
|
-
import path2 from "path";
|
|
17
|
-
import puppeteer from "puppeteer-core";
|
|
18
|
-
import ansiC from "ansi-colors";
|
|
19
|
-
|
|
20
|
-
// src/utils.ts
|
|
21
|
-
import path from "path";
|
|
22
|
-
var tscPather = (entryPoint, platform) => {
|
|
23
|
-
return path.join(
|
|
24
|
-
"./docs/",
|
|
25
|
-
platform,
|
|
26
|
-
entryPoint.split(".").slice(0, -1).join("."),
|
|
27
|
-
`type_errors.txt`
|
|
28
|
-
);
|
|
29
|
-
};
|
|
30
|
-
var tscExitCodePather = (entryPoint, platform) => {
|
|
31
|
-
return path.join(
|
|
32
|
-
"./docs/",
|
|
33
|
-
platform,
|
|
34
|
-
entryPoint.split(".").slice(0, -1).join("."),
|
|
35
|
-
`type_errors.txt`
|
|
36
|
-
);
|
|
37
|
-
};
|
|
38
|
-
var lintPather = (entryPoint, platform) => {
|
|
39
|
-
return path.join(
|
|
40
|
-
"./docs/",
|
|
41
|
-
platform,
|
|
42
|
-
entryPoint.split(".").slice(0, -1).join("."),
|
|
43
|
-
`lint_errors.json`
|
|
44
|
-
);
|
|
45
|
-
};
|
|
46
|
-
var lintExitCodePather = (entryPoint, platform) => {
|
|
47
|
-
return path.join(
|
|
48
|
-
"./docs/",
|
|
49
|
-
platform,
|
|
50
|
-
entryPoint.split(".").slice(0, -1).join("."),
|
|
51
|
-
`lint_errors.txt`
|
|
52
|
-
);
|
|
53
|
-
};
|
|
54
|
-
var bddExitCodePather = (entryPoint, platform) => {
|
|
55
|
-
return path.join(
|
|
56
|
-
"./docs/",
|
|
57
|
-
platform,
|
|
58
|
-
entryPoint.split(".").slice(0, -1).join("."),
|
|
59
|
-
`bdd_errors.txt`
|
|
60
|
-
);
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
// src/PM/index.ts
|
|
64
|
-
var PM = class {
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
// src/PM/main.ts
|
|
68
|
-
var fileStreams3 = [];
|
|
69
|
-
var fPaths = [];
|
|
70
|
-
var files = {};
|
|
71
|
-
var recorders = {};
|
|
72
|
-
var screenshots = {};
|
|
73
|
-
var statusMessagePretty = (failures, test) => {
|
|
74
|
-
if (failures === 0) {
|
|
75
|
-
console.log(ansiC.green(ansiC.inverse(`> ${test} completed successfully`)));
|
|
76
|
-
} else {
|
|
77
|
-
console.log(ansiC.red(ansiC.inverse(`> ${test} failed ${failures} times`)));
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
async function writeFileAndCreateDir(filePath, data) {
|
|
81
|
-
const dirPath = path2.dirname(filePath);
|
|
82
|
-
try {
|
|
83
|
-
await fs.promises.mkdir(dirPath, { recursive: true });
|
|
84
|
-
await fs.appendFileSync(filePath, data);
|
|
85
|
-
} catch (error) {
|
|
86
|
-
console.error(`Error writing file: ${error}`);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
function isValidUrl(string) {
|
|
90
|
-
try {
|
|
91
|
-
new URL(string);
|
|
92
|
-
return true;
|
|
93
|
-
} catch (err) {
|
|
94
|
-
return false;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
var PM_Main = class extends PM {
|
|
98
|
-
constructor(configs) {
|
|
99
|
-
super();
|
|
100
|
-
this.shutdownMode = false;
|
|
101
|
-
this.bigBoard = {};
|
|
102
|
-
this.checkForShutdown = () => {
|
|
103
|
-
const anyRunning = Object.values(this.bigBoard).filter((x) => x.status === "running").length > 0;
|
|
104
|
-
if (anyRunning) {
|
|
105
|
-
} else {
|
|
106
|
-
this.browser.disconnect().then(() => {
|
|
107
|
-
const final = {
|
|
108
|
-
timestamp: Date.now(),
|
|
109
|
-
tests: this.configs.tests.reduce((mm, t) => {
|
|
110
|
-
const bddErrors = fs.readFileSync(bddExitCodePather(t[0], t[1])).toString();
|
|
111
|
-
const lintErrors = fs.readFileSync(lintExitCodePather(t[0], t[1])).toString();
|
|
112
|
-
const typeErrors = fs.readFileSync(tscExitCodePather(t[0], t[1])).toString();
|
|
113
|
-
mm[t[0]] = {
|
|
114
|
-
bddErrors,
|
|
115
|
-
lintErrors,
|
|
116
|
-
typeErrors
|
|
117
|
-
};
|
|
118
|
-
return mm;
|
|
119
|
-
}, {})
|
|
120
|
-
};
|
|
121
|
-
const s = JSON.stringify(final, null, 2);
|
|
122
|
-
fs.writeFileSync("docs/summary.json", s);
|
|
123
|
-
console.log(ansiC.inverse("Goodbye"));
|
|
124
|
-
process.exit();
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
this.testIsNowRunning = (src) => {
|
|
129
|
-
this.bigBoard[src].status = "running";
|
|
130
|
-
};
|
|
131
|
-
this.testIsNowDone = (src) => {
|
|
132
|
-
this.bigBoard[src].status = "waiting";
|
|
133
|
-
if (this.shutdownMode) {
|
|
134
|
-
this.checkForShutdown();
|
|
135
|
-
}
|
|
136
|
-
};
|
|
137
|
-
this.launchNode = async (src, dest) => {
|
|
138
|
-
console.log(ansiC.green(ansiC.inverse(`! node, ${src}`)));
|
|
139
|
-
this.testIsNowRunning(src);
|
|
140
|
-
const destFolder = dest.replace(".mjs", "");
|
|
141
|
-
let argz = "";
|
|
142
|
-
const testConfig = this.configs.tests.find((t) => {
|
|
143
|
-
return t[0] === src;
|
|
144
|
-
});
|
|
145
|
-
if (!testConfig) {
|
|
146
|
-
console.log(ansiC.inverse("missing test config! Exiting ungracefully!"));
|
|
147
|
-
process.exit(-1);
|
|
148
|
-
}
|
|
149
|
-
const testConfigResource = testConfig[2];
|
|
150
|
-
let portsToUse = [];
|
|
151
|
-
if (testConfigResource.ports === 0) {
|
|
152
|
-
argz = JSON.stringify({
|
|
153
|
-
scheduled: true,
|
|
154
|
-
name: src,
|
|
155
|
-
ports: portsToUse,
|
|
156
|
-
fs: destFolder,
|
|
157
|
-
browserWSEndpoint: this.browser.wsEndpoint()
|
|
158
|
-
});
|
|
159
|
-
} else if (testConfigResource.ports > 0) {
|
|
160
|
-
const openPorts = Object.entries(this.ports).filter(
|
|
161
|
-
([portnumber, portopen]) => portopen
|
|
162
|
-
);
|
|
163
|
-
if (openPorts.length >= testConfigResource.ports) {
|
|
164
|
-
for (let i = 0; i < testConfigResource.ports; i++) {
|
|
165
|
-
portsToUse.push(openPorts[i][0]);
|
|
166
|
-
this.ports[openPorts[i][0]] = false;
|
|
167
|
-
}
|
|
168
|
-
argz = JSON.stringify({
|
|
169
|
-
scheduled: true,
|
|
170
|
-
name: src,
|
|
171
|
-
// ports: [3333],
|
|
172
|
-
ports: portsToUse,
|
|
173
|
-
fs: destFolder,
|
|
174
|
-
browserWSEndpoint: this.browser.wsEndpoint()
|
|
175
|
-
});
|
|
176
|
-
} else {
|
|
177
|
-
this.queue.push(src);
|
|
178
|
-
return;
|
|
179
|
-
}
|
|
180
|
-
} else {
|
|
181
|
-
console.error("negative port makes no sense", src);
|
|
182
|
-
process.exit(-1);
|
|
183
|
-
}
|
|
184
|
-
const builtfile = dest;
|
|
185
|
-
const webSideCares = [];
|
|
186
|
-
this.server[builtfile] = await import(`${builtfile}?cacheBust=${Date.now()}`).then((module) => {
|
|
187
|
-
return module.default.then((defaultModule) => {
|
|
188
|
-
defaultModule.receiveTestResourceConfig(argz).then(async ({ features, failed }) => {
|
|
189
|
-
this.receiveFeatures(features, destFolder, src);
|
|
190
|
-
statusMessagePretty(failed, src);
|
|
191
|
-
this.receiveExitCode(src, failed);
|
|
192
|
-
}).catch((e) => {
|
|
193
|
-
console.log(ansiC.red(ansiC.inverse(`${src} errored with: ${e}`)));
|
|
194
|
-
}).finally(() => {
|
|
195
|
-
webSideCares.forEach((webSideCar) => webSideCar.close());
|
|
196
|
-
this.testIsNowDone(src);
|
|
197
|
-
});
|
|
198
|
-
});
|
|
199
|
-
});
|
|
200
|
-
for (let i = 0; i <= portsToUse.length; i++) {
|
|
201
|
-
if (portsToUse[i]) {
|
|
202
|
-
this.ports[portsToUse[i]] = "true";
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
};
|
|
206
|
-
this.launchWebSideCar = async (src, dest, testConfig) => {
|
|
207
|
-
const d = dest + ".mjs";
|
|
208
|
-
console.log(ansiC.green(ansiC.inverse(`launchWebSideCar ${src}`)));
|
|
209
|
-
const destFolder = dest.replace(".mjs", "");
|
|
210
|
-
const fileStreams2 = [];
|
|
211
|
-
const doneFileStream2 = [];
|
|
212
|
-
return new Promise((res, rej) => {
|
|
213
|
-
this.browser.newPage().then((page) => {
|
|
214
|
-
page.exposeFunction(
|
|
215
|
-
"custom-screenshot",
|
|
216
|
-
async (ssOpts, testName) => {
|
|
217
|
-
const p = ssOpts.path;
|
|
218
|
-
const dir = path2.dirname(p);
|
|
219
|
-
fs.mkdirSync(dir, {
|
|
220
|
-
recursive: true
|
|
221
|
-
});
|
|
222
|
-
files[testName].add(ssOpts.path);
|
|
223
|
-
const sPromise = page.screenshot({
|
|
224
|
-
...ssOpts,
|
|
225
|
-
path: p
|
|
226
|
-
});
|
|
227
|
-
if (!screenshots[testName]) {
|
|
228
|
-
screenshots[testName] = [];
|
|
229
|
-
}
|
|
230
|
-
screenshots[testName].push(sPromise);
|
|
231
|
-
await sPromise;
|
|
232
|
-
return sPromise;
|
|
233
|
-
}
|
|
234
|
-
);
|
|
235
|
-
page.exposeFunction(
|
|
236
|
-
"writeFileSync",
|
|
237
|
-
(fp, contents, testName) => {
|
|
238
|
-
const dir = path2.dirname(fp);
|
|
239
|
-
fs.mkdirSync(dir, {
|
|
240
|
-
recursive: true
|
|
241
|
-
});
|
|
242
|
-
const p = new Promise(async (res2, rej2) => {
|
|
243
|
-
fs.writeFileSync(fp, contents);
|
|
244
|
-
res2(fp);
|
|
245
|
-
});
|
|
246
|
-
doneFileStream2.push(p);
|
|
247
|
-
if (!files[testName]) {
|
|
248
|
-
files[testName] = /* @__PURE__ */ new Set();
|
|
249
|
-
}
|
|
250
|
-
files[testName].add(fp);
|
|
251
|
-
return p;
|
|
252
|
-
}
|
|
253
|
-
);
|
|
254
|
-
page.exposeFunction("existsSync", (fp, contents) => {
|
|
255
|
-
return fs.existsSync(fp);
|
|
256
|
-
});
|
|
257
|
-
page.exposeFunction("mkdirSync", (fp) => {
|
|
258
|
-
if (!fs.existsSync(fp)) {
|
|
259
|
-
return fs.mkdirSync(fp, {
|
|
260
|
-
recursive: true
|
|
261
|
-
});
|
|
262
|
-
}
|
|
263
|
-
return false;
|
|
264
|
-
});
|
|
265
|
-
page.exposeFunction(
|
|
266
|
-
"createWriteStream",
|
|
267
|
-
(fp, testName) => {
|
|
268
|
-
const f = fs.createWriteStream(fp);
|
|
269
|
-
files[testName].add(fp);
|
|
270
|
-
const p = new Promise((res2, rej2) => {
|
|
271
|
-
res2(fp);
|
|
272
|
-
});
|
|
273
|
-
doneFileStream2.push(p);
|
|
274
|
-
f.on("close", async () => {
|
|
275
|
-
await p;
|
|
276
|
-
});
|
|
277
|
-
fileStreams2.push(f);
|
|
278
|
-
return {
|
|
279
|
-
...JSON.parse(JSON.stringify(f)),
|
|
280
|
-
uid: fileStreams2.length - 1
|
|
281
|
-
};
|
|
282
|
-
}
|
|
283
|
-
);
|
|
284
|
-
page.exposeFunction(
|
|
285
|
-
"write",
|
|
286
|
-
async (uid, contents) => {
|
|
287
|
-
return fileStreams2[uid].write(contents);
|
|
288
|
-
}
|
|
289
|
-
);
|
|
290
|
-
page.exposeFunction("end", async (uid) => {
|
|
291
|
-
return fileStreams2[uid].end();
|
|
292
|
-
});
|
|
293
|
-
return page;
|
|
294
|
-
}).then(async (page) => {
|
|
295
|
-
await page.goto(`file://${`${dest}.html`}`, {});
|
|
296
|
-
res(page);
|
|
297
|
-
});
|
|
298
|
-
});
|
|
299
|
-
};
|
|
300
|
-
this.launchNodeSideCar = async (src, dest, testConfig) => {
|
|
301
|
-
const d = dest + ".mjs";
|
|
302
|
-
console.log(ansiC.green(ansiC.inverse(`launchNodeSideCar ${src}`)));
|
|
303
|
-
const destFolder = dest.replace(".mjs", "");
|
|
304
|
-
let argz = "";
|
|
305
|
-
const testConfigResource = testConfig[2];
|
|
306
|
-
let portsToUse = [];
|
|
307
|
-
if (testConfigResource.ports === 0) {
|
|
308
|
-
argz = JSON.stringify({
|
|
309
|
-
scheduled: true,
|
|
310
|
-
name: src,
|
|
311
|
-
ports: portsToUse,
|
|
312
|
-
fs: destFolder,
|
|
313
|
-
browserWSEndpoint: this.browser.wsEndpoint()
|
|
314
|
-
});
|
|
315
|
-
} else if (testConfigResource.ports > 0) {
|
|
316
|
-
const openPorts = Object.entries(this.ports).filter(
|
|
317
|
-
([portnumber, portopen]) => portopen
|
|
318
|
-
);
|
|
319
|
-
if (openPorts.length >= testConfigResource.ports) {
|
|
320
|
-
for (let i = 0; i < testConfigResource.ports; i++) {
|
|
321
|
-
portsToUse.push(openPorts[i][0]);
|
|
322
|
-
this.ports[openPorts[i][0]] = false;
|
|
323
|
-
}
|
|
324
|
-
argz = JSON.stringify({
|
|
325
|
-
scheduled: true,
|
|
326
|
-
name: src,
|
|
327
|
-
// ports: [3333],
|
|
328
|
-
ports: portsToUse,
|
|
329
|
-
fs: ".",
|
|
330
|
-
browserWSEndpoint: this.browser.wsEndpoint()
|
|
331
|
-
});
|
|
332
|
-
} else {
|
|
333
|
-
this.queue.push(src);
|
|
334
|
-
return;
|
|
335
|
-
}
|
|
336
|
-
} else {
|
|
337
|
-
console.error("negative port makes no sense", src);
|
|
338
|
-
process.exit(-1);
|
|
339
|
-
}
|
|
340
|
-
const builtfile = dest + ".mjs";
|
|
341
|
-
this.server[builtfile] = await import(`${builtfile}?cacheBust=${Date.now()}`).then((module) => {
|
|
342
|
-
return module.default.then((defaultModule) => {
|
|
343
|
-
const s = new defaultModule();
|
|
344
|
-
s.receiveTestResourceConfig(argz);
|
|
345
|
-
});
|
|
346
|
-
});
|
|
347
|
-
for (let i = 0; i <= portsToUse.length; i++) {
|
|
348
|
-
if (portsToUse[i]) {
|
|
349
|
-
this.ports[portsToUse[i]] = "true";
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
};
|
|
353
|
-
this.launchWeb = (t, dest) => {
|
|
354
|
-
console.log(ansiC.green(ansiC.inverse(`! web ${t}`)));
|
|
355
|
-
this.testIsNowRunning(t);
|
|
356
|
-
const destFolder = dest.replace(".mjs", "");
|
|
357
|
-
const webArgz = JSON.stringify({
|
|
358
|
-
name: dest,
|
|
359
|
-
ports: [].toString(),
|
|
360
|
-
fs: destFolder,
|
|
361
|
-
browserWSEndpoint: this.browser.wsEndpoint()
|
|
362
|
-
});
|
|
363
|
-
const d = `${dest}?cacheBust=${Date.now()}`;
|
|
364
|
-
const evaluation = `
|
|
365
|
-
|
|
366
|
-
import('${d}').then(async (x) => {
|
|
367
|
-
|
|
368
|
-
try {
|
|
369
|
-
return await (await x.default).receiveTestResourceConfig(${webArgz})
|
|
370
|
-
} catch (e) {
|
|
371
|
-
console.log("fail", e)
|
|
372
|
-
}
|
|
373
|
-
})`;
|
|
374
|
-
const fileStreams2 = [];
|
|
375
|
-
const doneFileStream2 = [];
|
|
376
|
-
const stdoutStream = fs.createWriteStream(`${destFolder}/stdout.log`);
|
|
377
|
-
const stderrStream = fs.createWriteStream(`${destFolder}/stderr.log`);
|
|
378
|
-
this.browser.newPage().then((page) => {
|
|
379
|
-
page.exposeFunction(
|
|
380
|
-
"screencast",
|
|
381
|
-
async (ssOpts, testName) => {
|
|
382
|
-
const p = ssOpts.path;
|
|
383
|
-
const dir = path2.dirname(p);
|
|
384
|
-
fs.mkdirSync(dir, {
|
|
385
|
-
recursive: true
|
|
386
|
-
});
|
|
387
|
-
if (!files[testName]) {
|
|
388
|
-
files[testName] = /* @__PURE__ */ new Set();
|
|
389
|
-
}
|
|
390
|
-
files[testName].add(ssOpts.path);
|
|
391
|
-
const sPromise = page.screenshot({
|
|
392
|
-
...ssOpts,
|
|
393
|
-
path: p
|
|
394
|
-
});
|
|
395
|
-
if (!screenshots[testName]) {
|
|
396
|
-
screenshots[testName] = [];
|
|
397
|
-
}
|
|
398
|
-
screenshots[testName].push(sPromise);
|
|
399
|
-
await sPromise;
|
|
400
|
-
return sPromise;
|
|
401
|
-
}
|
|
402
|
-
);
|
|
403
|
-
page.exposeFunction(
|
|
404
|
-
"customScreenShot",
|
|
405
|
-
async (ssOpts, testName) => {
|
|
406
|
-
const p = ssOpts.path;
|
|
407
|
-
const dir = path2.dirname(p);
|
|
408
|
-
fs.mkdirSync(dir, {
|
|
409
|
-
recursive: true
|
|
410
|
-
});
|
|
411
|
-
if (!files[testName]) {
|
|
412
|
-
files[testName] = /* @__PURE__ */ new Set();
|
|
413
|
-
}
|
|
414
|
-
files[testName].add(ssOpts.path);
|
|
415
|
-
const sPromise = page.screenshot({
|
|
416
|
-
...ssOpts,
|
|
417
|
-
path: p
|
|
418
|
-
});
|
|
419
|
-
if (!screenshots[testName]) {
|
|
420
|
-
screenshots[testName] = [];
|
|
421
|
-
}
|
|
422
|
-
screenshots[testName].push(sPromise);
|
|
423
|
-
await sPromise;
|
|
424
|
-
return sPromise;
|
|
425
|
-
}
|
|
426
|
-
);
|
|
427
|
-
page.exposeFunction(
|
|
428
|
-
"writeFileSync",
|
|
429
|
-
(fp, contents, testName) => {
|
|
430
|
-
return globalThis["writeFileSync"](fp, contents, testName);
|
|
431
|
-
}
|
|
432
|
-
);
|
|
433
|
-
page.exposeFunction("existsSync", (fp, contents) => {
|
|
434
|
-
return fs.existsSync(fp);
|
|
435
|
-
});
|
|
436
|
-
page.exposeFunction("mkdirSync", (fp) => {
|
|
437
|
-
if (!fs.existsSync(fp)) {
|
|
438
|
-
return fs.mkdirSync(fp, {
|
|
439
|
-
recursive: true
|
|
440
|
-
});
|
|
441
|
-
}
|
|
442
|
-
return false;
|
|
443
|
-
});
|
|
444
|
-
page.exposeFunction(
|
|
445
|
-
"createWriteStream",
|
|
446
|
-
(fp, testName) => {
|
|
447
|
-
const f = fs.createWriteStream(fp);
|
|
448
|
-
if (!files[testName]) {
|
|
449
|
-
files[testName] = /* @__PURE__ */ new Set();
|
|
450
|
-
}
|
|
451
|
-
files[testName].add(fp);
|
|
452
|
-
const p = new Promise((res, rej) => {
|
|
453
|
-
res(fp);
|
|
454
|
-
});
|
|
455
|
-
doneFileStream2.push(p);
|
|
456
|
-
f.on("close", async () => {
|
|
457
|
-
await p;
|
|
458
|
-
});
|
|
459
|
-
fileStreams2.push(f);
|
|
460
|
-
return {
|
|
461
|
-
...JSON.parse(JSON.stringify(f)),
|
|
462
|
-
uid: fileStreams2.length - 1
|
|
463
|
-
};
|
|
464
|
-
}
|
|
465
|
-
);
|
|
466
|
-
page.exposeFunction("write", async (uid, contents) => {
|
|
467
|
-
return fileStreams2[uid].write(contents);
|
|
468
|
-
});
|
|
469
|
-
page.exposeFunction("end", async (uid) => {
|
|
470
|
-
return fileStreams2[uid].end();
|
|
471
|
-
});
|
|
472
|
-
page.exposeFunction("page", () => {
|
|
473
|
-
return page.mainFrame()._id;
|
|
474
|
-
});
|
|
475
|
-
page.exposeFunction("click", (sel) => {
|
|
476
|
-
return page.click(sel);
|
|
477
|
-
});
|
|
478
|
-
page.exposeFunction("focusOn", (sel) => {
|
|
479
|
-
return page.focus(sel);
|
|
480
|
-
});
|
|
481
|
-
page.exposeFunction(
|
|
482
|
-
"typeInto",
|
|
483
|
-
async (value) => await page.keyboard.type(value)
|
|
484
|
-
);
|
|
485
|
-
page.exposeFunction(
|
|
486
|
-
"getValue",
|
|
487
|
-
(selector) => page.$eval(selector, (input) => input.getAttribute("value"))
|
|
488
|
-
);
|
|
489
|
-
page.exposeFunction(
|
|
490
|
-
"getAttribute",
|
|
491
|
-
async (selector, attribute) => {
|
|
492
|
-
const attributeValue = await page.$eval(selector, (input) => {
|
|
493
|
-
return input.getAttribute(attribute);
|
|
494
|
-
});
|
|
495
|
-
return attributeValue;
|
|
496
|
-
}
|
|
497
|
-
);
|
|
498
|
-
page.exposeFunction("isDisabled", async (selector) => {
|
|
499
|
-
const attributeValue = await page.$eval(
|
|
500
|
-
selector,
|
|
501
|
-
(input) => {
|
|
502
|
-
return input.disabled;
|
|
503
|
-
}
|
|
504
|
-
);
|
|
505
|
-
return attributeValue;
|
|
506
|
-
});
|
|
507
|
-
page.exposeFunction("$", async (selector) => {
|
|
508
|
-
const x = page.$(selector);
|
|
509
|
-
const y = await x;
|
|
510
|
-
return y;
|
|
511
|
-
});
|
|
512
|
-
return page;
|
|
513
|
-
}).then(async (page) => {
|
|
514
|
-
const close = () => {
|
|
515
|
-
if (!files[t]) {
|
|
516
|
-
files[t] = /* @__PURE__ */ new Set();
|
|
517
|
-
}
|
|
518
|
-
fs.writeFileSync(
|
|
519
|
-
destFolder + "/manifest.json",
|
|
520
|
-
JSON.stringify(Array.from(files[t]))
|
|
521
|
-
);
|
|
522
|
-
delete files[t];
|
|
523
|
-
Promise.all(screenshots[t] || []).then(() => {
|
|
524
|
-
delete screenshots[t];
|
|
525
|
-
page.close();
|
|
526
|
-
this.testIsNowDone(t);
|
|
527
|
-
stderrStream.close();
|
|
528
|
-
stdoutStream.close();
|
|
529
|
-
});
|
|
530
|
-
};
|
|
531
|
-
page.on("pageerror", (err) => {
|
|
532
|
-
console.debug(`Error from ${t}: [${err.name}] `);
|
|
533
|
-
stderrStream.write(err.name);
|
|
534
|
-
if (err.cause) {
|
|
535
|
-
console.debug(`Error from ${t} cause: [${err.cause}] `);
|
|
536
|
-
stderrStream.write(err.cause);
|
|
537
|
-
}
|
|
538
|
-
if (err.stack) {
|
|
539
|
-
console.debug(`Error from stack ${t}: [${err.stack}] `);
|
|
540
|
-
stderrStream.write(err.stack);
|
|
541
|
-
}
|
|
542
|
-
console.debug(`Error from message ${t}: [${err.message}] `);
|
|
543
|
-
stderrStream.write(err.message);
|
|
544
|
-
close();
|
|
545
|
-
});
|
|
546
|
-
page.on("console", (log) => {
|
|
547
|
-
stdoutStream.write(log.text());
|
|
548
|
-
stdoutStream.write(JSON.stringify(log.location()));
|
|
549
|
-
stdoutStream.write(JSON.stringify(log.stackTrace()));
|
|
550
|
-
});
|
|
551
|
-
await page.goto(`file://${`${destFolder}.html`}`, {});
|
|
552
|
-
await page.evaluate(evaluation).then(async ({ failed, features }) => {
|
|
553
|
-
this.receiveFeatures(features, destFolder, t);
|
|
554
|
-
statusMessagePretty(failed, t);
|
|
555
|
-
this.receiveExitCode(t, failed);
|
|
556
|
-
}).catch((e) => {
|
|
557
|
-
console.log(ansiC.red(ansiC.inverse(`${t} errored with: ${e}`)));
|
|
558
|
-
}).finally(() => {
|
|
559
|
-
close();
|
|
560
|
-
});
|
|
561
|
-
return page;
|
|
562
|
-
});
|
|
563
|
-
};
|
|
564
|
-
this.receiveFeatures = (features, destFolder, srcTest) => {
|
|
565
|
-
const featureDestination = path2.resolve(
|
|
566
|
-
process.cwd(),
|
|
567
|
-
"docs",
|
|
568
|
-
"features",
|
|
569
|
-
"strings",
|
|
570
|
-
srcTest.split(".").slice(0, -1).join(".") + ".features.txt"
|
|
571
|
-
);
|
|
572
|
-
features.reduce(async (mm, featureStringKey) => {
|
|
573
|
-
const accum = await mm;
|
|
574
|
-
const isUrl = isValidUrl(featureStringKey);
|
|
575
|
-
if (isUrl) {
|
|
576
|
-
const u = new URL(featureStringKey);
|
|
577
|
-
if (u.protocol === "file:") {
|
|
578
|
-
const newPath = `${process.cwd()}/docs/features/internal/${path2.relative(
|
|
579
|
-
process.cwd(),
|
|
580
|
-
u.pathname
|
|
581
|
-
)}`;
|
|
582
|
-
await fs.promises.mkdir(path2.dirname(newPath), { recursive: true });
|
|
583
|
-
try {
|
|
584
|
-
await fs.unlinkSync(newPath);
|
|
585
|
-
} catch (error) {
|
|
586
|
-
if (error.code !== "ENOENT") {
|
|
587
|
-
}
|
|
588
|
-
}
|
|
589
|
-
accum.files.push(newPath);
|
|
590
|
-
} else if (u.protocol === "http:" || u.protocol === "https:") {
|
|
591
|
-
const newPath = `${process.cwd()}/docs/features/external${u.hostname}${u.pathname}`;
|
|
592
|
-
const body = await this.configs.featureIngestor(featureStringKey);
|
|
593
|
-
writeFileAndCreateDir(newPath, body);
|
|
594
|
-
accum.files.push(newPath);
|
|
595
|
-
}
|
|
596
|
-
} else {
|
|
597
|
-
await fs.promises.mkdir(path2.dirname(featureDestination), {
|
|
598
|
-
recursive: true
|
|
599
|
-
});
|
|
600
|
-
accum.strings.push(featureStringKey);
|
|
601
|
-
}
|
|
602
|
-
return accum;
|
|
603
|
-
}, Promise.resolve({ files: [], strings: [] })).then(({ files: files2, strings }) => {
|
|
604
|
-
fs.writeFileSync(
|
|
605
|
-
`${destFolder}/featurePrompt.txt`,
|
|
606
|
-
files2.map((f) => {
|
|
607
|
-
return `/read ${f}`;
|
|
608
|
-
}).join("\n")
|
|
609
|
-
);
|
|
610
|
-
});
|
|
611
|
-
this.writeBigBoard();
|
|
612
|
-
};
|
|
613
|
-
this.receiveExitCode = (srcTest, failures) => {
|
|
614
|
-
this.bigBoard[srcTest].runTimeError = failures;
|
|
615
|
-
this.writeBigBoard();
|
|
616
|
-
};
|
|
617
|
-
this.writeBigBoard = () => {
|
|
618
|
-
fs.writeFileSync(
|
|
619
|
-
"./docs/bigBoard.json",
|
|
620
|
-
JSON.stringify(this.bigBoard, null, 2)
|
|
621
|
-
);
|
|
622
|
-
};
|
|
623
|
-
this.server = {};
|
|
624
|
-
this.configs = configs;
|
|
625
|
-
this.ports = {};
|
|
626
|
-
this.configs.tests.forEach(([t]) => {
|
|
627
|
-
this.bigBoard[t] = {
|
|
628
|
-
status: "?"
|
|
629
|
-
};
|
|
630
|
-
});
|
|
631
|
-
this.configs.ports.forEach((element) => {
|
|
632
|
-
this.ports[element] = "true";
|
|
633
|
-
});
|
|
634
|
-
globalThis["waitForSelector"] = async (pageKey, sel) => {
|
|
635
|
-
const page = (await this.browser.pages()).find(
|
|
636
|
-
/* @ts-ignore:next-line */
|
|
637
|
-
(p) => p.mainFrame()._id === pageKey
|
|
638
|
-
);
|
|
639
|
-
await page?.waitForSelector(sel);
|
|
640
|
-
};
|
|
641
|
-
globalThis["screencastStop"] = async (path4) => {
|
|
642
|
-
return recorders[path4].stop();
|
|
643
|
-
};
|
|
644
|
-
globalThis["closePage"] = async (pageKey) => {
|
|
645
|
-
const page = (await this.browser.pages()).find(
|
|
646
|
-
/* @ts-ignore:next-line */
|
|
647
|
-
(p) => p.mainFrame()._id === pageKey
|
|
648
|
-
);
|
|
649
|
-
return page.close();
|
|
650
|
-
};
|
|
651
|
-
globalThis["goto"] = async (pageKey, url) => {
|
|
652
|
-
const page = (await this.browser.pages()).find(
|
|
653
|
-
/* @ts-ignore:next-line */
|
|
654
|
-
(p) => p.mainFrame()._id === pageKey
|
|
655
|
-
);
|
|
656
|
-
await page?.goto(url);
|
|
657
|
-
return;
|
|
658
|
-
};
|
|
659
|
-
globalThis["newPage"] = () => {
|
|
660
|
-
return this.browser.newPage();
|
|
661
|
-
};
|
|
662
|
-
globalThis["pages"] = () => {
|
|
663
|
-
return this.browser.pages();
|
|
664
|
-
};
|
|
665
|
-
globalThis["mkdirSync"] = (fp) => {
|
|
666
|
-
if (!fs.existsSync(fp)) {
|
|
667
|
-
return fs.mkdirSync(fp, {
|
|
668
|
-
recursive: true
|
|
669
|
-
});
|
|
670
|
-
}
|
|
671
|
-
return false;
|
|
672
|
-
};
|
|
673
|
-
globalThis["writeFileSync"] = (filepath, contents, testName) => {
|
|
674
|
-
fs.mkdirSync(path2.dirname(filepath), {
|
|
675
|
-
recursive: true
|
|
676
|
-
});
|
|
677
|
-
if (!files[testName]) {
|
|
678
|
-
files[testName] = /* @__PURE__ */ new Set();
|
|
679
|
-
}
|
|
680
|
-
files[testName].add(filepath);
|
|
681
|
-
return fs.writeFileSync(filepath, contents);
|
|
682
|
-
};
|
|
683
|
-
globalThis["createWriteStream"] = (filepath, testName) => {
|
|
684
|
-
const f = fs.createWriteStream(filepath);
|
|
685
|
-
fileStreams3.push(f);
|
|
686
|
-
if (!files[testName]) {
|
|
687
|
-
files[testName] = /* @__PURE__ */ new Set();
|
|
688
|
-
}
|
|
689
|
-
files[testName].add(filepath);
|
|
690
|
-
return {
|
|
691
|
-
...JSON.parse(JSON.stringify(f)),
|
|
692
|
-
uid: fileStreams3.length - 1
|
|
693
|
-
};
|
|
694
|
-
};
|
|
695
|
-
globalThis["write"] = (uid, contents) => {
|
|
696
|
-
fileStreams3[uid].write(contents);
|
|
697
|
-
};
|
|
698
|
-
globalThis["end"] = (uid) => {
|
|
699
|
-
fileStreams3[uid].end();
|
|
700
|
-
};
|
|
701
|
-
globalThis["customScreenShot"] = async (opts, pageKey, testName) => {
|
|
702
|
-
const page = (await this.browser.pages()).find(
|
|
703
|
-
/* @ts-ignore:next-line */
|
|
704
|
-
(p2) => p2.mainFrame()._id === pageKey
|
|
705
|
-
);
|
|
706
|
-
const p = opts.path;
|
|
707
|
-
const dir = path2.dirname(p);
|
|
708
|
-
fs.mkdirSync(dir, {
|
|
709
|
-
recursive: true
|
|
710
|
-
});
|
|
711
|
-
if (!files[opts.path]) {
|
|
712
|
-
files[opts.path] = /* @__PURE__ */ new Set();
|
|
713
|
-
}
|
|
714
|
-
files[opts.path].add(opts.path);
|
|
715
|
-
const sPromise = page.screenshot({
|
|
716
|
-
...opts,
|
|
717
|
-
path: p
|
|
718
|
-
});
|
|
719
|
-
if (!screenshots[opts.path]) {
|
|
720
|
-
screenshots[opts.path] = [];
|
|
721
|
-
}
|
|
722
|
-
screenshots[opts.path].push(sPromise);
|
|
723
|
-
await sPromise;
|
|
724
|
-
return sPromise;
|
|
725
|
-
};
|
|
726
|
-
globalThis["screencast"] = async (opts, pageKey) => {
|
|
727
|
-
const page = (await this.browser.pages()).find(
|
|
728
|
-
/* @ts-ignore:next-line */
|
|
729
|
-
(p2) => p2.mainFrame()._id === pageKey
|
|
730
|
-
);
|
|
731
|
-
const p = opts.path;
|
|
732
|
-
const dir = path2.dirname(p);
|
|
733
|
-
fs.mkdirSync(dir, {
|
|
734
|
-
recursive: true
|
|
735
|
-
});
|
|
736
|
-
const recorder = await page?.screencast({
|
|
737
|
-
...opts,
|
|
738
|
-
path: p
|
|
739
|
-
});
|
|
740
|
-
recorders[opts.path] = recorder;
|
|
741
|
-
return opts.path;
|
|
742
|
-
};
|
|
743
|
-
}
|
|
744
|
-
customclose() {
|
|
745
|
-
throw new Error("Method not implemented.");
|
|
746
|
-
}
|
|
747
|
-
waitForSelector(p, s) {
|
|
748
|
-
throw new Error("Method not implemented.");
|
|
749
|
-
}
|
|
750
|
-
closePage(p) {
|
|
751
|
-
throw new Error("Method not implemented.");
|
|
752
|
-
}
|
|
753
|
-
newPage() {
|
|
754
|
-
throw new Error("Method not implemented.");
|
|
755
|
-
}
|
|
756
|
-
goto(p, url) {
|
|
757
|
-
throw new Error("Method not implemented.");
|
|
758
|
-
}
|
|
759
|
-
$(selector) {
|
|
760
|
-
throw new Error("Method not implemented.");
|
|
761
|
-
}
|
|
762
|
-
screencast(opts) {
|
|
763
|
-
throw new Error("Method not implemented.");
|
|
764
|
-
}
|
|
765
|
-
customScreenShot(opts, cdpPage) {
|
|
766
|
-
throw new Error("Method not implemented.");
|
|
767
|
-
}
|
|
768
|
-
end(accessObject) {
|
|
769
|
-
throw new Error("Method not implemented.");
|
|
770
|
-
}
|
|
771
|
-
existsSync(destFolder) {
|
|
772
|
-
return fs.existsSync(destFolder);
|
|
773
|
-
}
|
|
774
|
-
async mkdirSync(fp) {
|
|
775
|
-
if (!fs.existsSync(fp)) {
|
|
776
|
-
return fs.mkdirSync(fp, {
|
|
777
|
-
recursive: true
|
|
778
|
-
});
|
|
779
|
-
}
|
|
780
|
-
return false;
|
|
781
|
-
}
|
|
782
|
-
writeFileSync(fp, contents) {
|
|
783
|
-
fs.writeFileSync(fp, contents);
|
|
784
|
-
}
|
|
785
|
-
createWriteStream(filepath) {
|
|
786
|
-
return fs.createWriteStream(filepath);
|
|
787
|
-
}
|
|
788
|
-
testArtiFactoryfileWriter(tLog, callback) {
|
|
789
|
-
return (fPath, value) => {
|
|
790
|
-
callback(
|
|
791
|
-
new Promise((res, rej) => {
|
|
792
|
-
tLog("testArtiFactory =>", fPath);
|
|
793
|
-
const cleanPath = path2.resolve(fPath);
|
|
794
|
-
fPaths.push(cleanPath.replace(process.cwd(), ``));
|
|
795
|
-
const targetDir = cleanPath.split("/").slice(0, -1).join("/");
|
|
796
|
-
fs.mkdir(targetDir, { recursive: true }, async (error) => {
|
|
797
|
-
if (error) {
|
|
798
|
-
console.error(`\u2757\uFE0FtestArtiFactory failed`, targetDir, error);
|
|
799
|
-
}
|
|
800
|
-
fs.writeFileSync(
|
|
801
|
-
path2.resolve(
|
|
802
|
-
targetDir.split("/").slice(0, -1).join("/"),
|
|
803
|
-
"manifest"
|
|
804
|
-
),
|
|
805
|
-
fPaths.join(`
|
|
806
|
-
`),
|
|
807
|
-
{
|
|
808
|
-
encoding: "utf-8"
|
|
809
|
-
}
|
|
810
|
-
);
|
|
811
|
-
if (Buffer.isBuffer(value)) {
|
|
812
|
-
fs.writeFileSync(fPath, value, "binary");
|
|
813
|
-
res();
|
|
814
|
-
} else if (`string` === typeof value) {
|
|
815
|
-
fs.writeFileSync(fPath, value.toString(), {
|
|
816
|
-
encoding: "utf-8"
|
|
817
|
-
});
|
|
818
|
-
res();
|
|
819
|
-
} else {
|
|
820
|
-
const pipeStream = value;
|
|
821
|
-
const myFile = fs.createWriteStream(fPath);
|
|
822
|
-
pipeStream.pipe(myFile);
|
|
823
|
-
pipeStream.on("close", () => {
|
|
824
|
-
myFile.close();
|
|
825
|
-
res();
|
|
826
|
-
});
|
|
827
|
-
}
|
|
828
|
-
});
|
|
829
|
-
})
|
|
830
|
-
);
|
|
831
|
-
};
|
|
832
|
-
}
|
|
833
|
-
write(accessObject, contents) {
|
|
834
|
-
throw new Error("Method not implemented.");
|
|
835
|
-
}
|
|
836
|
-
page() {
|
|
837
|
-
throw new Error("Method not implemented.");
|
|
838
|
-
}
|
|
839
|
-
click(selector) {
|
|
840
|
-
throw new Error("Method not implemented.");
|
|
841
|
-
}
|
|
842
|
-
focusOn(selector) {
|
|
843
|
-
throw new Error("Method not implemented.");
|
|
844
|
-
}
|
|
845
|
-
typeInto(value) {
|
|
846
|
-
throw new Error("Method not implemented.");
|
|
847
|
-
}
|
|
848
|
-
getValue(value) {
|
|
849
|
-
throw new Error("Method not implemented.");
|
|
850
|
-
}
|
|
851
|
-
getAttribute(selector, attribute) {
|
|
852
|
-
throw new Error("Method not implemented.");
|
|
853
|
-
}
|
|
854
|
-
isDisabled(selector) {
|
|
855
|
-
throw new Error("Method not implemented.");
|
|
856
|
-
}
|
|
857
|
-
screencastStop(s) {
|
|
858
|
-
throw new Error("Method not implemented.");
|
|
859
|
-
}
|
|
860
|
-
////////////////////////////////////////////////////////////////////////////////
|
|
861
|
-
async startPuppeteer(options, destfolder) {
|
|
862
|
-
this.browser = await puppeteer.launch(options);
|
|
863
|
-
}
|
|
864
|
-
// goodbye = () => {
|
|
865
|
-
// this.browser.disconnect().then(() => {
|
|
866
|
-
// console.log("Goodbye");
|
|
867
|
-
// process.exit();
|
|
868
|
-
// });
|
|
869
|
-
// };
|
|
870
|
-
shutDown() {
|
|
871
|
-
this.shutdownMode = true;
|
|
872
|
-
this.checkForShutdown();
|
|
873
|
-
}
|
|
874
|
-
};
|
|
875
|
-
|
|
876
|
-
// src/run.ts
|
|
877
|
-
console.log(ansiC2.inverse("Press 'x' to shutdown forcefully."));
|
|
878
|
-
readline.emitKeypressEvents(process.stdin);
|
|
879
|
-
if (process.stdin.isTTY)
|
|
880
|
-
process.stdin.setRawMode(true);
|
|
881
|
-
process.stdin.on("keypress", (str, key) => {
|
|
882
|
-
if (key.name === "x") {
|
|
883
|
-
console.log(ansiC2.inverse("Shutting down forcefully..."));
|
|
884
|
-
process.exit(-1);
|
|
885
|
-
}
|
|
886
|
-
});
|
|
887
|
-
async function fileHash(filePath, algorithm = "md5") {
|
|
888
|
-
return new Promise((resolve, reject) => {
|
|
889
|
-
const hash = crypto.createHash(algorithm);
|
|
890
|
-
const fileStream = fs2.createReadStream(filePath);
|
|
891
|
-
fileStream.on("data", (data) => {
|
|
892
|
-
hash.update(data);
|
|
893
|
-
});
|
|
894
|
-
fileStream.on("end", () => {
|
|
895
|
-
const fileHash2 = hash.digest("hex");
|
|
896
|
-
resolve(fileHash2);
|
|
897
|
-
});
|
|
898
|
-
fileStream.on("error", (error) => {
|
|
899
|
-
reject(`Error reading file: ${error.message}`);
|
|
900
|
-
});
|
|
901
|
-
});
|
|
902
|
-
}
|
|
903
|
-
async function filesHash(files2, algorithm = "md5") {
|
|
904
|
-
return new Promise((resolve, reject) => {
|
|
905
|
-
resolve(
|
|
906
|
-
files2.reduce(async (mm, f) => {
|
|
907
|
-
return await mm + await fileHash(f);
|
|
908
|
-
}, Promise.resolve(""))
|
|
909
|
-
);
|
|
910
|
-
});
|
|
911
|
-
}
|
|
912
|
-
var getRunnables = (tests, payload = {
|
|
913
|
-
nodeEntryPoints: {},
|
|
914
|
-
webEntryPoints: {}
|
|
915
|
-
}) => {
|
|
916
|
-
return tests.reduce((pt, cv, cndx, cry) => {
|
|
917
|
-
if (cv[1] === "node") {
|
|
918
|
-
pt.nodeEntryPoints[cv[0]] = path3.resolve(
|
|
919
|
-
`./docs/node/${cv[0].split(".").slice(0, -1).concat("mjs").join(".")}`
|
|
920
|
-
);
|
|
921
|
-
} else if (cv[1] === "web") {
|
|
922
|
-
pt.webEntryPoints[cv[0]] = path3.resolve(
|
|
923
|
-
`./docs/web/${cv[0].split(".").slice(0, -1).concat("mjs").join(".")}`
|
|
924
|
-
);
|
|
925
|
-
}
|
|
926
|
-
if (cv[3].length) {
|
|
927
|
-
getRunnables(cv[3], payload);
|
|
928
|
-
}
|
|
929
|
-
return pt;
|
|
930
|
-
}, payload);
|
|
931
|
-
};
|
|
932
|
-
var changes = {};
|
|
933
|
-
var tscCheck = async ({
|
|
934
|
-
entrypoint,
|
|
935
|
-
addableFiles,
|
|
936
|
-
platform
|
|
937
|
-
}) => {
|
|
938
|
-
console.log(ansiC2.green(ansiC2.inverse(`tsc < ${entrypoint}`)));
|
|
939
|
-
const program = tsc.createProgramFromConfig({
|
|
940
|
-
basePath: process.cwd(),
|
|
941
|
-
// always required, used for relative paths
|
|
942
|
-
configFilePath: "tsconfig.json",
|
|
943
|
-
// config to inherit from (optional)
|
|
944
|
-
compilerOptions: {
|
|
945
|
-
rootDir: "src",
|
|
946
|
-
outDir: tscPather(entrypoint, platform),
|
|
947
|
-
// declaration: true,
|
|
948
|
-
// skipLibCheck: true,
|
|
949
|
-
noEmit: true
|
|
950
|
-
},
|
|
951
|
-
include: addableFiles
|
|
952
|
-
//["src/**/*"],
|
|
953
|
-
// exclude: ["**/*.test.ts", "**/*.spec.ts"],
|
|
954
|
-
});
|
|
955
|
-
const tscPath = tscPather(entrypoint, platform);
|
|
956
|
-
let allDiagnostics = program.getSemanticDiagnostics();
|
|
957
|
-
const d = [];
|
|
958
|
-
allDiagnostics.forEach((diagnostic) => {
|
|
959
|
-
if (diagnostic.file) {
|
|
960
|
-
let { line, character } = ts.getLineAndCharacterOfPosition(
|
|
961
|
-
diagnostic.file,
|
|
962
|
-
diagnostic.start
|
|
963
|
-
);
|
|
964
|
-
let message = ts.flattenDiagnosticMessageText(
|
|
965
|
-
diagnostic.messageText,
|
|
966
|
-
"\n"
|
|
967
|
-
);
|
|
968
|
-
d.push(
|
|
969
|
-
`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`
|
|
970
|
-
);
|
|
971
|
-
} else {
|
|
972
|
-
d.push(ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n"));
|
|
973
|
-
}
|
|
974
|
-
});
|
|
975
|
-
fs2.writeFileSync(tscPath, d.join("\n"));
|
|
976
|
-
fs2.writeFileSync(
|
|
977
|
-
tscExitCodePather(entrypoint, platform),
|
|
978
|
-
d.length.toString()
|
|
979
|
-
);
|
|
980
|
-
};
|
|
981
|
-
var eslint = new ESLint();
|
|
982
|
-
var formatter = await eslint.loadFormatter(
|
|
983
|
-
"./node_modules/testeranto/dist/prebuild/esbuildConfigs/eslint-formatter-testeranto.mjs"
|
|
984
|
-
);
|
|
985
|
-
var eslintCheck = async (entrypoint, platform, addableFiles) => {
|
|
986
|
-
console.log(ansiC2.green(ansiC2.inverse(`eslint < ${entrypoint}`)));
|
|
987
|
-
const results = (await eslint.lintFiles(addableFiles)).filter((r) => r.messages.length).filter((r) => {
|
|
988
|
-
return r.messages[0].ruleId !== null;
|
|
989
|
-
}).map((r) => {
|
|
990
|
-
delete r.source;
|
|
991
|
-
return r;
|
|
992
|
-
});
|
|
993
|
-
fs2.writeFileSync(
|
|
994
|
-
lintPather(entrypoint, platform),
|
|
995
|
-
await formatter.format(results)
|
|
996
|
-
);
|
|
997
|
-
fs2.writeFileSync(
|
|
998
|
-
lintExitCodePather(entrypoint, platform),
|
|
999
|
-
results.length.toString()
|
|
1000
|
-
);
|
|
1001
|
-
};
|
|
1002
|
-
var makePrompt = async (entryPoint, addableFiles, platform) => {
|
|
1003
|
-
const promptPath = path3.join(
|
|
1004
|
-
"./docs/",
|
|
1005
|
-
platform,
|
|
1006
|
-
entryPoint.split(".").slice(0, -1).join("."),
|
|
1007
|
-
`prompt.txt`
|
|
1008
|
-
);
|
|
1009
|
-
const testPaths = path3.join(
|
|
1010
|
-
"./docs/",
|
|
1011
|
-
platform,
|
|
1012
|
-
entryPoint.split(".").slice(0, -1).join("."),
|
|
1013
|
-
`tests.json`
|
|
1014
|
-
);
|
|
1015
|
-
const featuresPath = path3.join(
|
|
1016
|
-
"./docs/",
|
|
1017
|
-
platform,
|
|
1018
|
-
entryPoint.split(".").slice(0, -1).join("."),
|
|
1019
|
-
`featurePrompt.txt`
|
|
1020
|
-
);
|
|
1021
|
-
fs2.writeFileSync(
|
|
1022
|
-
promptPath,
|
|
1023
|
-
`
|
|
1024
|
-
${addableFiles.map((x) => {
|
|
1025
|
-
return `/add ${x}`;
|
|
1026
|
-
}).join("\n")}
|
|
1027
|
-
|
|
1028
|
-
/read ${lintPather(entryPoint, platform)}
|
|
1029
|
-
/read ${tscPather(entryPoint, platform)}
|
|
1030
|
-
/read ${testPaths}
|
|
1031
|
-
|
|
1032
|
-
/load ${featuresPath}
|
|
1033
|
-
|
|
1034
|
-
/code Fix the failing tests described in ${testPaths}. Correct any type signature errors described in the files ${tscPather(
|
|
1035
|
-
entryPoint,
|
|
1036
|
-
platform
|
|
1037
|
-
)}. Implement any method which throws "Function not implemented. Resolve the lint errors described in ${lintPather(
|
|
1038
|
-
entryPoint,
|
|
1039
|
-
platform
|
|
1040
|
-
)}"
|
|
1041
|
-
`
|
|
1042
|
-
);
|
|
1043
|
-
};
|
|
1044
|
-
var metafileOutputs = async (platform) => {
|
|
1045
|
-
const metafile = JSON.parse(
|
|
1046
|
-
fs2.readFileSync(`docs/${platform}/metafile.json`).toString()
|
|
1047
|
-
).metafile;
|
|
1048
|
-
if (!metafile)
|
|
1049
|
-
return;
|
|
1050
|
-
const outputs = metafile.outputs;
|
|
1051
|
-
Object.keys(outputs).forEach(async (k) => {
|
|
1052
|
-
const addableFiles = Object.keys(outputs[k].inputs).filter((i) => {
|
|
1053
|
-
if (!fs2.existsSync(i))
|
|
1054
|
-
return false;
|
|
1055
|
-
if (i.startsWith("node_modules"))
|
|
1056
|
-
return false;
|
|
1057
|
-
return true;
|
|
1058
|
-
});
|
|
1059
|
-
const f = `${k.split(".").slice(0, -1).join(".")}/`;
|
|
1060
|
-
if (!fs2.existsSync(f)) {
|
|
1061
|
-
fs2.mkdirSync(f);
|
|
1062
|
-
}
|
|
1063
|
-
const entrypoint = outputs[k].entryPoint;
|
|
1064
|
-
if (entrypoint) {
|
|
1065
|
-
const changeDigest = await filesHash(addableFiles);
|
|
1066
|
-
if (changeDigest === changes[entrypoint]) {
|
|
1067
|
-
} else {
|
|
1068
|
-
changes[entrypoint] = changeDigest;
|
|
1069
|
-
tscCheck({ platform, addableFiles, entrypoint });
|
|
1070
|
-
eslintCheck(entrypoint, platform, addableFiles);
|
|
1071
|
-
makePrompt(entrypoint, addableFiles, platform);
|
|
1072
|
-
}
|
|
1073
|
-
}
|
|
1074
|
-
});
|
|
1075
|
-
};
|
|
1076
|
-
import(process.cwd() + "/" + process.argv[2]).then(async (module) => {
|
|
1077
|
-
const rawConfig = module.default;
|
|
1078
|
-
const config = {
|
|
1079
|
-
...rawConfig,
|
|
1080
|
-
buildDir: process.cwd() + "/" + rawConfig.outdir
|
|
1081
|
-
};
|
|
1082
|
-
let mode = config.devMode ? "DEV" : "PROD";
|
|
1083
|
-
const fileHashes = {};
|
|
1084
|
-
let pm = new PM_Main(config);
|
|
1085
|
-
console.log(ansiC2.inverse(`Press 'q' to shutdown gracefully`));
|
|
1086
|
-
process.stdin.on("keypress", (str, key) => {
|
|
1087
|
-
if (key.name === "q") {
|
|
1088
|
-
console.log(
|
|
1089
|
-
ansiC2.inverse("Testeranto-Run is shutting down gracefully...")
|
|
1090
|
-
);
|
|
1091
|
-
mode = "PROD";
|
|
1092
|
-
nodeMetafileWatcher.close();
|
|
1093
|
-
webMetafileWatcher.close();
|
|
1094
|
-
pm.shutDown();
|
|
1095
|
-
}
|
|
1096
|
-
});
|
|
1097
|
-
metafileOutputs("node");
|
|
1098
|
-
const nodeMetafileWatcher = watch(
|
|
1099
|
-
"docs/node/metafile.json",
|
|
1100
|
-
async (e, filename) => {
|
|
1101
|
-
console.log(ansiC2.green(ansiC2.inverse(`< ${e} ${filename} (node)`)));
|
|
1102
|
-
metafileOutputs("node");
|
|
1103
|
-
}
|
|
1104
|
-
);
|
|
1105
|
-
metafileOutputs("web");
|
|
1106
|
-
const webMetafileWatcher = watch(
|
|
1107
|
-
"docs/web/metafile.json",
|
|
1108
|
-
async (e, filename) => {
|
|
1109
|
-
console.log(ansiC2.green(ansiC2.inverse(`< ${e} ${filename} (web)`)));
|
|
1110
|
-
metafileOutputs("web");
|
|
1111
|
-
}
|
|
1112
|
-
);
|
|
1113
|
-
await pm.startPuppeteer(
|
|
1114
|
-
{
|
|
1115
|
-
slowMo: 1,
|
|
1116
|
-
// timeout: 1,
|
|
1117
|
-
waitForInitialPage: false,
|
|
1118
|
-
executablePath: (
|
|
1119
|
-
// process.env.CHROMIUM_PATH || "/opt/homebrew/bin/chromium",
|
|
1120
|
-
"/opt/homebrew/bin/chromium"
|
|
1121
|
-
),
|
|
1122
|
-
headless: true,
|
|
1123
|
-
dumpio: true,
|
|
1124
|
-
// timeout: 0,
|
|
1125
|
-
devtools: true,
|
|
1126
|
-
args: [
|
|
1127
|
-
"--auto-open-devtools-for-tabs",
|
|
1128
|
-
`--remote-debugging-port=3234`,
|
|
1129
|
-
// "--disable-features=IsolateOrigins,site-per-process",
|
|
1130
|
-
"--disable-site-isolation-trials",
|
|
1131
|
-
"--allow-insecure-localhost",
|
|
1132
|
-
"--allow-file-access-from-files",
|
|
1133
|
-
"--allow-running-insecure-content",
|
|
1134
|
-
"--disable-dev-shm-usage",
|
|
1135
|
-
"--disable-extensions",
|
|
1136
|
-
"--disable-gpu",
|
|
1137
|
-
"--disable-setuid-sandbox",
|
|
1138
|
-
"--disable-site-isolation-trials",
|
|
1139
|
-
"--disable-web-security",
|
|
1140
|
-
"--no-first-run",
|
|
1141
|
-
"--no-sandbox",
|
|
1142
|
-
"--no-startup-window",
|
|
1143
|
-
// "--no-zygote",
|
|
1144
|
-
"--reduce-security-for-testing",
|
|
1145
|
-
"--remote-allow-origins=*",
|
|
1146
|
-
"--unsafely-treat-insecure-origin-as-secure=*"
|
|
1147
|
-
// "--disable-features=IsolateOrigins",
|
|
1148
|
-
// "--remote-allow-origins=ws://localhost:3234",
|
|
1149
|
-
// "--single-process",
|
|
1150
|
-
// "--unsafely-treat-insecure-origin-as-secure",
|
|
1151
|
-
// "--unsafely-treat-insecure-origin-as-secure=ws://192.168.0.101:3234",
|
|
1152
|
-
// "--disk-cache-dir=/dev/null",
|
|
1153
|
-
// "--disk-cache-size=1",
|
|
1154
|
-
// "--start-maximized",
|
|
1155
|
-
]
|
|
1156
|
-
},
|
|
1157
|
-
"."
|
|
1158
|
-
);
|
|
1159
|
-
const { nodeEntryPoints, webEntryPoints } = getRunnables(config.tests);
|
|
1160
|
-
Object.entries(nodeEntryPoints).forEach(
|
|
1161
|
-
([k, outputFile]) => {
|
|
1162
|
-
pm.launchNode(k, outputFile);
|
|
1163
|
-
try {
|
|
1164
|
-
watch(outputFile, async (e, filename) => {
|
|
1165
|
-
const hash = await fileHash(outputFile);
|
|
1166
|
-
if (fileHashes[k] !== hash) {
|
|
1167
|
-
fileHashes[k] = hash;
|
|
1168
|
-
console.log(ansiC2.green(ansiC2.inverse(`< ${e} ${filename}`)));
|
|
1169
|
-
pm.launchNode(k, outputFile);
|
|
1170
|
-
}
|
|
1171
|
-
});
|
|
1172
|
-
} catch (e) {
|
|
1173
|
-
console.error(e);
|
|
1174
|
-
}
|
|
1175
|
-
}
|
|
1176
|
-
);
|
|
1177
|
-
Object.entries(webEntryPoints).forEach(
|
|
1178
|
-
([k, outputFile]) => {
|
|
1179
|
-
pm.launchWeb(k, outputFile);
|
|
1180
|
-
watch(outputFile, async (e, filename) => {
|
|
1181
|
-
const hash = await fileHash(outputFile);
|
|
1182
|
-
if (fileHashes[k] !== hash) {
|
|
1183
|
-
fileHashes[k] = hash;
|
|
1184
|
-
console.log(ansiC2.green(ansiC2.inverse(`< ${e} ${filename}`)));
|
|
1185
|
-
pm.launchWeb(k, outputFile);
|
|
1186
|
-
}
|
|
1187
|
-
});
|
|
1188
|
-
}
|
|
1189
|
-
);
|
|
1190
|
-
});
|