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.
Files changed (87) hide show
  1. package/README.md +6 -1
  2. package/bundle.js +1 -1
  3. package/dist/common/Init.js +55 -61
  4. package/dist/common/PM/base.js +233 -0
  5. package/dist/common/PM/main.js +217 -434
  6. package/dist/common/build.js +113 -92
  7. package/dist/common/defaultConfig.js +2 -2
  8. package/dist/common/esbuildConfigs/index.js +1 -1
  9. package/dist/common/esbuildConfigs/inputFilesPlugin.js +7 -3
  10. package/dist/common/esbuildConfigs/node.js +5 -3
  11. package/dist/common/esbuildConfigs/web.js +3 -3
  12. package/dist/common/init-docs.js +2 -46
  13. package/dist/common/lib/abstractBase.js +60 -54
  14. package/dist/common/lib/basebuilder.js +7 -8
  15. package/dist/common/lib/classBuilder.js +8 -5
  16. package/dist/common/lib/core.js +6 -18
  17. package/dist/common/lib/index.js +6 -1
  18. package/dist/common/run.js +10 -2
  19. package/dist/common/tsconfig.common.tsbuildinfo +1 -1
  20. package/dist/common/utils.js +9 -21
  21. package/dist/module/Init.js +55 -61
  22. package/dist/module/PM/base.js +226 -0
  23. package/dist/module/PM/main.js +218 -435
  24. package/dist/module/Project.js +117 -0
  25. package/dist/module/TestReport.js +13 -4
  26. package/dist/module/build.js +113 -92
  27. package/dist/module/defaultConfig.js +2 -2
  28. package/dist/module/esbuildConfigs/index.js +1 -1
  29. package/dist/module/esbuildConfigs/inputFilesPlugin.js +7 -3
  30. package/dist/module/esbuildConfigs/node.js +5 -3
  31. package/dist/module/esbuildConfigs/web.js +3 -3
  32. package/dist/module/init-docs.js +2 -13
  33. package/dist/module/lib/abstractBase.js +60 -54
  34. package/dist/module/lib/basebuilder.js +7 -8
  35. package/dist/module/lib/classBuilder.js +8 -5
  36. package/dist/module/lib/core.js +6 -18
  37. package/dist/module/lib/index.js +6 -1
  38. package/dist/module/run.js +10 -2
  39. package/dist/module/tsconfig.module.tsbuildinfo +1 -1
  40. package/dist/module/utils.js +8 -17
  41. package/dist/prebuild/Project.css +11367 -0
  42. package/dist/prebuild/Project.js +24640 -0
  43. package/dist/prebuild/ReportClient.js +1 -1
  44. package/dist/prebuild/TestReport.js +9 -11
  45. package/dist/prebuild/build.mjs +142 -81
  46. package/dist/prebuild/init-docs.mjs +28 -83
  47. package/dist/prebuild/run.mjs +618 -537
  48. package/dist/tsconfig.tsbuildinfo +1 -1
  49. package/dist/types/Init.d.ts +1 -1
  50. package/dist/types/PM/base.d.ts +38 -0
  51. package/dist/types/PM/main.d.ts +20 -44
  52. package/dist/types/esbuildConfigs/inputFilesPlugin.d.ts +1 -1
  53. package/dist/types/esbuildConfigs/node.d.ts +1 -1
  54. package/dist/types/esbuildConfigs/web.d.ts +1 -1
  55. package/dist/types/lib/abstractBase.d.ts +19 -11
  56. package/dist/types/lib/basebuilder.d.ts +1 -2
  57. package/dist/types/lib/index.d.ts +3 -3
  58. package/dist/types/lib/types.d.ts +2 -5
  59. package/dist/types/tsconfig.types.tsbuildinfo +1 -1
  60. package/dist/types/utils.d.ts +4 -7
  61. package/package.json +6 -5
  62. package/src/Init.ts +60 -68
  63. package/src/PM/base.ts +301 -0
  64. package/src/PM/main.ts +276 -567
  65. package/src/Project.tsx +197 -0
  66. package/src/ReportClient.tsx +1 -1
  67. package/src/TestReport.tsx +30 -15
  68. package/src/build.ts +140 -104
  69. package/src/defaultConfig.ts +2 -2
  70. package/src/esbuildConfigs/index.ts +1 -1
  71. package/src/esbuildConfigs/inputFilesPlugin.ts +7 -6
  72. package/src/esbuildConfigs/node.ts +5 -3
  73. package/src/esbuildConfigs/web.ts +4 -3
  74. package/src/init-docs.ts +2 -15
  75. package/src/lib/abstractBase.ts +113 -93
  76. package/src/lib/basebuilder.ts +8 -9
  77. package/src/lib/classBuilder.ts +11 -10
  78. package/src/lib/core.ts +15 -27
  79. package/src/lib/index.ts +13 -6
  80. package/src/lib/types.ts +3 -8
  81. package/src/run.ts +21 -5
  82. package/src/utils.ts +27 -39
  83. package/tsc.log +12 -23
  84. package/dist/common/puppeteerConfiger.js +0 -24
  85. package/dist/module/puppeteerConfiger.js +0 -19
  86. package/dist/types/puppeteerConfiger.d.ts +0 -4
  87. package/src/puppeteerConfiger.ts +0 -26
