testeranto 0.173.0 → 0.177.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.
Files changed (145) hide show
  1. package/dist/common/src/PM/base.js +5 -5
  2. package/dist/common/src/PM/main.js +48 -52
  3. package/dist/common/src/PM/node.js +4 -1
  4. package/dist/common/src/PM/pure.js +4 -1
  5. package/dist/common/src/PM/web.js +4 -1
  6. package/dist/common/src/Pure.js +0 -4
  7. package/dist/common/src/Pure.test.js +1 -1
  8. package/dist/common/src/ReportServerLib.js +11 -5
  9. package/dist/common/src/esbuildConfigs/node.js +1 -3
  10. package/dist/common/src/lib/BaseSuite.js +13 -11
  11. package/dist/common/src/lib/abstractBase.js +39 -42
  12. package/dist/common/src/lib/basebuilder.js +5 -0
  13. package/dist/common/src/lib/core.js +1 -0
  14. package/dist/common/src/lib/pmProxy.js +210 -100
  15. package/dist/common/src/lib/pmProxy.test/adapter.js +2 -2
  16. package/dist/common/src/lib/pmProxy.test/implementation.js +1 -1
  17. package/dist/common/testeranto.config.js +39 -39
  18. package/dist/common/tsconfig.common.tsbuildinfo +1 -1
  19. package/dist/module/src/PM/base.js +5 -5
  20. package/dist/module/src/PM/main.js +13 -17
  21. package/dist/module/src/PM/node.js +4 -1
  22. package/dist/module/src/PM/pure.js +4 -1
  23. package/dist/module/src/PM/web.js +4 -1
  24. package/dist/module/src/Pure.js +0 -4
  25. package/dist/module/src/Pure.test.js +1 -1
  26. package/dist/module/src/ReportServerLib.js +11 -5
  27. package/dist/module/src/esbuildConfigs/node.js +1 -3
  28. package/dist/module/src/lib/BaseSuite.js +13 -11
  29. package/dist/module/src/lib/abstractBase.js +39 -42
  30. package/dist/module/src/lib/basebuilder.js +5 -0
  31. package/dist/module/src/lib/core.js +1 -0
  32. package/dist/module/src/lib/pmProxy.js +210 -100
  33. package/dist/module/src/lib/pmProxy.test/adapter.js +2 -2
  34. package/dist/module/src/lib/pmProxy.test/implementation.js +1 -1
  35. package/dist/module/testeranto.config.js +39 -39
  36. package/dist/module/tsconfig.module.tsbuildinfo +1 -1
  37. package/dist/prebuild/ReportServer.mjs +10 -4
  38. package/dist/prebuild/build.mjs +1 -1
  39. package/dist/prebuild/run.mjs +19 -22
  40. package/dist/types/src/PM/base.d.ts +1 -1
  41. package/dist/types/src/PM/node.d.ts +1 -1
  42. package/dist/types/src/PM/pure.d.ts +1 -1
  43. package/dist/types/src/PM/web.d.ts +1 -1
  44. package/dist/types/src/ReportServerLib.d.ts +1 -2
  45. package/dist/types/src/lib/BaseSuite.d.ts +2 -0
  46. package/dist/types/src/lib/abstractBase.d.ts +4 -6
  47. package/dist/types/src/lib/pmProxy.d.ts +3 -3
  48. package/dist/types/tsconfig.types.tsbuildinfo +1 -1
  49. package/package.json +2 -2
  50. package/src/PM/base.ts +6 -9
  51. package/src/PM/main.ts +17 -20
  52. package/src/PM/node.ts +6 -1
  53. package/src/PM/pure.ts +6 -1
  54. package/src/PM/web.ts +5 -1
  55. package/src/Pure.test.ts +6 -6
  56. package/src/Pure.ts +0 -8
  57. package/src/ReportServerLib.ts +10 -7
  58. package/src/esbuildConfigs/node.ts +1 -1
  59. package/src/lib/BaseSuite.ts +16 -21
  60. package/src/lib/abstractBase.ts +57 -49
  61. package/src/lib/basebuilder.ts +6 -0
  62. package/src/lib/core.ts +1 -0
  63. package/src/lib/pmProxy.test/adapter.ts +2 -2
  64. package/src/lib/pmProxy.test/implementation.ts +3 -3
  65. package/src/lib/pmProxy.test/types.ts +0 -2
  66. package/src/lib/pmProxy.ts +224 -92
  67. package/testeranto/bundles/node/core/metafile.json +2 -480
  68. package/testeranto/bundles/pure/core/metafile.json +3 -621
  69. package/testeranto/bundles/web/core/metafile.json +14384 -78
  70. package/testeranto/bundles/web/core/src/{lib/baseBuilder.test/baseBuilder.test.web.html → components/pure/ProjectPageView.test/index.html} +2 -2
  71. package/testeranto/bundles/web/core/src/components/pure/ProjectPageView.test/index.mjs +39991 -0
  72. package/testeranto/projects.json +0 -1
  73. package/testeranto/reports/core/config.json +5 -5
  74. package/testeranto/reports/core/src/components/pure/ProjectPageView.test/index/web/lint_errors.txt +18 -0
  75. package/testeranto/reports/core/src/components/pure/ProjectPageView.test/index/web/logs.txt +59 -0
  76. package/testeranto/reports/core/src/components/pure/ProjectPageView.test/index/web/message.txt +2 -0
  77. package/testeranto/reports/core/src/components/pure/ProjectPageView.test/index/web/prompt.txt +27 -0
  78. package/testeranto/reports/core/src/components/pure/ProjectPageView.test/index/web/suite-0/given-basicRender/then-0/butThen/happyPath.png +0 -0
  79. package/testeranto/reports/{staticSite/src/ReportServer.test.ts/index/node → core/src/components/pure/ProjectPageView.test/index/web}/type_errors.txt +20 -22
  80. package/testeranto/reports/core/summary.json +5 -19
  81. package/testeranto.config.ts +39 -39
  82. package/tsc.log +78 -92
  83. package/testeranto/bundles/node/allTests/metafile.json +0 -486
  84. package/testeranto/bundles/node/allTests/src/lib/baseBuilder.test/baseBuilder.test.node.mjs +0 -1182
  85. package/testeranto/bundles/node/core/src/lib/baseBuilder.test/baseBuilder.test.node.mjs +0 -1182
  86. package/testeranto/bundles/node/staticSite/metafile.json +0 -593
  87. package/testeranto/bundles/node/staticSite/src/ReportServer.test.ts/index.mjs +0 -1594
  88. package/testeranto/bundles/pure/allTests/metafile.json +0 -626
  89. package/testeranto/bundles/pure/allTests/src/lib/baseBuilder.test/baseBuilder.test.pure.mjs +0 -1094
  90. package/testeranto/bundles/pure/core/src/lib/baseBuilder.test/baseBuilder.test.pure.mjs +0 -1094
  91. package/testeranto/bundles/pure/staticSite/metafile.json +0 -8
  92. package/testeranto/bundles/web/allTests/metafile.json +0 -780
  93. package/testeranto/bundles/web/allTests/src/lib/baseBuilder.test/baseBuilder.test.web.html +0 -19
  94. package/testeranto/bundles/web/allTests/src/lib/baseBuilder.test/baseBuilder.test.web.mjs +0 -1092
  95. package/testeranto/bundles/web/core/src/lib/baseBuilder.test/baseBuilder.test.web.mjs +0 -1092
  96. package/testeranto/bundles/web/staticSite/metafile.json +0 -8
  97. package/testeranto/reports/allTests/config.json +0 -40
  98. package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.node/node/bdd_errors.txt +0 -1
  99. package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.node/node/lint_errors.txt +0 -2
  100. package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.node/node/logs.txt +0 -33
  101. package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.node/node/message.txt +0 -2
  102. package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.node/node/prompt.txt +0 -26
  103. package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.node/node/suite-0/given-testInitialization/then-0/butThen/hello.txt +0 -1
  104. package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.node/node/tests.json +0 -69
  105. package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.node/node/type_errors.txt +0 -74
  106. package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.pure/pure/lint_errors.txt +0 -2
  107. package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.pure/pure/message.txt +0 -2
  108. package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.pure/pure/prompt.txt +0 -26
  109. package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.pure/pure/type_errors.txt +0 -74
  110. package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.web/web/bdd_errors.txt +0 -1
  111. package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.web/web/lint_errors.txt +0 -2
  112. package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.web/web/logs.txt +0 -63
  113. package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.web/web/message.txt +0 -2
  114. package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.web/web/prompt.txt +0 -26
  115. package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.web/web/suite-0/given-testInitialization/then-0/butThen/hello.txt +0 -1
  116. package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.web/web/tests.json +0 -69
  117. package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.web/web/type_errors.txt +0 -74
  118. package/testeranto/reports/allTests/summary.json +0 -23
  119. package/testeranto/reports/core/src/lib/baseBuilder.test/baseBuilder.test.node/node/bdd_errors.txt +0 -1
  120. package/testeranto/reports/core/src/lib/baseBuilder.test/baseBuilder.test.node/node/lint_errors.txt +0 -2
  121. package/testeranto/reports/core/src/lib/baseBuilder.test/baseBuilder.test.node/node/logs.txt +0 -32
  122. package/testeranto/reports/core/src/lib/baseBuilder.test/baseBuilder.test.node/node/message.txt +0 -2
  123. package/testeranto/reports/core/src/lib/baseBuilder.test/baseBuilder.test.node/node/prompt.txt +0 -26
  124. package/testeranto/reports/core/src/lib/baseBuilder.test/baseBuilder.test.node/node/suite-0/given-testInitialization/then-0/butThen/hello.txt +0 -1
  125. package/testeranto/reports/core/src/lib/baseBuilder.test/baseBuilder.test.node/node/tests.json +0 -69
  126. package/testeranto/reports/core/src/lib/baseBuilder.test/baseBuilder.test.node/node/type_errors.txt +0 -74
  127. package/testeranto/reports/core/src/lib/baseBuilder.test/baseBuilder.test.pure/pure/lint_errors.txt +0 -2
  128. package/testeranto/reports/core/src/lib/baseBuilder.test/baseBuilder.test.pure/pure/message.txt +0 -2
  129. package/testeranto/reports/core/src/lib/baseBuilder.test/baseBuilder.test.pure/pure/prompt.txt +0 -26
  130. package/testeranto/reports/core/src/lib/baseBuilder.test/baseBuilder.test.pure/pure/type_errors.txt +0 -74
  131. package/testeranto/reports/core/src/lib/baseBuilder.test/baseBuilder.test.web/web/bdd_errors.txt +0 -1
  132. package/testeranto/reports/core/src/lib/baseBuilder.test/baseBuilder.test.web/web/lint_errors.txt +0 -2
  133. package/testeranto/reports/core/src/lib/baseBuilder.test/baseBuilder.test.web/web/logs.txt +0 -61
  134. package/testeranto/reports/core/src/lib/baseBuilder.test/baseBuilder.test.web/web/message.txt +0 -2
  135. package/testeranto/reports/core/src/lib/baseBuilder.test/baseBuilder.test.web/web/prompt.txt +0 -26
  136. package/testeranto/reports/core/src/lib/baseBuilder.test/baseBuilder.test.web/web/suite-0/given-testInitialization/then-0/butThen/hello.txt +0 -1
  137. package/testeranto/reports/core/src/lib/baseBuilder.test/baseBuilder.test.web/web/tests.json +0 -69
  138. package/testeranto/reports/core/src/lib/baseBuilder.test/baseBuilder.test.web/web/type_errors.txt +0 -74
  139. package/testeranto/reports/staticSite/config.json +0 -24
  140. package/testeranto/reports/staticSite/src/ReportServer.test.ts/index/node/lint_errors.txt +0 -5
  141. package/testeranto/reports/staticSite/src/ReportServer.test.ts/index/node/logs.txt +0 -44
  142. package/testeranto/reports/staticSite/src/ReportServer.test.ts/index/node/message.txt +0 -2
  143. package/testeranto/reports/staticSite/src/ReportServer.test.ts/index/node/prompt.txt +0 -23
  144. package/testeranto/reports/staticSite/summary.json +0 -9
  145. package/testeranto/reportsnode_build_errors +0 -17
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "testeranto",
3
3
  "description": "the AI powered BDD test framework for typescript projects",
