testeranto 0.114.1 → 0.121.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -1
- package/bundle.js +1 -1
- package/dist/common/Init.js +55 -61
- package/dist/common/PM/base.js +233 -0
- package/dist/common/PM/main.js +217 -434
- package/dist/common/build.js +113 -92
- package/dist/common/defaultConfig.js +2 -2
- package/dist/common/esbuildConfigs/index.js +1 -1
- package/dist/common/esbuildConfigs/inputFilesPlugin.js +7 -3
- package/dist/common/esbuildConfigs/node.js +5 -3
- package/dist/common/esbuildConfigs/web.js +3 -3
- package/dist/common/init-docs.js +2 -46
- package/dist/common/lib/abstractBase.js +60 -54
- package/dist/common/lib/basebuilder.js +7 -8
- package/dist/common/lib/classBuilder.js +8 -5
- package/dist/common/lib/core.js +6 -18
- package/dist/common/lib/index.js +6 -1
- package/dist/common/run.js +10 -2
- package/dist/common/tsconfig.common.tsbuildinfo +1 -1
- package/dist/common/utils.js +9 -21
- package/dist/module/Init.js +55 -61
- package/dist/module/PM/base.js +226 -0
- package/dist/module/PM/main.js +218 -435
- package/dist/module/Project.js +117 -0
- package/dist/module/TestReport.js +13 -4
- package/dist/module/build.js +113 -92
- package/dist/module/defaultConfig.js +2 -2
- package/dist/module/esbuildConfigs/index.js +1 -1
- package/dist/module/esbuildConfigs/inputFilesPlugin.js +7 -3
- package/dist/module/esbuildConfigs/node.js +5 -3
- package/dist/module/esbuildConfigs/web.js +3 -3
- package/dist/module/init-docs.js +2 -13
- package/dist/module/lib/abstractBase.js +60 -54
- package/dist/module/lib/basebuilder.js +7 -8
- package/dist/module/lib/classBuilder.js +8 -5
- package/dist/module/lib/core.js +6 -18
- package/dist/module/lib/index.js +6 -1
- package/dist/module/run.js +10 -2
- package/dist/module/tsconfig.module.tsbuildinfo +1 -1
- package/dist/module/utils.js +8 -17
- package/dist/prebuild/Project.css +11367 -0
- package/dist/prebuild/Project.js +24640 -0
- package/dist/prebuild/ReportClient.js +1 -1
- package/dist/prebuild/TestReport.js +9 -11
- package/dist/prebuild/build.mjs +142 -81
- package/dist/prebuild/init-docs.mjs +28 -83
- package/dist/prebuild/run.mjs +618 -537
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/Init.d.ts +1 -1
- package/dist/types/PM/base.d.ts +38 -0
- package/dist/types/PM/main.d.ts +20 -44
- package/dist/types/esbuildConfigs/inputFilesPlugin.d.ts +1 -1
- package/dist/types/esbuildConfigs/node.d.ts +1 -1
- package/dist/types/esbuildConfigs/web.d.ts +1 -1
- package/dist/types/lib/abstractBase.d.ts +19 -11
- package/dist/types/lib/basebuilder.d.ts +1 -2
- package/dist/types/lib/index.d.ts +3 -3
- package/dist/types/lib/types.d.ts +2 -5
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/dist/types/utils.d.ts +4 -7
- package/package.json +6 -5
- package/src/Init.ts +60 -68
- package/src/PM/base.ts +301 -0
- package/src/PM/main.ts +276 -567
- package/src/Project.tsx +197 -0
- package/src/ReportClient.tsx +1 -1
- package/src/TestReport.tsx +30 -15
- package/src/build.ts +140 -104
- package/src/defaultConfig.ts +2 -2
- package/src/esbuildConfigs/index.ts +1 -1
- package/src/esbuildConfigs/inputFilesPlugin.ts +7 -6
- package/src/esbuildConfigs/node.ts +5 -3
- package/src/esbuildConfigs/web.ts +4 -3
- package/src/init-docs.ts +2 -15
- package/src/lib/abstractBase.ts +113 -93
- package/src/lib/basebuilder.ts +8 -9
- package/src/lib/classBuilder.ts +11 -10
- package/src/lib/core.ts +15 -27
- package/src/lib/index.ts +13 -6
- package/src/lib/types.ts +3 -8
- package/src/run.ts +21 -5
- package/src/utils.ts +27 -39
- package/tsc.log +12 -23
- package/dist/common/puppeteerConfiger.js +0 -24
- package/dist/module/puppeteerConfiger.js +0 -19
- package/dist/types/puppeteerConfiger.d.ts +0 -4
- package/src/puppeteerConfiger.ts +0 -26
package/dist/common/build.js
CHANGED
|
@@ -36,6 +36,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
36
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
const ansi_colors_1 = __importDefault(require("ansi-colors"));
|
|
39
40
|
const fs_1 = __importDefault(require("fs"));
|
|
40
41
|
const path_1 = __importDefault(require("path"));
|
|
41
42
|
const readline_1 = __importDefault(require("readline"));
|
|
@@ -47,25 +48,21 @@ const web_html_js_1 = __importDefault(require("./web.html.js"));
|
|
|
47
48
|
readline_1.default.emitKeypressEvents(process.stdin);
|
|
48
49
|
if (process.stdin.isTTY)
|
|
49
50
|
process.stdin.setRawMode(true);
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}, payload);
|
|
66
|
-
};
|
|
67
|
-
Promise.resolve(`${process.cwd() + "/" + process.argv[2]}`).then(s => __importStar(require(s))).then(async (module) => {
|
|
68
|
-
const rawConfig = module.default;
|
|
51
|
+
let testName = process.argv[2];
|
|
52
|
+
let mode = process.argv[3];
|
|
53
|
+
if (mode !== "once" && mode !== "dev") {
|
|
54
|
+
console.error(`The 4th argument should be 'dev' or 'once', not '${mode}'.`);
|
|
55
|
+
process.exit(-1);
|
|
56
|
+
}
|
|
57
|
+
console.log("testeranto is building", testName, mode);
|
|
58
|
+
Promise.resolve(`${process.cwd() + "/" + "testeranto.config.ts"}`).then(s => __importStar(require(s))).then(async (module) => {
|
|
59
|
+
const bigConfig = module.default;
|
|
60
|
+
const project = bigConfig.projects[testName];
|
|
61
|
+
if (!project) {
|
|
62
|
+
console.error("no project found for", testName, "in testeranto.config.ts");
|
|
63
|
+
process.exit(-1);
|
|
64
|
+
}
|
|
65
|
+
const rawConfig = bigConfig.projects[testName];
|
|
69
66
|
const getSecondaryEndpointsPoints = (runtime) => {
|
|
70
67
|
const meta = (ts, st) => {
|
|
71
68
|
ts.forEach((t) => {
|
|
@@ -80,13 +77,25 @@ Promise.resolve(`${process.cwd() + "/" + process.argv[2]}`).then(s => __importSt
|
|
|
80
77
|
};
|
|
81
78
|
return Array.from(meta(config.tests, new Set()));
|
|
82
79
|
};
|
|
83
|
-
const config = Object.assign(Object.assign({}, rawConfig), { buildDir: process.cwd() + "/" +
|
|
80
|
+
const config = Object.assign(Object.assign({}, rawConfig), { buildDir: process.cwd() + "/testeranto/bundles/" + testName });
|
|
81
|
+
console.log(`Press 'q' to shutdown gracefully. Press 'x' to shutdown forcefully.`);
|
|
82
|
+
process.stdin.on("keypress", (str, key) => {
|
|
83
|
+
if (key.name === "q") {
|
|
84
|
+
console.log("Testeranto-Build is shutting down...");
|
|
85
|
+
mode = "once";
|
|
86
|
+
onDone();
|
|
87
|
+
}
|
|
88
|
+
else if (key.name === "x") {
|
|
89
|
+
console.log("Testeranto-Build is shutting down forcefully...");
|
|
90
|
+
process.exit(-1);
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
console.log(`Press 'q' to shutdown gracefully. Press 'x' to shutdown forcefully.`);
|
|
94
|
+
}
|
|
95
|
+
});
|
|
84
96
|
let nodeDone = false;
|
|
85
97
|
let webDone = false;
|
|
86
|
-
let mode = config.devMode ? "DEV" : "PROD";
|
|
87
98
|
let status = "build";
|
|
88
|
-
// let pm: PM_Main | undefined = new PM_Main(config);
|
|
89
|
-
// const fileHashes = {};
|
|
90
99
|
const { nodeEntryPoints, webEntryPoints } = getRunnables(config.tests);
|
|
91
100
|
const onNodeDone = () => {
|
|
92
101
|
nodeDone = true;
|
|
@@ -100,72 +109,67 @@ Promise.resolve(`${process.cwd() + "/" + process.argv[2]}`).then(s => __importSt
|
|
|
100
109
|
if (nodeDone && webDone) {
|
|
101
110
|
status = "built";
|
|
102
111
|
}
|
|
103
|
-
if (nodeDone && webDone &&
|
|
104
|
-
|
|
105
|
-
// console.log("watching", outputFile);
|
|
106
|
-
// try {
|
|
107
|
-
// watch(outputFile, async (filename) => {
|
|
108
|
-
// const hash = await fileHash(outputFile);
|
|
109
|
-
// if (fileHashes[k] !== hash) {
|
|
110
|
-
// fileHashes[k] = hash;
|
|
111
|
-
// console.log(`< ${filename} `);
|
|
112
|
-
// pm.launchNode(k, outputFile);
|
|
113
|
-
// }
|
|
114
|
-
// });
|
|
115
|
-
// } catch (e) {
|
|
116
|
-
// console.error(e);
|
|
117
|
-
// }
|
|
118
|
-
// });
|
|
119
|
-
// Object.entries(webEntryPoints).forEach(([k, outputFile]) => {
|
|
120
|
-
// console.log("watching", outputFile);
|
|
121
|
-
// watch(outputFile, async (filename) => {
|
|
122
|
-
// const hash = await fileHash(outputFile);
|
|
123
|
-
// console.log(`< ${filename} ${hash}`);
|
|
124
|
-
// if (fileHashes[k] !== hash) {
|
|
125
|
-
// fileHashes[k] = hash;
|
|
126
|
-
// pm.launchWeb(k, outputFile);
|
|
127
|
-
// }
|
|
128
|
-
// });
|
|
129
|
-
// });
|
|
130
|
-
}
|
|
131
|
-
if (nodeDone && webDone && mode === "PROD") {
|
|
132
|
-
console.log("Testeranto-EsBuild is all done. Goodbye!");
|
|
112
|
+
if (nodeDone && webDone && mode === "once") {
|
|
113
|
+
console.log(ansi_colors_1.default.inverse(`${testName} has been built. Goodbye.`));
|
|
133
114
|
process.exit();
|
|
134
115
|
}
|
|
135
|
-
else {
|
|
136
|
-
if (mode === "PROD") {
|
|
137
|
-
console.log("waiting for tests to finish");
|
|
138
|
-
console.log(JSON.stringify({
|
|
139
|
-
nodeDone: nodeDone,
|
|
140
|
-
webDone: webDone,
|
|
141
|
-
mode: mode,
|
|
142
|
-
}, null, 2));
|
|
143
|
-
}
|
|
144
|
-
else {
|
|
145
|
-
console.log("waiting for tests to change");
|
|
146
|
-
}
|
|
147
|
-
if (config.devMode) {
|
|
148
|
-
console.log("ready and watching for changes...");
|
|
149
|
-
}
|
|
150
|
-
else {
|
|
151
|
-
// pm.shutDown();
|
|
152
|
-
}
|
|
153
|
-
////////////////////////////////////////////////////////////////////////////////
|
|
154
|
-
}
|
|
155
116
|
};
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
117
|
+
if (!fs_1.default.existsSync(`testeranto/reports/${testName}`)) {
|
|
118
|
+
fs_1.default.mkdirSync(`testeranto/reports/${testName}`);
|
|
119
|
+
}
|
|
120
|
+
fs_1.default.writeFileSync(`${process.cwd()}/testeranto/reports/${testName}/index.html`, `
|
|
121
|
+
<!DOCTYPE html>
|
|
122
|
+
<html lang="en">
|
|
123
|
+
|
|
124
|
+
<head>
|
|
125
|
+
<meta name="description" content="Webpage description goes here" />
|
|
126
|
+
<meta charset="utf-8" />
|
|
127
|
+
<title>kokomoBay - testeranto</title>
|
|
128
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
129
|
+
<meta name="author" content="" />
|
|
130
|
+
|
|
131
|
+
<link rel="stylesheet" href="/kokomoBay/testeranto/ReportClient.css" />
|
|
132
|
+
<script type="module" src="/kokomoBay/testeranto/ReportClient.js"></script>
|
|
133
|
+
|
|
134
|
+
</head>
|
|
135
|
+
|
|
136
|
+
<body>
|
|
137
|
+
<div id="root">
|
|
138
|
+
react is loading
|
|
139
|
+
</div>
|
|
140
|
+
</body>
|
|
141
|
+
|
|
142
|
+
</html>
|
|
143
|
+
`);
|
|
144
|
+
fs_1.default.writeFileSync(`testeranto/reports/${testName}/config.json`, JSON.stringify(config, null, 2));
|
|
145
|
+
fs_1.default.writeFileSync(`${process.cwd()}/testeranto/index.html`, `
|
|
146
|
+
<!DOCTYPE html>
|
|
147
|
+
<html lang="en">
|
|
148
|
+
|
|
149
|
+
<head>
|
|
150
|
+
<meta name="description" content="Webpage description goes here" />
|
|
151
|
+
<meta charset="utf-8" />
|
|
152
|
+
<title>kokomoBay - testeranto</title>
|
|
153
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
154
|
+
<meta name="author" content="" />
|
|
155
|
+
|
|
156
|
+
<script type="application/json" id="bigConfig">
|
|
157
|
+
${JSON.stringify(Object.keys(bigConfig.projects))}
|
|
158
|
+
</script>
|
|
159
|
+
|
|
160
|
+
<link rel="stylesheet" href="/kokomoBay/testeranto/Project.css" />
|
|
161
|
+
<script type="module" src="/kokomoBay/testeranto/Project.js"></script>
|
|
162
|
+
|
|
163
|
+
</head>
|
|
164
|
+
|
|
165
|
+
<body>
|
|
166
|
+
<div id="root">
|
|
167
|
+
react is loading
|
|
168
|
+
</div>
|
|
169
|
+
</body>
|
|
170
|
+
|
|
171
|
+
</html>
|
|
172
|
+
`);
|
|
169
173
|
Promise.resolve(Promise.all([...getSecondaryEndpointsPoints("web")].map(async (sourceFilePath) => {
|
|
170
174
|
const sourceFileSplit = sourceFilePath.split("/");
|
|
171
175
|
const sourceDir = sourceFileSplit.slice(0, -1);
|
|
@@ -174,13 +178,13 @@ Promise.resolve(`${process.cwd() + "/" + process.argv[2]}`).then(s => __importSt
|
|
|
174
178
|
.split(".")
|
|
175
179
|
.slice(0, -1)
|
|
176
180
|
.join(".");
|
|
177
|
-
const htmlFilePath = path_1.default.normalize(`${process.cwd()}/${
|
|
181
|
+
const htmlFilePath = path_1.default.normalize(`${process.cwd()}/testeranto/bundles/web/${testName}/${sourceDir.join("/")}/${sourceFileNameMinusJs}.html`);
|
|
178
182
|
const jsfilePath = `./${sourceFileNameMinusJs}.mjs`;
|
|
179
183
|
return fs_1.default.promises
|
|
180
184
|
.mkdir(path_1.default.dirname(htmlFilePath), { recursive: true })
|
|
181
185
|
.then((x) => fs_1.default.writeFileSync(htmlFilePath, (0, web_html_js_1.default)(jsfilePath, htmlFilePath)));
|
|
182
186
|
})));
|
|
183
|
-
(0, glob_1.glob)(
|
|
187
|
+
(0, glob_1.glob)(`${process.cwd()}/testeranto/bundles/${testName}/chunk-*.mjs`, {
|
|
184
188
|
ignore: "node_modules/**",
|
|
185
189
|
}).then((chunks) => {
|
|
186
190
|
chunks.forEach((chunk) => {
|
|
@@ -189,9 +193,9 @@ Promise.resolve(`${process.cwd() + "/" + process.argv[2]}`).then(s => __importSt
|
|
|
189
193
|
});
|
|
190
194
|
await Promise.all([
|
|
191
195
|
esbuild_1.default
|
|
192
|
-
.context((0, node_js_1.default)(config, Object.keys(nodeEntryPoints)))
|
|
196
|
+
.context((0, node_js_1.default)(config, Object.keys(nodeEntryPoints), testName))
|
|
193
197
|
.then(async (nodeContext) => {
|
|
194
|
-
if (
|
|
198
|
+
if (mode === "dev") {
|
|
195
199
|
await nodeContext.watch().then((v) => {
|
|
196
200
|
onNodeDone();
|
|
197
201
|
});
|
|
@@ -204,9 +208,9 @@ Promise.resolve(`${process.cwd() + "/" + process.argv[2]}`).then(s => __importSt
|
|
|
204
208
|
return nodeContext;
|
|
205
209
|
}),
|
|
206
210
|
esbuild_1.default
|
|
207
|
-
.context((0, web_js_1.default)(config, Object.keys(webEntryPoints)))
|
|
211
|
+
.context((0, web_js_1.default)(config, Object.keys(webEntryPoints), testName))
|
|
208
212
|
.then(async (webContext) => {
|
|
209
|
-
if (
|
|
213
|
+
if (mode === "dev") {
|
|
210
214
|
await webContext.watch().then((v) => {
|
|
211
215
|
onWebDone();
|
|
212
216
|
});
|
|
@@ -220,3 +224,20 @@ Promise.resolve(`${process.cwd() + "/" + process.argv[2]}`).then(s => __importSt
|
|
|
220
224
|
}),
|
|
221
225
|
]);
|
|
222
226
|
});
|
|
227
|
+
const getRunnables = (tests, payload = {
|
|
228
|
+
nodeEntryPoints: {},
|
|
229
|
+
webEntryPoints: {},
|
|
230
|
+
}) => {
|
|
231
|
+
return tests.reduce((pt, cv, cndx, cry) => {
|
|
232
|
+
if (cv[1] === "node") {
|
|
233
|
+
pt.nodeEntryPoints[cv[0]] = path_1.default.resolve(`./docs/node/${cv[0].split(".").slice(0, -1).concat("mjs").join(".")}`);
|
|
234
|
+
}
|
|
235
|
+
else if (cv[1] === "web") {
|
|
236
|
+
pt.webEntryPoints[cv[0]] = path_1.default.resolve(`./docs/web/${cv[0].split(".").slice(0, -1).concat("mjs").join(".")}`);
|
|
237
|
+
}
|
|
238
|
+
if (cv[3].length) {
|
|
239
|
+
getRunnables(cv[3], payload);
|
|
240
|
+
}
|
|
241
|
+
return pt;
|
|
242
|
+
}, payload);
|
|
243
|
+
};
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const config = {
|
|
4
4
|
src: "src",
|
|
5
|
-
outdir: "docs",
|
|
5
|
+
// outdir: "docs",
|
|
6
6
|
tests: [],
|
|
7
7
|
debugger: true,
|
|
8
8
|
clearScreen: false,
|
|
9
9
|
devMode: true,
|
|
10
10
|
minify: false,
|
|
11
|
-
outbase: ".",
|
|
11
|
+
// outbase: ".",
|
|
12
12
|
ports: ["3001"],
|
|
13
13
|
externals: [],
|
|
14
14
|
nodePlugins: [],
|
|
@@ -11,15 +11,19 @@ const register = (entrypoint, sources) => {
|
|
|
11
11
|
}
|
|
12
12
|
sources.forEach((s) => otherInputs[entrypoint].add(s));
|
|
13
13
|
};
|
|
14
|
-
exports.default = (platform,
|
|
14
|
+
exports.default = (platform, testName) => {
|
|
15
|
+
const d = `testeranto/bundles/${platform}/${testName}/`;
|
|
16
|
+
const f = `testeranto/bundles/${platform}/${testName}/metafile.json`;
|
|
17
|
+
if (!fs_1.default.existsSync(d)) {
|
|
18
|
+
fs_1.default.mkdirSync(d);
|
|
19
|
+
}
|
|
15
20
|
return {
|
|
16
21
|
register,
|
|
17
22
|
inputFilesPluginFactory: {
|
|
18
23
|
name: "metafileWriter",
|
|
19
24
|
setup(build) {
|
|
20
25
|
build.onEnd((result) => {
|
|
21
|
-
|
|
22
|
-
fs_1.default.writeFileSync(`docs/${platform}/metafile.json`, JSON.stringify(result, null, 2));
|
|
26
|
+
fs_1.default.writeFileSync(f, JSON.stringify(result, null, 2));
|
|
23
27
|
});
|
|
24
28
|
},
|
|
25
29
|
},
|
|
@@ -6,9 +6,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const index_js_1 = __importDefault(require("./index.js"));
|
|
7
7
|
const inputFilesPlugin_js_1 = __importDefault(require("./inputFilesPlugin.js"));
|
|
8
8
|
const featuresPlugin_1 = __importDefault(require("./featuresPlugin"));
|
|
9
|
-
exports.default = (config, entryPoints) => {
|
|
10
|
-
const { inputFilesPluginFactory, register } = (0, inputFilesPlugin_js_1.default)("node",
|
|
11
|
-
|
|
9
|
+
exports.default = (config, entryPoints, testName) => {
|
|
10
|
+
const { inputFilesPluginFactory, register } = (0, inputFilesPlugin_js_1.default)("node",
|
|
11
|
+
// entryPoints,
|
|
12
|
+
testName);
|
|
13
|
+
return Object.assign(Object.assign({}, (0, index_js_1.default)(config)), { splitting: true, outdir: `testeranto/bundles/node/${testName}/`,
|
|
12
14
|
// inject: [`./node_modules/testeranto/dist/cjs-shim.js`],
|
|
13
15
|
metafile: true, supported: {
|
|
14
16
|
"dynamic-import": true,
|
|
@@ -7,9 +7,9 @@ const path_1 = __importDefault(require("path"));
|
|
|
7
7
|
const index_js_1 = __importDefault(require("./index.js"));
|
|
8
8
|
const inputFilesPlugin_js_1 = __importDefault(require("./inputFilesPlugin.js"));
|
|
9
9
|
const featuresPlugin_js_1 = __importDefault(require("./featuresPlugin.js"));
|
|
10
|
-
exports.default = (config, entryPoints) => {
|
|
11
|
-
const { inputFilesPluginFactory, register } = (0, inputFilesPlugin_js_1.default)("web",
|
|
12
|
-
return Object.assign(Object.assign({}, (0, index_js_1.default)(config)), { outdir:
|
|
10
|
+
exports.default = (config, entryPoints, testName) => {
|
|
11
|
+
const { inputFilesPluginFactory, register } = (0, inputFilesPlugin_js_1.default)("web", testName);
|
|
12
|
+
return Object.assign(Object.assign({}, (0, index_js_1.default)(config)), { outdir: `testeranto/bundles/web/${testName}`, alias: {
|
|
13
13
|
react: path_1.default.resolve("./node_modules/react"),
|
|
14
14
|
}, metafile: true, external: [
|
|
15
15
|
"path",
|
package/dist/common/init-docs.js
CHANGED
|
@@ -1,53 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
4
|
};
|
|
38
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
const fs_1 = __importDefault(require("fs"));
|
|
40
6
|
const Init_1 = __importDefault(require("./Init"));
|
|
41
7
|
console.log("Initializing a testeranto project");
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
fs_1.default.writeFileSync("testeranto.mts", fs_1.default.readFileSync("node_modules/testeranto/src/defaultConfig.ts"));
|
|
45
|
-
Promise.resolve(`${process.cwd() + "/" + "testeranto.mts"}`).then(s => __importStar(require(s))).then((module) => {
|
|
46
|
-
(0, Init_1.default)(module.default);
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
Promise.resolve(`${process.cwd() + "/" + process.argv[2]}`).then(s => __importStar(require(s))).then((module) => {
|
|
51
|
-
(0, Init_1.default)(module.default);
|
|
52
|
-
});
|
|
53
|
-
}
|
|
8
|
+
(0, Init_1.default)();
|
|
9
|
+
console.log("testeranto project initialized");
|
|
@@ -24,9 +24,11 @@ class BaseSuite {
|
|
|
24
24
|
}
|
|
25
25
|
toObj() {
|
|
26
26
|
const givens = Object.keys(this.givens).map((k) => this.givens[k].toObj());
|
|
27
|
+
const checks = Object.keys(this.checks).map((k) => this.checks[k].toObj());
|
|
27
28
|
return {
|
|
28
29
|
name: this.name,
|
|
29
30
|
givens,
|
|
31
|
+
checks,
|
|
30
32
|
fails: this.fails,
|
|
31
33
|
features: this.features(),
|
|
32
34
|
};
|
|
@@ -42,29 +44,28 @@ class BaseSuite {
|
|
|
42
44
|
}
|
|
43
45
|
async run(input, testResourceConfiguration, artifactory, tLog, pm) {
|
|
44
46
|
this.testResourceConfiguration = testResourceConfiguration;
|
|
45
|
-
tLog("test resources: ", JSON.stringify(testResourceConfiguration));
|
|
47
|
+
// tLog("test resources: ", JSON.stringify(testResourceConfiguration));
|
|
46
48
|
const suiteArtifactory = (fPath, value) => artifactory(`suite-${this.index}-${this.name}/${fPath}`, value);
|
|
47
49
|
// console.log("\nSuite:", this.index, this.name);
|
|
48
50
|
tLog("\nSuite:", this.index, this.name);
|
|
49
51
|
const sNdx = this.index;
|
|
50
52
|
const sName = this.name;
|
|
53
|
+
const beforeAllProxy = new Proxy(pm, {
|
|
54
|
+
get(target, prop, receiver) {
|
|
55
|
+
if (prop === "customScreenShot") {
|
|
56
|
+
return (opts, p) => target.customScreenShot(Object.assign(Object.assign({}, opts), {
|
|
57
|
+
// path: `${filepath}/${opts.path}`,
|
|
58
|
+
path: `suite-${sNdx}/beforeAll/${opts.path}` }), p);
|
|
59
|
+
}
|
|
60
|
+
if (prop === "writeFileSync") {
|
|
61
|
+
return (fp, contents) => target[prop](`suite-${sNdx}/beforeAll/${fp}`, contents);
|
|
62
|
+
}
|
|
63
|
+
/* @ts-ignore:next-line */
|
|
64
|
+
return Reflect.get(...arguments);
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
const subject = await this.setup(input, suiteArtifactory, testResourceConfiguration, beforeAllProxy);
|
|
51
68
|
for (const [gKey, g] of Object.entries(this.givens)) {
|
|
52
|
-
// console.log("gKey", gKey);
|
|
53
|
-
const beforeAllProxy = new Proxy(pm, {
|
|
54
|
-
get(target, prop, receiver) {
|
|
55
|
-
if (prop === "customScreenShot") {
|
|
56
|
-
return (opts, p) => target.customScreenShot(Object.assign(Object.assign({}, opts), {
|
|
57
|
-
// path: `${filepath}/${opts.path}`,
|
|
58
|
-
path: `suite-${sNdx}/beforeAll/${opts.path}` }), p);
|
|
59
|
-
}
|
|
60
|
-
if (prop === "writeFileSync") {
|
|
61
|
-
return (fp, contents) => target[prop](`suite-${sNdx}/beforeAll/${fp}`, contents);
|
|
62
|
-
}
|
|
63
|
-
/* @ts-ignore:next-line */
|
|
64
|
-
return Reflect.get(...arguments);
|
|
65
|
-
},
|
|
66
|
-
});
|
|
67
|
-
const subject = await this.setup(input, suiteArtifactory, testResourceConfiguration, beforeAllProxy);
|
|
68
69
|
const giver = this.givens[gKey];
|
|
69
70
|
try {
|
|
70
71
|
this.store = await giver.give(subject, gKey, testResourceConfiguration, this.assertThat, suiteArtifactory, tLog, pm, sNdx);
|
|
@@ -75,6 +76,9 @@ class BaseSuite {
|
|
|
75
76
|
// return this;
|
|
76
77
|
}
|
|
77
78
|
}
|
|
79
|
+
for (const [ndx, thater] of this.checks.entries()) {
|
|
80
|
+
await thater.check(subject, thater.name, testResourceConfiguration, this.assertThat, suiteArtifactory, tLog, pm);
|
|
81
|
+
}
|
|
78
82
|
try {
|
|
79
83
|
this.afterAll(this.store, artifactory,
|
|
80
84
|
// afterAllProxy
|
|
@@ -85,17 +89,6 @@ class BaseSuite {
|
|
|
85
89
|
// this.fails.push(this);
|
|
86
90
|
// return this;
|
|
87
91
|
}
|
|
88
|
-
// for (const [ndx, thater] of this.checks.entries()) {
|
|
89
|
-
// await thater.check(
|
|
90
|
-
// subject,
|
|
91
|
-
// thater.name,
|
|
92
|
-
// testResourceConfiguration,
|
|
93
|
-
// this.assertThat,
|
|
94
|
-
// suiteArtifactory,
|
|
95
|
-
// tLog,
|
|
96
|
-
// pm
|
|
97
|
-
// );
|
|
98
|
-
// }
|
|
99
92
|
// @TODO fix me
|
|
100
93
|
// for (const k of Object.keys(this.givens)) {
|
|
101
94
|
// const giver = this.givens[k];
|
|
@@ -113,9 +106,7 @@ class BaseSuite {
|
|
|
113
106
|
}
|
|
114
107
|
exports.BaseSuite = BaseSuite;
|
|
115
108
|
class BaseGiven {
|
|
116
|
-
constructor(name, features, whens, thens, givenCB, initialValues
|
|
117
|
-
// key: string
|
|
118
|
-
) {
|
|
109
|
+
constructor(name, features, whens, thens, givenCB, initialValues) {
|
|
119
110
|
this.name = name;
|
|
120
111
|
this.features = features;
|
|
121
112
|
this.whens = whens;
|
|
@@ -205,7 +196,8 @@ class BaseGiven {
|
|
|
205
196
|
afterEachProxy);
|
|
206
197
|
}
|
|
207
198
|
catch (e) {
|
|
208
|
-
console.error("afterEach failed!
|
|
199
|
+
console.error("afterEach failed!", e);
|
|
200
|
+
this.error = e.message;
|
|
209
201
|
}
|
|
210
202
|
}
|
|
211
203
|
return this.store;
|
|
@@ -225,7 +217,6 @@ class BaseWhen {
|
|
|
225
217
|
}
|
|
226
218
|
async test(store, testResourceConfiguration, tLog, pm, filepath) {
|
|
227
219
|
tLog(" When:", this.name);
|
|
228
|
-
const name = this.name;
|
|
229
220
|
const andWhenProxy = new Proxy(pm, {
|
|
230
221
|
get(target, prop, receiver) {
|
|
231
222
|
if (prop === "customScreenShot") {
|
|
@@ -269,7 +260,16 @@ class BaseThen {
|
|
|
269
260
|
};
|
|
270
261
|
}
|
|
271
262
|
async test(store, testResourceConfiguration, tLog, pm, filepath) {
|
|
272
|
-
|
|
263
|
+
this.go = async (s) => {
|
|
264
|
+
tLog(" Then!!!:", this.name);
|
|
265
|
+
try {
|
|
266
|
+
await this.thenCB(s);
|
|
267
|
+
}
|
|
268
|
+
catch (e) {
|
|
269
|
+
console.log("test failed", e);
|
|
270
|
+
this.error = e.message;
|
|
271
|
+
}
|
|
272
|
+
};
|
|
273
273
|
try {
|
|
274
274
|
const butThenProxy = new Proxy(pm, {
|
|
275
275
|
get(target, prop, receiver) {
|
|
@@ -283,7 +283,7 @@ class BaseThen {
|
|
|
283
283
|
return Reflect.get(...arguments);
|
|
284
284
|
},
|
|
285
285
|
});
|
|
286
|
-
return this.butThen(store, this.
|
|
286
|
+
return this.butThen(store, this.go, testResourceConfiguration, butThenProxy).catch((e) => {
|
|
287
287
|
this.error = true;
|
|
288
288
|
throw e;
|
|
289
289
|
});
|
|
@@ -294,35 +294,41 @@ class BaseThen {
|
|
|
294
294
|
throw e;
|
|
295
295
|
}
|
|
296
296
|
}
|
|
297
|
+
check() { }
|
|
297
298
|
}
|
|
298
299
|
exports.BaseThen = BaseThen;
|
|
299
300
|
class BaseCheck {
|
|
300
|
-
constructor(name, features,
|
|
301
|
+
constructor(name, features, checker, x, checkCB) {
|
|
301
302
|
this.name = name;
|
|
302
303
|
this.features = features;
|
|
303
304
|
this.checkCB = checkCB;
|
|
304
|
-
this.
|
|
305
|
-
this.thens = thens;
|
|
305
|
+
this.checker = checker;
|
|
306
306
|
}
|
|
307
|
-
|
|
308
|
-
return
|
|
307
|
+
toObj() {
|
|
308
|
+
return {
|
|
309
|
+
key: this.key,
|
|
310
|
+
name: this.name,
|
|
311
|
+
functionAsString: this.checkCB.toString(),
|
|
312
|
+
// thens: this.thens.map((t) => t.toObj()),
|
|
313
|
+
// error: this.error ? [this.error, this.error.stack] : null,
|
|
314
|
+
// fail: this.fail ? [this.fail] : false,
|
|
315
|
+
features: this.features,
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
async afterEach(store, key, artifactory, pm) {
|
|
319
|
+
return store;
|
|
320
|
+
}
|
|
321
|
+
beforeAll(store,
|
|
322
|
+
// artifactory: ITestArtifactory
|
|
323
|
+
// subject,
|
|
324
|
+
initializer, artifactory, testResource, initialValues, pm) {
|
|
325
|
+
return store;
|
|
309
326
|
}
|
|
310
327
|
async check(subject, key, testResourceConfiguration, tester, artifactory, tLog, pm) {
|
|
328
|
+
this.key = key;
|
|
311
329
|
tLog(`\n Check: ${this.name}`);
|
|
312
|
-
|
|
313
|
-
await this.
|
|
314
|
-
a[key] = async (payload) => {
|
|
315
|
-
return await when(payload, testResourceConfiguration).test(store, testResourceConfiguration, tLog, pm, "x");
|
|
316
|
-
};
|
|
317
|
-
return a;
|
|
318
|
-
}, {}), Object.entries(this.thens).reduce((a, [key, then]) => {
|
|
319
|
-
a[key] = async (payload) => {
|
|
320
|
-
const t = await then(payload, testResourceConfiguration).test(store, testResourceConfiguration, tLog, pm);
|
|
321
|
-
tester(t);
|
|
322
|
-
};
|
|
323
|
-
return a;
|
|
324
|
-
}, {}));
|
|
325
|
-
await this.afterEach(store, key, () => { }, pm);
|
|
330
|
+
this.store = await this.checkThat(subject, testResourceConfiguration, artifactory, this.checkCB, this.initialValues, pm);
|
|
331
|
+
await this.checker(this.store, pm);
|
|
326
332
|
return;
|
|
327
333
|
}
|
|
328
334
|
}
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.BaseBuilder = void 0;
|
|
4
4
|
class BaseBuilder {
|
|
5
5
|
constructor(input, suitesOverrides, givenOverides, whenOverides, thenOverides, checkOverides, testResourceRequirement, testSpecification) {
|
|
6
|
-
this.input = input;
|
|
7
6
|
this.artifacts = [];
|
|
8
7
|
this.artifacts = [];
|
|
9
8
|
this.testResourceRequirement = testResourceRequirement;
|
|
@@ -45,7 +44,7 @@ class BaseBuilder {
|
|
|
45
44
|
puppetMaster.writeFileSync(`bdd_errors.txt`, numberOfFailures.toString());
|
|
46
45
|
const o = this.toObj();
|
|
47
46
|
puppetMaster.writeFileSync(`littleBoard.html`, `
|
|
48
|
-
|
|
47
|
+
<!DOCTYPE html>
|
|
49
48
|
<html lang="en">
|
|
50
49
|
|
|
51
50
|
<head>
|
|
@@ -55,15 +54,15 @@ class BaseBuilder {
|
|
|
55
54
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
56
55
|
<meta name="author" content="" />
|
|
57
56
|
|
|
58
|
-
<link rel="stylesheet" href="/kokomoBay/
|
|
59
|
-
<script src="/kokomoBay/
|
|
57
|
+
<link rel="stylesheet" href="/kokomoBay/testeranto/TestReport.css" />
|
|
58
|
+
<script src="/kokomoBay/testeranto/TestReport.js"></script>
|
|
60
59
|
|
|
61
60
|
</head>
|
|
62
61
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
62
|
+
<body>
|
|
63
|
+
<h1>Test report</h1>
|
|
64
|
+
<div id="root"/>
|
|
65
|
+
</body>
|
|
67
66
|
`);
|
|
68
67
|
puppetMaster.writeFileSync(`tests.json`, JSON.stringify(this.toObj(), null, 2));
|
|
69
68
|
return {
|