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
@@ -112,11 +112,11 @@ export class PM_Base {
112
112
  }
113
113
  return false;
114
114
  }
115
- async writeFileSync(filepath, contents, testName) {
116
- console.log("writeFileSync");
117
- console.log("filepath", filepath);
118
- console.log("contents", contents);
119
- console.log("testName", testName);
115
+ async writeFileSync(...x) {
116
+ const filepath = x[0];
117
+ const contents = x[1];
118
+ const testName = x[2];
119
+ console.log("writing file", filepath);
120
120
  return new Promise(async (res) => {
121
121
  fs.mkdirSync(path.dirname(filepath), {
122
122
  recursive: true,
@@ -3,6 +3,7 @@
3
3
  /* eslint-disable @typescript-eslint/no-explicit-any */
4
4
  /* eslint-disable @typescript-eslint/no-unused-vars */
5
5
  import { spawn } from "node:child_process";
6
+ import ansiColors from "ansi-colors";
6
7
  import net from "net";
7
8
  import fs, { watch } from "fs";
8
9
  import path from "path";
@@ -12,7 +13,6 @@ import crypto from "node:crypto";
12
13
  import { getRunnables } from "../utils";
13
14
  import { Queue } from "../utils/queue.js";
14
15
  import { PM_WithEslintAndTsc } from "./PM_WithEslintAndTsc.js";
15
- import ansiColors from "ansi-colors";
16
16
  const changes = {};
17
17
  const fileHashes = {};
18
18
  const files = {};
@@ -69,12 +69,10 @@ function isValidUrl(string) {
69
69
  }
70
70
  // Wait for file to exist, checks every 2 seconds by default
71
71
  async function pollForFile(path, timeout = 2000) {
72
- console.log(`pollForFile: ${path}...`);
73
72
  const intervalObj = setInterval(function () {
74
73
  const file = path;
75
74
  const fileExists = fs.existsSync(file);
76
75
  if (fileExists) {
77
- console.log(`metafile found: ${path}!`);
78
76
  clearInterval(intervalObj);
79
77
  }
80
78
  }, timeout);
@@ -694,16 +692,6 @@ export class PM_Main extends PM_WithEslintAndTsc {
694
692
  browserWSEndpoint: this.browser.wsEndpoint(),
695
693
  });
696
694
  const d = `${dest}?cacheBust=${Date.now()}`;
697
- const evaluation = `
698
-
699
- import('${d}').then(async (x) => {
700
-
701
- try {
702
- return await (await x.default).receiveTestResourceConfig(${webArgz})
703
- } catch (e) {
704
- console.log("web run failure", e.toString())
705
- }
706
- })`;
707
695
  const ofile = `${reportDest}/logs.txt`;
708
696
  const oStream = fs.createWriteStream(ofile);
709
697
  this.browser
@@ -742,7 +730,6 @@ export class PM_Main extends PM_WithEslintAndTsc {
742
730
  page.close();
743
731
  oStream.close();
744
732
  });
745
- console.log("ostream is closed");
746
733
  return;
747
734
  };
748
735
  page.on("pageerror", (err) => {
@@ -781,19 +768,28 @@ export class PM_Main extends PM_WithEslintAndTsc {
781
768
  });
782
769
  await page.goto(`file://${`${destFolder}.html`}`, {});
783
770
  await page
784
- .evaluate(evaluation)
771
+ .evaluate(`
772
+ import('${d}').then(async (x) => {
773
+ try {
774
+ return await (await x.default).receiveTestResourceConfig(${webArgz})
775
+ } catch (e) {
776
+ console.log("web run failure", e.toString())
777
+ }
778
+ })
779
+ `)
785
780
  .then(async ({ fails, failed, features }) => {
786
781
  statusMessagePretty(fails, src, "web");
787
782
  this.bddTestIsNowDone(src, fails);
788
- close();
783
+ // close();
789
784
  })
790
785
  .catch((e) => {
791
- console.log(ansiC.red(ansiC.inverse(e)));
786
+ console.log(ansiC.red(ansiC.inverse(e.stack)));
792
787
  console.log(ansiC.red(ansiC.inverse(`web ! ${src} failed to execute. No "tests.json" file was generated. Check ${reportDest}/logs.txt for more info`)));
793
788
  this.bddTestIsNowDone(src, -1);
794
789
  })
795
790
  .finally(() => {
796
791
  // process.exit(-1);
792
+ close();
797
793
  });
798
794
  return page;
799
795
  });
@@ -108,7 +108,10 @@ export class PM_Node extends PM {
108
108
  async write(uid, contents) {
109
109
  return await this.send("write", ...arguments);
110
110
  }
111
- async writeFileSync([filepath, contents]) {
111
+ async writeFileSync(x) {
112
+ const z = arguments["0"];
113
+ const filepath = z[0];
114
+ const contents = z[1];
112
115
  return await this.send("writeFileSync", this.testResourceConfiguration.fs + "/" + filepath, contents, this.testResourceConfiguration.name);
113
116
  }
114
117
  async createWriteStream(filepath) {
@@ -82,7 +82,10 @@ export class PM_Pure extends PM {
82
82
  write(uid, contents) {
83
83
  return globalThis["write"](uid, contents);
84
84
  }
85
- writeFileSync(filepath, contents) {
85
+ writeFileSync(x) {
86
+ const z = arguments["0"];
87
+ const filepath = z[0];
88
+ const contents = z[1];
86
89
  return globalThis["writeFileSync"](this.testResourceConfiguration.fs + "/" + filepath, contents, this.testResourceConfiguration.name);
87
90
  }
88
91
  createWriteStream(filepath) {
@@ -80,7 +80,10 @@ export class PM_Web extends PM {
80
80
  write(uid, contents) {
81
81
  return window["write"](uid, contents);
82
82
  }
83
- writeFileSync([filepath, contents]) {
83
+ writeFileSync(x) {
84
+ const z = arguments["0"];
85
+ const filepath = z[0];
86
+ const contents = z[1];
84
87
  return window["writeFileSync"](this.testResourceConfiguration.fs + "/" + filepath, contents, this.testResourceConfiguration.name);
85
88
  }
86
89
  createWriteStream(filepath) {
@@ -8,10 +8,8 @@ export class PureTesteranto extends Testeranto {
8
8
  });
9
9
  }
10
10
  async receiveTestResourceConfig(partialTestResource) {
11
- console.log("[DEBUG] receiveTestResourceConfig called with:", partialTestResource);
12
11
  const t = JSON.parse(partialTestResource);
13
12
  const pm = new PM_Pure(t);
14
- // console.log("[DEBUG] Current test jobs:", this.testJobs?.length);
15
13
  // if (!this.testJobs || this.testJobs.length === 0) {
16
14
  // console.error(
17
15
  // "[ERROR] No test jobs available - checking specs:",
@@ -27,9 +25,7 @@ export class PureTesteranto extends Testeranto {
27
25
  // };
28
26
  // }
29
27
  try {
30
- console.log("[DEBUG] Executing test job with PM:", pm);
31
28
  const result = await this.testJobs[0].receiveTestResourceConfig(pm);
32
- console.log("[DEBUG] Test job completed with result:", result);
33
29
  return result;
34
30
  }
35
31
  catch (e) {
@@ -48,7 +48,7 @@ const implementation = {
48
48
  modifySpecs: (modifier) => (store) => {
49
49
  console.debug("[DEBUG] Modifying specs");
50
50
  return Object.assign(Object.assign({}, store), { specs: modifier(store.specs || []) });
51
- }
51
+ },
52
52
  },
53
53
  thens: {
54
54
  initializedProperly: () => (store) => {
@@ -120,9 +120,15 @@ server.on("error", (err) => {
120
120
  process.on("uncaughtException", (err) => {
121
121
  console.error("Uncaught exception:", err);
122
122
  });
123
- const start = (port) => server.listen(port, () => {
124
- console.log(`Server running on http://localhost:${port}`);
125
- console.log("Serving files from:", process.cwd());
126
- });
123
+ const start = (port) => {
124
+ if (port) {
125
+ server.listen(port, () => {
126
+ console.log(`Server running on http://localhost:${port}`);
127
+ console.log("Serving files from:", process.cwd());
128
+ });
129
+ }
130
+ else {
131
+ console.log("you need to specify a port");
132
+ }
133
+ };
127
134
  export const ReportServerOfPort = (port) => start(port);
128
- // export default () => start(process.argv[2]);
@@ -4,9 +4,7 @@ import featuresPlugin from "./featuresPlugin";
4
4
  import rebuildPlugin from "./rebuildPlugin.js";
5
5
  export default (config, entryPoints, testName) => {
6
6
  const { inputFilesPluginFactory, register } = inputFilesPlugin("node", testName);
7
- return Object.assign(Object.assign({}, baseEsBuildConfig(config)), { splitting: true, outdir: `testeranto/bundles/node/${testName}/`,
8
- // inject: [`./node_modules/testeranto/dist/cjs-shim.js`],
9
- metafile: true, supported: {
7
+ return Object.assign(Object.assign({}, baseEsBuildConfig(config)), { splitting: true, outdir: `testeranto/bundles/node/${testName}/`, inject: [`./node_modules/testeranto/dist/cjs-shim.js`], metafile: true, supported: {
10
8
  "dynamic-import": true,
11
9
  }, define: {
12
10
  "process.env.FLUENTFFMPEG_COV": "0",
@@ -1,17 +1,20 @@
1
1
  import { beforeAllProxy, afterAllProxy } from "./pmProxy";
2
2
  export class BaseSuite {
3
+ addArtifact(path) {
4
+ console.log("Suite addArtifact", path);
5
+ const normalizedPath = path.replace(/\\/g, "/"); // Normalize path separators
6
+ this.artifacts.push(normalizedPath);
7
+ }
3
8
  constructor(name, index, givens = {}) {
9
+ this.artifacts = [];
4
10
  const suiteName = name || "testSuite"; // Ensure name is never undefined
5
11
  if (!suiteName) {
6
12
  throw new Error("BaseSuite requires a non-empty name");
7
13
  }
8
- console.log("[DEBUG] BaseSuite constructor - name:", suiteName, "index:", index);
9
14
  this.name = suiteName;
10
15
  this.index = index;
11
16
  this.givens = givens;
12
17
  this.fails = 0;
13
- console.log("[DEBUG] BaseSuite initialized:", this.name, this.index);
14
- console.log("[DEBUG] BaseSuite givens:", Object.keys(givens).toString());
15
18
  }
16
19
  features() {
17
20
  try {
@@ -21,11 +24,10 @@ export class BaseSuite {
21
24
  .filter((value, index, array) => {
22
25
  return array.indexOf(value) === index;
23
26
  });
24
- console.debug("[DEBUG] Features extracted:", features.toString());
25
27
  return features || [];
26
28
  }
27
29
  catch (e) {
28
- console.error("[ERROR] Failed to extract features:", e);
30
+ console.error("[ERROR] Failed to extract features:", JSON.stringify(e));
29
31
  return [];
30
32
  }
31
33
  }
@@ -53,10 +55,10 @@ export class BaseSuite {
53
55
  // tLog("test resources: ", JSON.stringify(testResourceConfiguration));
54
56
  const suiteArtifactory = (fPath, value) => artifactory(`suite-${this.index}-${this.name}/${fPath}`, value);
55
57
  // console.log("\nSuite:", this.index, this.name);
56
- tLog("\nSuite:", this.index, this.name);
58
+ // tLog("\nSuite:", this.index, this.name);
57
59
  const sNdx = this.index;
58
- // const sName = this.name;
59
- const subject = await this.setup(input, suiteArtifactory, testResourceConfiguration, beforeAllProxy(pm, sNdx.toString()));
60
+ const proxiedPm = beforeAllProxy(pm, sNdx.toString(), this);
61
+ const subject = await this.setup(input, suiteArtifactory, testResourceConfiguration, proxiedPm);
60
62
  for (const [gKey, g] of Object.entries(this.givens)) {
61
63
  const giver = this.givens[gKey];
62
64
  this.store = await giver
@@ -64,15 +66,15 @@ export class BaseSuite {
64
66
  .catch((e) => {
65
67
  this.failed = true;
66
68
  this.fails = this.fails + 1;
67
- // console.error("Given error 1:", e.toString());
68
69
  throw e;
69
70
  });
70
71
  }
71
72
  try {
72
- this.afterAll(this.store, artifactory, afterAllProxy(pm, sNdx.toString()));
73
+ const afterAllPm = afterAllProxy(pm, sNdx.toString(), this);
74
+ this.afterAll(this.store, artifactory, afterAllPm);
73
75
  }
74
76
  catch (e) {
75
- console.error(e);
77
+ console.error(JSON.stringify(e));
76
78
  // this.fails.push(this);
77
79
  // return this;
78
80
  }
@@ -3,10 +3,9 @@
3
3
  import { afterEachProxy, andWhenProxy, beforeEachProxy, butThenProxy, } from "./pmProxy.js";
4
4
  export class BaseGiven {
5
5
  addArtifact(path) {
6
- console.log(`[Artifact] Adding to ${this.constructor.name}:`, path);
7
- // console.log("mark111");
8
- // process.exit();
9
- this.artifacts.push(path);
6
+ console.log("Given addArtifact", path);
7
+ const normalizedPath = path.replace(/\\/g, "/"); // Normalize path separators
8
+ this.artifacts.push(normalizedPath);
10
9
  }
11
10
  constructor(name, features, whens, thens, givenCB, initialValues) {
12
11
  this.artifacts = [];
@@ -27,7 +26,7 @@ export class BaseGiven {
27
26
  whens: this.whens.map((w) => {
28
27
  if (w && w.toObj)
29
28
  return w.toObj();
30
- console.error("w is not as expected!", w.toString());
29
+ console.error("w is not as expected!", JSON.stringify(w));
31
30
  return {};
32
31
  }),
33
32
  thens: this.thens.map((t) => t.toObj()),
@@ -51,15 +50,13 @@ export class BaseGiven {
51
50
  tLog(e.stack);
52
51
  });
53
52
  try {
54
- const proxiedPm = beforeEachProxy(pm, suiteNdx.toString());
55
- console.log(`[Given] Setting currentStep for beforeEach:`, this.name);
56
- proxiedPm.currentStep = this;
53
+ const proxiedPm = beforeEachProxy(pm, suiteNdx.toString(), this.addArtifact.bind(this));
57
54
  this.store = await this.givenThat(subject, testResourceConfiguration, givenArtifactory, this.givenCB, this.initialValues, proxiedPm);
58
55
  }
59
56
  catch (e) {
60
- console.error("Given failure: ", e.toString());
61
- this.error = e;
62
- throw e;
57
+ // console.error("Given failure: ", e.stack);
58
+ this.error = e.stack;
59
+ // throw e;
63
60
  }
64
61
  try {
65
62
  // tLog(`\n Given this.store`, this.store);
@@ -69,9 +66,6 @@ export class BaseGiven {
69
66
  for (const [thenNdx, thenStep] of this.thens.entries()) {
70
67
  const t = await thenStep.test(this.store, testResourceConfiguration, tLog, pm, `suite-${suiteNdx}/given-${key}/then-${thenNdx}`);
71
68
  tester(t);
72
- // ((t) => {
73
- // return tester(t);
74
- // })();
75
69
  }
76
70
  }
77
71
  catch (e) {
@@ -81,10 +75,11 @@ export class BaseGiven {
81
75
  }
82
76
  finally {
83
77
  try {
84
- await this.afterEach(this.store, this.key, givenArtifactory, afterEachProxy(pm, suiteNdx.toString(), key));
78
+ const proxiedPm = afterEachProxy(pm, suiteNdx.toString(), key, this.addArtifact.bind(this));
79
+ // (proxiedPm as any).currentStep = this;
80
+ await this.afterEach(this.store, this.key, givenArtifactory, proxiedPm);
85
81
  }
86
82
  catch (e) {
87
- console.error("afterEach failed!", e.toString());
88
83
  this.failed = e;
89
84
  throw e;
90
85
  // this.error = e.message;
@@ -94,36 +89,33 @@ export class BaseGiven {
94
89
  }
95
90
  }
96
91
  export class BaseWhen {
92
+ addArtifact(path) {
93
+ console.log("When addArtifact", path);
94
+ const normalizedPath = path.replace(/\\/g, "/"); // Normalize path separators
95
+ this.artifacts.push(normalizedPath);
96
+ }
97
97
  constructor(name, whenCB) {
98
98
  this.artifacts = [];
99
99
  this.name = name;
100
100
  this.whenCB = whenCB;
101
101
  }
102
102
  toObj() {
103
- console.log("toObj error", this.error);
104
- if (this.error) {
105
- return {
106
- name: this.name,
107
- error: this.error && this.error.name + this.error.stack,
108
- artifacts: this.artifacts,
109
- };
110
- }
111
- else {
112
- return {
113
- name: this.name,
114
- artifacts: this.artifacts,
115
- };
116
- }
103
+ const obj = {
104
+ name: this.name,
105
+ error: this.error
106
+ ? `${this.error.name}: ${this.error.message}\n${this.error.stack}`
107
+ : null,
108
+ artifacts: this.artifacts || [],
109
+ };
110
+ console.log(`[TOOBJ] Serializing ${this.constructor.name} with artifacts:`, obj.artifacts);
111
+ return obj;
117
112
  }
118
113
  async test(store, testResourceConfiguration, tLog, pm, filepath) {
119
114
  try {
120
- tLog(" When:", this.name);
121
- console.debug("[DEBUG] Executing When step:", this.name.toString());
122
- const proxiedPm = andWhenProxy(pm, filepath);
123
- console.log(`[When] Setting currentStep for andWhen:`, this.name);
124
- proxiedPm.currentStep = this;
115
+ // tLog(" When:", this.name);
116
+ const proxiedPm = andWhenProxy(pm, filepath, this.addArtifact.bind(this));
117
+ // (proxiedPm as any).currentStep = this;
125
118
  const result = await this.andWhen(store, this.whenCB, testResourceConfiguration, proxiedPm);
126
- console.debug("[DEBUG] When step completed:", this.name.toString());
127
119
  return result;
128
120
  }
129
121
  catch (e) {
@@ -139,18 +131,23 @@ export class BaseThen {
139
131
  this.name = name;
140
132
  this.thenCB = thenCB;
141
133
  this.error = false;
134
+ this.artifacts = [];
135
+ }
136
+ addArtifact(path) {
137
+ console.log("Then addArtifact", path);
138
+ const normalizedPath = path.replace(/\\/g, "/"); // Normalize path separators
139
+ this.artifacts.push(normalizedPath);
142
140
  }
143
141
  toObj() {
144
- return {
142
+ const obj = {
145
143
  name: this.name,
146
144
  error: this.error,
147
145
  artifacts: this.artifacts,
148
146
  };
147
+ return obj;
149
148
  }
150
149
  async test(store, testResourceConfiguration, tLog, pm, filepath) {
151
- const proxiedPm = butThenProxy(pm, filepath);
152
- console.log(`[Then] Setting currentStep for butThen:`, this.name);
153
- proxiedPm.currentStep = this;
150
+ const proxiedPm = butThenProxy(pm, filepath, this.addArtifact.bind(this));
154
151
  return this.butThen(store, async (s) => {
155
152
  if (typeof this.thenCB === "function") {
156
153
  return await this.thenCB(s, proxiedPm);
@@ -158,8 +155,8 @@ export class BaseThen {
158
155
  else {
159
156
  return this.thenCB;
160
157
  }
161
- }, testResourceConfiguration, butThenProxy(pm, filepath)).catch((e) => {
162
- this.error = e.toString();
158
+ }, testResourceConfiguration, proxiedPm).catch((e) => {
159
+ this.error = e.stack;
163
160
  // throw e;
164
161
  });
165
162
  }
@@ -15,9 +15,11 @@ export class BaseBuilder {
15
15
  this.specs = testSpecification(this.Suites(), this.Given(), this.When(), this.Then());
16
16
  this.testJobs = this.specs.map((suite) => {
17
17
  const suiteRunner = (suite) => async (puppetMaster, tLog) => {
18
+ console.log("mark17");
18
19
  const x = await suite.run(input, puppetMaster.testResourceConfiguration, (fPath, value) => puppetMaster.testArtiFactoryfileWriter(tLog, (p) => {
19
20
  this.artifacts.push(p);
20
21
  })(puppetMaster.testResourceConfiguration.fs + "/" + fPath, value), tLog, puppetMaster);
22
+ console.log("mark18");
21
23
  return x;
22
24
  };
23
25
  const runner = suiteRunner(suite);
@@ -36,7 +38,9 @@ export class BaseBuilder {
36
38
  const tLog = async (...l) => {
37
39
  //
38
40
  };
41
+ console.log("mark14");
39
42
  const suiteDone = await runner(puppetMaster, tLog);
43
+ console.log("mark15");
40
44
  // const logPromise = new Promise(async (res) => {
41
45
  // await puppetMaster.end(access);
42
46
  // res(true);
@@ -50,6 +54,7 @@ export class BaseBuilder {
50
54
  `tests.json`,
51
55
  JSON.stringify(this.toObj(), null, 2),
52
56
  ]);
57
+ console.log("mark13");
53
58
  return {
54
59
  failed: fails > 0,
55
60
  fails,
@@ -26,6 +26,7 @@ export default class TesterantoCore extends ClassBuilder {
26
26
  this.uberCatcher = uberCatcher;
27
27
  }
28
28
  async givenThat(subject, testResource, artifactory, initializer, initialValues, pm) {
29
+ console.log("mark800");
29
30
  return fullAdapter.beforeEach(subject, initializer, testResource, initialValues, pm);
30
31
  }
31
32
  afterEach(store, key, artifactory, pm) {