4
- "version": "0.173.0",
4
+ "version": "0.177.0",
5
5
  "engines": {
6
6
  "node": "18.18.0"
7
7
  },
@@ -165,7 +165,7 @@
165
165
  "@typescript-eslint/parser": "^5.46.0",
166
166
  "marked": "^12.0.2",
167
167
  "self-import": "*",
168
- "testeranto-react": "0.0.5",
168
+ "testeranto-react": "0.0.8",
169
169
  "ts-node": "^10.9.1",
170
170
  "typescript": "^5.8.2"
171
171
  },
package/src/PM/base.ts CHANGED
@@ -162,15 +162,12 @@ export abstract class PM_Base {
162
162
  return false;
163
163
  }
164
164
 
165
- async writeFileSync(
166
- filepath: string,
167
- contents: string,
168
- testName: string
169
- ): Promise<boolean> {
170
- console.log("writeFileSync");
171
- console.log("filepath", filepath);
172
- console.log("contents", contents);
173
- console.log("testName", testName);
165
+ async writeFileSync(...x): Promise<boolean> {
166
+ const filepath = x[0];
167
+ const contents = x[1];
168
+ const testName = x[2];
169
+
170
+ console.log("writing file", filepath);
174
171
 
175
172
  return new Promise<boolean>(async (res) => {
176
173
  fs.mkdirSync(path.dirname(filepath), {
package/src/PM/main.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  /* eslint-disable @typescript-eslint/no-explicit-any */
4
4
  /* eslint-disable @typescript-eslint/no-unused-vars */
5
5
  import { ChildProcess, spawn } from "node:child_process";
6
-
6
+ import ansiColors from "ansi-colors";
7
7
  import net from "net";
8
8
  import { Page } from "puppeteer-core/lib/esm/puppeteer";
9
9
  import fs, { watch } from "fs";
@@ -21,8 +21,8 @@ import { getRunnables } from "../utils";
21
21
  import { IBuiltConfig, IRunTime, ITestTypes } from "../Types.js";
22
22
  import { Sidecar } from "../lib/Sidecar.js";
23
23
  import { Queue } from "../utils/queue.js";
24
+
24
25
  import { PM_WithEslintAndTsc } from "./PM_WithEslintAndTsc.js";
25
- import ansiColors from "ansi-colors";
26
26
 
27
27
  type IOutputs = Record<
28
28
  string,
@@ -105,13 +105,10 @@ function isValidUrl(string) {
105
105
 
106
106
  // Wait for file to exist, checks every 2 seconds by default
107
107
  async function pollForFile(path, timeout = 2000) {
108
- console.log(`pollForFile: ${path}...`);
109
-
110
108
  const intervalObj = setInterval(function () {
111
109
  const file = path;
112
110
  const fileExists = fs.existsSync(file);
113
111
  if (fileExists) {
114
- console.log(`metafile found: ${path}!`);
115
112
  clearInterval(intervalObj);
116
113
  }
117
114
  }, timeout);
@@ -1253,17 +1250,6 @@ export class PM_Main extends PM_WithEslintAndTsc {
1253
1250
 
1254
1251
  const d = `${dest}?cacheBust=${Date.now()}`;
1255
1252
 
1256
- const evaluation = `
1257
-
1258
- import('${d}').then(async (x) => {
1259
-
1260
- try {
1261
- return await (await x.default).receiveTestResourceConfig(${webArgz})
1262
- } catch (e) {
1263
- console.log("web run failure", e.toString())
1264
- }
1265
- })`;
1266
-
1267
1253
  const ofile = `${reportDest}/logs.txt`;
1268
1254
  const oStream = fs.createWriteStream(ofile);
1269
1255
 
@@ -1304,7 +1290,7 @@ export class PM_Main extends PM_WithEslintAndTsc {
1304
1290
  page.close();
1305
1291
  oStream.close();
1306
1292
  });
1307
- console.log("ostream is closed");
1293
+
1308
1294
  return;
1309
1295
  };
1310
1296
 
@@ -1355,14 +1341,24 @@ export class PM_Main extends PM_WithEslintAndTsc {
1355
1341
  await page.goto(`file://${`${destFolder}.html`}`, {});
1356
1342
 
1357
1343
  await page
1358
- .evaluate(evaluation)
1344
+ .evaluate(
1345
+ `
1346
+ import('${d}').then(async (x) => {
1347
+ try {
1348
+ return await (await x.default).receiveTestResourceConfig(${webArgz})
1349
+ } catch (e) {
1350
+ console.log("web run failure", e.toString())
1351
+ }
1352
+ })
1353
+ `
1354
+ )
1359
1355
  .then(async ({ fails, failed, features }: IFinalResults) => {
1360
1356
  statusMessagePretty(fails, src, "web");
1361
1357
  this.bddTestIsNowDone(src, fails);
1362
- close();
1358
+ // close();
1363
1359
  })
1364
1360
  .catch((e) => {
1365
- console.log(ansiC.red(ansiC.inverse(e)));
1361
+ console.log(ansiC.red(ansiC.inverse(e.stack)));
1366
1362
 
1367
1363
  console.log(
1368
1364
  ansiC.red(
@@ -1375,6 +1371,7 @@ export class PM_Main extends PM_WithEslintAndTsc {
1375
1371
  })
1376
1372
  .finally(() => {
1377
1373
  // process.exit(-1);
1374
+ close();
1378
1375
  });
1379
1376
 
1380
1377
  return page;
package/src/PM/node.ts CHANGED
@@ -182,7 +182,12 @@ export class PM_Node extends PM {
182
182
  return await this.send("write", ...arguments);
183
183
  }
184
184
 
185
- async writeFileSync([filepath, contents]: [string, string]) {
185
+ async writeFileSync(x) {
186
+ const z = arguments["0"];
187
+
188
+ const filepath = z[0];
189
+ const contents = z[1];
190
+
186
191
  return await this.send<boolean>(
187
192
  "writeFileSync",
188
193
  this.testResourceConfiguration.fs + "/" + filepath,
package/src/PM/pure.ts CHANGED
@@ -136,7 +136,12 @@ export class PM_Pure extends PM {
136
136
  return globalThis["write"](uid, contents);
137
137
  }
138
138
 
139
- writeFileSync(filepath: string, contents: string) {
139
+ writeFileSync(x) {
140
+ const z = arguments["0"];
141
+
142
+ const filepath = z[0];
143
+ const contents = z[1];
144
+
140
145
  return globalThis["writeFileSync"](
141
146
  this.testResourceConfiguration.fs + "/" + filepath,
142
147
  contents,
package/src/PM/web.ts CHANGED
@@ -135,7 +135,11 @@ export class PM_Web extends PM {
135
135
  return window["write"](uid, contents);
136
136
  }
137
137
 
138
- writeFileSync([filepath, contents]: [string, string]) {
138
+ writeFileSync(x) {
139
+ const z = arguments["0"];
140
+
141
+ const filepath = z[0];
142
+ const contents = z[1];
139
143
  return window["writeFileSync"](
140
144
  this.testResourceConfiguration.fs + "/" + filepath,
141
145
  contents,
package/src/Pure.test.ts CHANGED
@@ -105,8 +105,8 @@ const implementation: ITestImplementation<I, O> = {
105
105
  ...store,
106
106
  pm: {
107
107
  ...store.pm,
108
- testResourceConfiguration: { name: "test-resource" }
109
- }
108
+ testResourceConfiguration: { name: "test-resource" },
109
+ },
110
110
  };
111
111
  default:
112
112
  return store;
@@ -116,23 +116,23 @@ const implementation: ITestImplementation<I, O> = {
116
116
  console.debug("[DEBUG] Adding artifact");
117
117
  return {
118
118
  ...store,
119
- artifacts: [...(store.artifacts || []), artifact]
119
+ artifacts: [...(store.artifacts || []), artifact],
120
120
  };
121
121
  },
122
122
  setTestJobs: (jobs: any[]) => (store) => {
123
123
  console.debug("[DEBUG] Setting test jobs");
124
124
  return {
125
125
  ...store,
126
- testJobs: jobs
126
+ testJobs: jobs,
127
127
  };
128
128
  },
129
129
  modifySpecs: (modifier: (specs: any) => any[]) => (store) => {
130
130
  console.debug("[DEBUG] Modifying specs");
131
131
  return {
132
132
  ...store,
133
- specs: modifier(store.specs || [])
133
+ specs: modifier(store.specs || []),
134
134
  };
135
- }
135
+ },
136
136
  },
137
137
 
138
138
  thens: {
package/src/Pure.ts CHANGED
@@ -39,15 +39,9 @@ export class PureTesteranto<
39
39
  }
40
40
 
41
41
  async receiveTestResourceConfig(partialTestResource: string) {
42
- console.log(
43
- "[DEBUG] receiveTestResourceConfig called with:",
44
- partialTestResource
45
- );
46
42
  const t: ITTestResourceConfiguration = JSON.parse(partialTestResource);
47
43
  const pm = new PM_Pure(t);
48
44
 
49
- // console.log("[DEBUG] Current test jobs:", this.testJobs?.length);
50
-
51
45
  // if (!this.testJobs || this.testJobs.length === 0) {
52
46
  // console.error(
53
47
  // "[ERROR] No test jobs available - checking specs:",
@@ -64,9 +58,7 @@ export class PureTesteranto<
64
58
  // }
65
59
 
66
60
  try {
67
- console.log("[DEBUG] Executing test job with PM:", pm);
68
61
  const result = await this.testJobs[0].receiveTestResourceConfig(pm);
69
- console.log("[DEBUG] Test job completed with result:", result);
70
62
  return result;
71
63
  } catch (e) {
72
64
  console.error("[ERROR] Test job failed:", e);
@@ -133,12 +133,15 @@ process.on("uncaughtException", (err) => {
133
133
  console.error("Uncaught exception:", err);
134
134
  });
135
135
 
136
- const start = (port: number) =>
137
- server.listen(port, () => {
138
- console.log(`Server running on http://localhost:${port}`);
139
- console.log("Serving files from:", process.cwd());
140
- });
136
+ const start = (port: number) => {
137
+ if (port) {
138
+ server.listen(port, () => {
139
+ console.log(`Server running on http://localhost:${port}`);
140
+ console.log("Serving files from:", process.cwd());
141
+ });
142
+ } else {
143
+ console.log("you need to specify a port");
144
+ }
145
+ };
141
146
 
142
147
  export const ReportServerOfPort = (port: number) => start(port);
143
-
144
- // export default () => start(process.argv[2]);
@@ -23,7 +23,7 @@ export default (
23
23
 
24
24
  outdir: `testeranto/bundles/node/${testName}/`,
25
25
 
26
- // inject: [`./node_modules/testeranto/dist/cjs-shim.js`],
26
+ inject: [`./node_modules/testeranto/dist/cjs-shim.js`],
27
27
  metafile: true,
28
28
  supported: {
29
29
  "dynamic-import": true,
@@ -14,23 +14,24 @@ export abstract class BaseSuite<I extends Ibdd_in_any, O extends Ibdd_out_any> {
14
14
  failed: boolean;
15
15
  fails: number;
16
16
 
17
+ artifacts: string[] = [];
18
+
19
+ addArtifact(path: string) {
20
+ console.log("Suite addArtifact", path);
21
+ const normalizedPath = path.replace(/\\/g, "/"); // Normalize path separators
22
+ this.artifacts.push(normalizedPath);
23
+ }
24
+
17
25
  constructor(name: string, index: number, givens: IGivens<I> = {}) {
18
26
  const suiteName = name || "testSuite"; // Ensure name is never undefined
19
27
  if (!suiteName) {
20
28
  throw new Error("BaseSuite requires a non-empty name");
21
29
  }
22
- console.log(
23
- "[DEBUG] BaseSuite constructor - name:",
24
- suiteName,
25
- "index:",
26
- index
27
- );
30
+
28
31
  this.name = suiteName;
29
32
  this.index = index;
30
33
  this.givens = givens;
31
34
  this.fails = 0;
32
- console.log("[DEBUG] BaseSuite initialized:", this.name, this.index);
33
- console.log("[DEBUG] BaseSuite givens:", Object.keys(givens).toString());
34
35
  }
35
36
 
36
37
  public features() {
@@ -41,10 +42,9 @@ export abstract class BaseSuite<I extends Ibdd_in_any, O extends Ibdd_out_any> {
41
42
  .filter((value, index, array) => {
42
43
  return array.indexOf(value) === index;
43
44
  });
44
- console.debug("[DEBUG] Features extracted:", features.toString());
45
45
  return features || [];
46
46
  } catch (e) {
47
- console.error("[ERROR] Failed to extract features:", e);
47
+ console.error("[ERROR] Failed to extract features:", JSON.stringify(e));
48
48
  return [];
49
49
  }
50
50
  }
@@ -92,15 +92,14 @@ export abstract class BaseSuite<I extends Ibdd_in_any, O extends Ibdd_out_any> {
92
92
  artifactory(`suite-${this.index}-${this.name}/${fPath}`, value);
93
93
 
94
94
  // console.log("\nSuite:", this.index, this.name);
95
- tLog("\nSuite:", this.index, this.name);
95
+ // tLog("\nSuite:", this.index, this.name);
96
96
  const sNdx = this.index;
97
- // const sName = this.name;
98
-
97
+ const proxiedPm = beforeAllProxy(pm, sNdx.toString(), this);
99
98
  const subject = await this.setup(
100
99
  input,
101
100
  suiteArtifactory,
102
101
  testResourceConfiguration,
103
- beforeAllProxy(pm, sNdx.toString())
102
+ proxiedPm
104
103
  );
105
104
 
106
105
  for (const [gKey, g] of Object.entries(this.givens)) {
@@ -119,19 +118,15 @@ export abstract class BaseSuite<I extends Ibdd_in_any, O extends Ibdd_out_any> {
119
118
  .catch((e) => {
120
119
  this.failed = true;
121
120
  this.fails = this.fails + 1;
122
- // console.error("Given error 1:", e.toString());
123
121
  throw e;
124
122
  });
125
123
  }
126
124
 
127
125
  try {
128
- this.afterAll(
129
- this.store,
130
- artifactory,
131
- afterAllProxy(pm, sNdx.toString())
132
- );
126
+ const afterAllPm = afterAllProxy(pm, sNdx.toString(), this);
127
+ this.afterAll(this.store, artifactory, afterAllPm);
133
128
  } catch (e) {
134
- console.error(e);
129
+ console.error(JSON.stringify(e));
135
130
  // this.fails.push(this);
136
131
  // return this;
137
132
  }
@@ -28,11 +28,11 @@ export abstract class BaseGiven<I extends Ibdd_in_any> {
28
28
  key: string;
29
29
  failed: boolean;
30
30
  artifacts: string[] = [];
31
- protected addArtifact(path: string) {
32
- console.log(`[Artifact] Adding to ${this.constructor.name}:`, path);
33
- // console.log("mark111");
34
- // process.exit();
35
- this.artifacts.push(path);
31
+
32
+ addArtifact(path: string) {
33
+ console.log("Given addArtifact", path);
34
+ const normalizedPath = path.replace(/\\/g, "/"); // Normalize path separators
35
+ this.artifacts.push(normalizedPath);
36
36
  }
37
37
 
38
38
  constructor(
@@ -62,7 +62,7 @@ export abstract class BaseGiven<I extends Ibdd_in_any> {
62
62
  whens: this.whens.map((w) => {
63
63
  if (w && w.toObj) return w.toObj();
64
64
 
65
- console.error("w is not as expected!", w.toString());
65
+ console.error("w is not as expected!", JSON.stringify(w));
66
66
  return {};
67
67
  }),
68
68
  thens: this.thens.map((t) => t.toObj()),
@@ -118,9 +118,11 @@ export abstract class BaseGiven<I extends Ibdd_in_any> {
118
118
  });
119
119
 
120
120
  try {
121
- const proxiedPm = beforeEachProxy(pm, suiteNdx.toString());
122
- console.log(`[Given] Setting currentStep for beforeEach:`, this.name);
123
- (proxiedPm as any).currentStep = this;
121
+ const proxiedPm = beforeEachProxy(
122
+ pm,
123
+ suiteNdx.toString(),
124
+ this.addArtifact.bind(this)
125
+ );
124
126
  this.store = await this.givenThat(
125
127
  subject,
126
128
  testResourceConfiguration,
@@ -130,9 +132,9 @@ export abstract class BaseGiven<I extends Ibdd_in_any> {
130
132
  proxiedPm
131
133
  );
132
134
  } catch (e) {
133
- console.error("Given failure: ", e.toString());
134
- this.error = e;
135
- throw e;
135
+ // console.error("Given failure: ", e.stack);
136
+ this.error = e.stack;
137
+ // throw e;
136
138
  }
137
139
 
138
140
  try {
@@ -157,9 +159,6 @@ export abstract class BaseGiven<I extends Ibdd_in_any> {
157
159
  `suite-${suiteNdx}/given-${key}/then-${thenNdx}`
158
160
  );
159
161
  tester(t);
160
- // ((t) => {
161
- // return tester(t);
162
- // })();
163
162
  }
164
163
  } catch (e) {
165
164
  this.failed = true;
@@ -167,21 +166,22 @@ export abstract class BaseGiven<I extends Ibdd_in_any> {
167
166
  throw e;
168
167
  } finally {
169
168
  try {
170
- await this.afterEach(
171
- this.store,
172
- this.key,
173
- givenArtifactory,
174
-
175
- afterEachProxy(pm, suiteNdx.toString(), key)
169
+ const proxiedPm = afterEachProxy(
170
+ pm,
171
+ suiteNdx.toString(),
172
+ key,
173
+ this.addArtifact.bind(this)
176
174
  );
175
+ // (proxiedPm as any).currentStep = this;
176
+ await this.afterEach(this.store, this.key, givenArtifactory, proxiedPm);
177
177
  } catch (e) {
178
- console.error("afterEach failed!", e.toString());
179
178
  this.failed = e;
180
179
  throw e;
181
180
 
182
181
  // this.error = e.message;
183
182
  }
184
183
  }
184
+
185
185
  return this.store;
186
186
  }
187
187
  }
@@ -190,8 +190,15 @@ export abstract class BaseWhen<I extends Ibdd_in_any> {
190
190
  public name: string;
191
191
  whenCB: (x: I["iselection"]) => I["then"];
192
192
  error: Error;
193
+
193
194
  artifacts: string[] = [];
194
195
 
196
+ addArtifact(path: string) {
197
+ console.log("When addArtifact", path);
198
+ const normalizedPath = path.replace(/\\/g, "/"); // Normalize path separators
199
+ this.artifacts.push(normalizedPath);
200
+ }
201
+
195
202
  constructor(name: string, whenCB: (xyz: I["iselection"]) => I["then"]) {
196
203
  this.name = name;
197
204
  this.whenCB = whenCB;
@@ -205,20 +212,18 @@ export abstract class BaseWhen<I extends Ibdd_in_any> {
205
212
  ): Promise<any>;
206
213
 
207
214
  toObj() {
208
- console.log("toObj error", this.error);
209
-
210
- if (this.error) {
211
- return {
212
- name: this.name,
213
- error: this.error && this.error.name + this.error.stack,
214
- artifacts: this.artifacts,
215
- };
216
- } else {
217
- return {
218
- name: this.name,
219
- artifacts: this.artifacts,
220
- };
221
- }
215
+ const obj = {
216
+ name: this.name,
217
+ error: this.error
218
+ ? `${this.error.name}: ${this.error.message}\n${this.error.stack}`
219
+ : null,
220
+ artifacts: this.artifacts || [],
221
+ };
222
+ console.log(
223
+ `[TOOBJ] Serializing ${this.constructor.name} with artifacts:`,
224
+ obj.artifacts
225
+ );
226
+ return obj;
222
227
  }
223
228
 
224
229
  async test(
@@ -229,12 +234,10 @@ export abstract class BaseWhen<I extends Ibdd_in_any> {
229
234
  filepath: string
230
235
  ) {
231
236
  try {
232
- tLog(" When:", this.name);
233
- console.debug("[DEBUG] Executing When step:", this.name.toString());
237
+ // tLog(" When:", this.name);
238
+ const proxiedPm = andWhenProxy(pm, filepath, this.addArtifact.bind(this));
234
239
 
235
- const proxiedPm = andWhenProxy(pm, filepath);
236
- console.log(`[When] Setting currentStep for andWhen:`, this.name);
237
- (proxiedPm as any).currentStep = this;
240
+ // (proxiedPm as any).currentStep = this;
238
241
  const result = await this.andWhen(
239
242
  store,
240
243
  this.whenCB,
@@ -242,9 +245,8 @@ export abstract class BaseWhen<I extends Ibdd_in_any> {
242
245
  proxiedPm
243
246
  );
244
247
 
245
- console.debug("[DEBUG] When step completed:", this.name.toString());
246
248
  return result;
247
- } catch (e: Error) {
249
+ } catch (e: any) {
248
250
  console.error(
249
251
  "[ERROR] When step failed:",
250
252
  this.name.toString(),
@@ -269,14 +271,22 @@ export abstract class BaseThen<I extends Ibdd_in_any> {
269
271
  this.name = name;
270
272
  this.thenCB = thenCB;
271
273
  this.error = false;
274
+ this.artifacts = [];
275
+ }
276
+
277
+ addArtifact(path: string) {
278
+ console.log("Then addArtifact", path);
279
+ const normalizedPath = path.replace(/\\/g, "/"); // Normalize path separators
280
+ this.artifacts.push(normalizedPath);
272
281
  }
273
282
 
274
283
  toObj() {
275
- return {
284
+ const obj = {
276
285
  name: this.name,
277
286
  error: this.error,
278
287
  artifacts: this.artifacts,
279
288
  };
289
+ return obj;
280
290
  }
281
291
 
282
292
  abstract butThen(
@@ -294,9 +304,7 @@ export abstract class BaseThen<I extends Ibdd_in_any> {
294
304
  pm: IPM,
295
305
  filepath: string
296
306
  ): Promise<I["then"] | undefined> {
297
- const proxiedPm = butThenProxy(pm, filepath);
298
- console.log(`[Then] Setting currentStep for butThen:`, this.name);
299
- (proxiedPm as any).currentStep = this;
307
+ const proxiedPm = butThenProxy(pm, filepath, this.addArtifact.bind(this));
300
308
  return this.butThen(
301
309
  store,
302
310
  async (s: I["iselection"]) => {
@@ -307,9 +315,9 @@ export abstract class BaseThen<I extends Ibdd_in_any> {
307
315
  }
308
316
  },
309
317
  testResourceConfiguration,
310
- butThenProxy(pm, filepath)
318
+ proxiedPm
311
319
  ).catch((e) => {
312
- this.error = e.toString();
320
+ this.error = e.stack;
313
321
  // throw e;
314
322
  });
315
323
  }
@@ -72,6 +72,7 @@ export abstract class BaseBuilder<
72
72
  const suiteRunner =
73
73
  (suite: BaseSuite<I, O>) =>
74
74
  async (puppetMaster: IPM, tLog: ITLog): Promise<BaseSuite<I, O>> => {
75
+ console.log("mark17");
75
76
  const x = await suite.run(
76
77
  input,
77
78
  puppetMaster.testResourceConfiguration,
@@ -85,6 +86,7 @@ export abstract class BaseBuilder<
85
86
  tLog,
86
87
  puppetMaster
87
88
  );
89
+ console.log("mark18");
88
90
 
89
91
  return x;
90
92
  };
@@ -113,7 +115,9 @@ export abstract class BaseBuilder<
113
115
  //
114
116
  };
115
117
 
118
+ console.log("mark14");
116
119
  const suiteDone: BaseSuite<I, O> = await runner(puppetMaster, tLog);
120
+ console.log("mark15");
117
121
 
118
122
  // const logPromise = new Promise(async (res) => {
119
123
  // await puppetMaster.end(access);
@@ -132,6 +136,8 @@ export abstract class BaseBuilder<
132
136
  JSON.stringify(this.toObj(), null, 2),
133
137
  ]);
134
138
 
139
+ console.log("mark13");
140
+
135
141
  return {
136
142
  failed: fails > 0,
137
143
  fails,
package/src/lib/core.ts CHANGED
@@ -90,6 +90,7 @@ export default abstract class TesterantoCore<
90
90
  initialValues,
91
91
  pm
92
92
  ) {
93
+ console.log("mark800");
93
94
  return fullAdapter.beforeEach(
94
95
  subject,
95
96
  initializer,
@@ -22,12 +22,12 @@ export const testAdapter: ITestAdapter<I> = {
22
22
  },
23
23
 
24
24
  andWhen: async (store, whenCB, testResource, pm) => {
25
- const proxiedPM = andWhenProxy(pm, "some/path");
25
+ const proxiedPM = andWhenProxy(pm, "some/path", store);
26
26
  return whenCB(store, proxiedPM);
27
27
  },
28
28
 
29
29
  butThen: async (store, thenCB, testResource, pm) => {
30
- const proxiedPM = butThenProxy(pm, "some/path");
30
+ const proxiedPM = butThenProxy(pm, "some/path", store);
31
31
  return thenCB(store, proxiedPM);
32
32
  },
33
33
 
@@ -20,11 +20,11 @@ export const implementation: ITestImplementation<I, O, M> = {
20
20
  },
21
21
  thens: {
22
22
  theButTheProxyReturns:
23
- (method: IProxiedFunctions, expectedPath: string) =>
24
- (store: { butThenProxy: IProxy }) => {
23
+ (method: string, expectedPath: string) =>
24
+ (store: { pathRewriter: PathRewriter }) => {
25
25
  const mockPm = new MockPMBase() as unknown as IPM;
26
26
  const filepath = "test/path";
27
- const proxiedPm = store.butThenProxy(mockPm, filepath);
27
+ const rewritePath = createPathRewriter(`${filepath}/butThen`);
28
28
 
29
29
  let actualPath: string;
30
30
  let actualContent: any;
@@ -8,8 +8,6 @@ export type I = Ibdd_in<
8
8
  { butThenProxy: IProxy },
9
9
  { proxies: ITestProxies; filepath: string; mockPm: IPM },
10
10
  { butThenProxy: IProxy },
11
- // { butThenProxy: IProxy },
12
-
13
11
  { proxies: ITestProxies; filepath: string; mockPm: IPM },
14
12
  [string, string],
15
13
  (