@@ -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
- const getRunnables = (tests, payload = {
51
- nodeEntryPoints: {},
52
- webEntryPoints: {},
53
- }) => {
54
- return tests.reduce((pt, cv, cndx, cry) => {
55
- if (cv[1] === "node") {
56
- pt.nodeEntryPoints[cv[0]] = path_1.default.resolve(`./docs/node/${cv[0].split(".").slice(0, -1).concat("mjs").join(".")}`);
57
- }
58
- else if (cv[1] === "web") {
59
- pt.webEntryPoints[cv[0]] = path_1.default.resolve(`./docs/web/${cv[0].split(".").slice(0, -1).concat("mjs").join(".")}`);
60
- }
61
- if (cv[3].length) {
62
- getRunnables(cv[3], payload);
63
- }
64
- return pt;
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() + "/" + rawConfig.outdir });
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 && status === "built") {
104
- // Object.entries(nodeEntryPoints).forEach(([k, outputFile]) => {
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
- console.log(`Press 'q' to shutdown gracefully. Press 'x' to shutdown forcefully.`);
157
- process.stdin.on("keypress", (str, key) => {
158
- if (key.name === "q") {
159
- console.log("Testeranto-Build is shutting down...");
160
- mode = "PROD";
161
- onDone();
162
- }
163
- if (key.name === "x") {
164
- console.log("Testeranto-Build is shutting down forcefully...");
165
- process.exit(-1);
166
- }
167
- });
168
- fs_1.default.writeFileSync(`${config.outdir}/testeranto.json`, JSON.stringify(config, null, 2));
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()}/${config.outdir}/web/${sourceDir.join("/")}/${sourceFileNameMinusJs}.html`);
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)(`./${config.outdir}/chunk-*.mjs`, {
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 (config.devMode) {
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 (config.devMode) {
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: [],
@@ -7,7 +7,7 @@ exports.default = (config) => {
7
7
  format: "esm",
8
8
  splitting: true,
9
9
  outExtension: { ".js": ".mjs" },
10
- outbase: config.outbase,
10
+ outbase: ".",
11
11
  jsx: "transform",
12
12
  bundle: true,
13
13
  minify: config.minify === true,
@@ -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, entryPoints) => {
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
- // console.log("build.onEnd", entryPoints);
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", entryPoints);
11
- return Object.assign(Object.assign({}, (0, index_js_1.default)(config)), { splitting: true, outdir: config.outdir + "/node",
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", entryPoints);
12
- return Object.assign(Object.assign({}, (0, index_js_1.default)(config)), { outdir: config.outdir + "/web", alias: {
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",
@@ -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
- if (!process.argv[2]) {
43
- console.log("You didn't pass a config file, so I will create one for you.");
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! no error will be recorded!", e);
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
- tLog(" Then:", this.name);
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.thenCB, testResourceConfiguration, butThenProxy).catch((e) => {
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, checkCB, whens, thens) {
301
+ constructor(name, features, checker, x, checkCB) {
301
302
  this.name = name;
302
303
  this.features = features;
303
304
  this.checkCB = checkCB;
304
- this.whens = whens;
305
- this.thens = thens;
305
+ this.checker = checker;
306
306
  }
307
- async afterEach(store, key, cb, pm) {
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
- const store = await this.checkThat(subject, testResourceConfiguration, artifactory, pm);
313
- await this.checkCB(Object.entries(this.whens).reduce((a, [key, when]) => {
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
- <!DOCTYPE html>
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/docs/TestReport.css" />
59
- <script src="/kokomoBay/docs/TestReport.js"></script>
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
- <body>
64
- <h1>Test report</h1>
65
- <div id="root"/>
66
- </body>
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 {