testeranto 0.90.0 → 0.100.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 (133) hide show
  1. package/bundle.js +4 -7
  2. package/dist/common/src/Node.js +5 -3
  3. package/dist/common/src/PM/main.js +254 -126
  4. package/dist/common/src/PM/node.js +20 -5
  5. package/dist/common/src/PM/web.js +19 -4
  6. package/dist/common/src/SubPackages/puppeteer.js +1 -1
  7. package/dist/common/src/SubPackages/react/jsx/index.js +14 -6
  8. package/dist/common/src/SubPackages/react/jsx/node.js +2 -2
  9. package/dist/common/src/SubPackages/react-dom/component/web.js +13 -39
  10. package/dist/common/src/SubPackages/react-test-renderer/component/interface.js +2 -10
  11. package/dist/common/src/Web.js +25 -21
  12. package/dist/common/src/cli.js +439 -0
  13. package/dist/common/src/cli2.js +144 -0
  14. package/dist/common/src/esbuildConfigs/inputFilesPlugin.js +18 -8
  15. package/dist/common/src/esbuildConfigs/node.js +1 -4
  16. package/dist/common/src/esbuildConfigs/web.js +1 -1
  17. package/dist/common/src/lib/abstractBase.js +31 -263
  18. package/dist/common/src/lib/basebuilder.js +1 -11
  19. package/dist/common/src/lib/classBuilder.js +1 -1
  20. package/dist/common/src/lib/core.js +8 -28
  21. package/dist/common/src/lib/types.js +1 -0
  22. package/dist/common/tsconfig.common.tsbuildinfo +1 -1
  23. package/dist/module/src/Node.js +5 -3
  24. package/dist/module/src/PM/main.js +254 -126
  25. package/dist/module/src/PM/node.js +20 -5
  26. package/dist/module/src/PM/web.js +19 -4
  27. package/dist/module/src/SubPackages/puppeteer.js +1 -1
  28. package/dist/module/src/SubPackages/react/jsx/index.js +14 -6
  29. package/dist/module/src/SubPackages/react/jsx/node.js +2 -2
  30. package/dist/module/src/SubPackages/react-dom/component/web.js +13 -39
  31. package/dist/module/src/SubPackages/react-test-renderer/component/interface.js +2 -10
  32. package/dist/module/src/Web.js +25 -21
  33. package/dist/module/src/cli.js +411 -0
  34. package/dist/module/src/cli2.js +116 -0
  35. package/dist/module/src/esbuildConfigs/inputFilesPlugin.js +18 -8
  36. package/dist/module/src/esbuildConfigs/node.js +1 -4
  37. package/dist/module/src/esbuildConfigs/web.js +1 -1
  38. package/dist/module/src/lib/abstractBase.js +31 -263
  39. package/dist/module/src/lib/basebuilder.js +1 -11
  40. package/dist/module/src/lib/classBuilder.js +1 -1
  41. package/dist/module/src/lib/core.js +8 -28
  42. package/dist/module/src/lib/types.js +1 -0
  43. package/dist/module/tsconfig.module.tsbuildinfo +1 -1
  44. package/dist/prebuild/cli.mjs +1491 -0
  45. package/dist/prebuild/{run-tests.mjs → cli2.mjs} +223 -212
  46. package/dist/types/src/Node.d.ts +6 -3
  47. package/dist/types/src/PM/index.d.ts +10 -2
  48. package/dist/types/src/PM/main.d.ts +14 -7
  49. package/dist/types/src/PM/node.d.ts +9 -2
  50. package/dist/types/src/PM/web.d.ts +9 -3
  51. package/dist/types/src/SubPackages/puppeteer.d.ts +1 -1
  52. package/dist/types/src/SubPackages/react/component/node.d.ts +1 -1
  53. package/dist/types/src/SubPackages/react/component/web.d.ts +1 -1
  54. package/dist/types/src/SubPackages/react/jsx/node.d.ts +3 -3
  55. package/dist/types/src/SubPackages/react/jsx/web.d.ts +2 -2
  56. package/dist/types/src/SubPackages/react-dom/component/node.d.ts +2 -2
  57. package/dist/types/src/SubPackages/react-dom/component/web.d.ts +1 -1
  58. package/dist/types/src/SubPackages/react-dom/jsx/node.d.ts +1 -1
  59. package/dist/types/src/SubPackages/react-dom/jsx/web.d.ts +2 -2
  60. package/dist/types/src/SubPackages/react-test-renderer/MemoExoticComponent/node.d.ts +2 -2
  61. package/dist/types/src/SubPackages/react-test-renderer/component/interface.d.ts +1 -1
  62. package/dist/types/src/SubPackages/react-test-renderer/component/node.d.ts +2 -2
  63. package/dist/types/src/SubPackages/react-test-renderer/component/web.d.ts +2 -2
  64. package/dist/types/src/SubPackages/react-test-renderer/fc/node.d.ts +2 -2
  65. package/dist/types/src/SubPackages/react-test-renderer/fc/web.d.ts +2 -2
  66. package/dist/types/src/SubPackages/react-test-renderer/jsx/node.d.ts +3 -2
  67. package/dist/types/src/SubPackages/react-test-renderer/jsx/web.d.ts +2 -2
  68. package/dist/types/src/SubPackages/react-test-renderer/jsx-promised/node.d.ts +2 -2
  69. package/dist/types/src/SubPackages/react-test-renderer/jsx-promised/web.d.ts +2 -2
  70. package/dist/types/src/Types.d.ts +60 -21
  71. package/dist/types/src/Web.d.ts +3 -3
  72. package/dist/types/src/lib/abstractBase.d.ts +6 -2
  73. package/dist/types/src/lib/core.d.ts +3 -3
  74. package/dist/types/src/lib/index.d.ts +1 -1
  75. package/dist/types/src/lib/types.d.ts +6 -30
  76. package/dist/types/tsconfig.types.tsbuildinfo +1 -1
  77. package/package.json +23 -20
  78. package/src/Node.ts +6 -3
  79. package/src/PM/index.ts +12 -8
  80. package/src/PM/main.ts +331 -165
  81. package/src/PM/node.ts +42 -7
  82. package/src/PM/web.ts +33 -5
  83. package/src/SubPackages/puppeteer.ts +1 -1
  84. package/src/SubPackages/react/jsx/index.ts +15 -7
  85. package/src/SubPackages/react/jsx/node.ts +18 -6
  86. package/src/SubPackages/react-dom/component/web.ts +28 -51
  87. package/src/SubPackages/react-test-renderer/component/interface.ts +4 -11
  88. package/src/SubPackages/react-test-renderer/jsx/node.ts +16 -1
  89. package/src/Types.ts +362 -114
  90. package/src/Web.ts +45 -23
  91. package/src/cli.ts +535 -0
  92. package/src/cli2.ts +157 -0
  93. package/src/esbuildConfigs/inputFilesPlugin.ts +27 -9
  94. package/src/esbuildConfigs/node.ts +4 -7
  95. package/src/esbuildConfigs/web.ts +4 -3
  96. package/src/lib/abstractBase.ts +84 -291
  97. package/src/lib/basebuilder.ts +1 -12
  98. package/src/lib/classBuilder.ts +2 -1
  99. package/src/lib/core.ts +17 -29
  100. package/src/lib/types.ts +5 -177
  101. package/dist/common/src/Aider.js +0 -143
  102. package/dist/common/src/Project.js +0 -225
  103. package/dist/common/src/Puppeteer.js +0 -113
  104. package/dist/common/src/build-tests.js +0 -39
  105. package/dist/common/src/esbuildConfigs/features.js +0 -14
  106. package/dist/common/src/esbuildConfigs/report.js +0 -14
  107. package/dist/common/src/esbuildConfigs/tests.js +0 -13
  108. package/dist/common/src/run-tests.js +0 -39
  109. package/dist/module/src/Aider.js +0 -136
  110. package/dist/module/src/Project.js +0 -218
  111. package/dist/module/src/Puppeteer.js +0 -108
  112. package/dist/module/src/build-tests.js +0 -11
  113. package/dist/module/src/esbuildConfigs/features.js +0 -12
  114. package/dist/module/src/esbuildConfigs/report.js +0 -14
  115. package/dist/module/src/esbuildConfigs/tests.js +0 -11
  116. package/dist/module/src/run-tests.js +0 -11
  117. package/dist/prebuild/build-tests.mjs +0 -552
  118. package/dist/types/src/Aider.d.ts +0 -1
  119. package/dist/types/src/Project.d.ts +0 -12
  120. package/dist/types/src/Puppeteer.d.ts +0 -2
  121. package/dist/types/src/esbuildConfigs/features.d.ts +0 -4
  122. package/dist/types/src/esbuildConfigs/report.d.ts +0 -0
  123. package/dist/types/src/esbuildConfigs/tests.d.ts +0 -4
  124. package/src/Aider.ts +0 -168
  125. package/src/Project.ts +0 -291
  126. package/src/Puppeteer.ts +0 -145
  127. package/src/build-tests.ts +0 -12
  128. package/src/esbuildConfigs/features.ts +0 -17
  129. package/src/esbuildConfigs/report.ts +0 -15
  130. package/src/esbuildConfigs/tests.ts +0 -14
  131. package/src/run-tests.ts +0 -12
  132. /package/dist/types/src/{build-tests.d.ts → cli.d.ts} +0 -0
  133. /package/dist/types/src/{run-tests.d.ts → cli2.d.ts} +0 -0
@@ -0,0 +1,116 @@
1
+ import { watch } from "fs";
2
+ import { PM_Main } from "./PM/main";
3
+ import path from "path";
4
+ import crypto from "node:crypto";
5
+ import fs from "fs";
6
+ const fileHashes = {};
7
+ async function fileHash(filePath, algorithm = "md5") {
8
+ return new Promise((resolve, reject) => {
9
+ const hash = crypto.createHash(algorithm);
10
+ const fileStream = fs.createReadStream(filePath);
11
+ fileStream.on("data", (data) => {
12
+ hash.update(data);
13
+ });
14
+ fileStream.on("end", () => {
15
+ const fileHash = hash.digest("hex");
16
+ resolve(fileHash);
17
+ });
18
+ fileStream.on("error", (error) => {
19
+ reject(`Error reading file: ${error.message}`);
20
+ });
21
+ });
22
+ }
23
+ const getRunnables = (tests, payload = {
24
+ nodeEntryPoints: {},
25
+ webEntryPoints: {},
26
+ }) => {
27
+ return tests.reduce((pt, cv, cndx, cry) => {
28
+ if (cv[1] === "node") {
29
+ pt.nodeEntryPoints[cv[0]] = path.resolve(`./docs/node/${cv[0].split(".").slice(0, -1).concat("mjs").join(".")}`);
30
+ }
31
+ else if (cv[1] === "web") {
32
+ pt.webEntryPoints[cv[0]] = path.resolve(`./docs/web/${cv[0].split(".").slice(0, -1).concat("mjs").join(".")}`);
33
+ }
34
+ if (cv[3].length) {
35
+ getRunnables(cv[3], payload);
36
+ }
37
+ return pt;
38
+ }, payload);
39
+ };
40
+ import(process.cwd() + "/" + process.argv[2]).then(async (module) => {
41
+ const rawConfig = module.default;
42
+ const config = Object.assign(Object.assign({}, rawConfig), { buildDir: process.cwd() + "/" + rawConfig.outdir });
43
+ let pm = new PM_Main(config);
44
+ await pm.startPuppeteer({
45
+ slowMo: 1,
46
+ // timeout: 1,
47
+ waitForInitialPage: false,
48
+ executablePath:
49
+ // process.env.CHROMIUM_PATH || "/opt/homebrew/bin/chromium",
50
+ "/opt/homebrew/bin/chromium",
51
+ headless: true,
52
+ dumpio: true,
53
+ // timeout: 0,
54
+ devtools: true,
55
+ args: [
56
+ "--auto-open-devtools-for-tabs",
57
+ `--remote-debugging-port=3234`,
58
+ // "--disable-features=IsolateOrigins,site-per-process",
59
+ "--disable-site-isolation-trials",
60
+ "--allow-insecure-localhost",
61
+ "--allow-file-access-from-files",
62
+ "--allow-running-insecure-content",
63
+ "--disable-dev-shm-usage",
64
+ "--disable-extensions",
65
+ "--disable-gpu",
66
+ "--disable-setuid-sandbox",
67
+ "--disable-site-isolation-trials",
68
+ "--disable-web-security",
69
+ "--no-first-run",
70
+ "--no-sandbox",
71
+ "--no-startup-window",
72
+ // "--no-zygote",
73
+ "--reduce-security-for-testing",
74
+ "--remote-allow-origins=*",
75
+ "--unsafely-treat-insecure-origin-as-secure=*",
76
+ // "--disable-features=IsolateOrigins",
77
+ // "--remote-allow-origins=ws://localhost:3234",
78
+ // "--single-process",
79
+ // "--unsafely-treat-insecure-origin-as-secure",
80
+ // "--unsafely-treat-insecure-origin-as-secure=ws://192.168.0.101:3234",
81
+ // "--disk-cache-dir=/dev/null",
82
+ // "--disk-cache-size=1",
83
+ // "--start-maximized",
84
+ ],
85
+ }, ".");
86
+ const { nodeEntryPoints, webEntryPoints } = getRunnables(config.tests);
87
+ Object.entries(nodeEntryPoints).forEach(([k, outputFile]) => {
88
+ console.log("watching and running", outputFile);
89
+ pm.launchNode(k, outputFile);
90
+ try {
91
+ watch(outputFile, async (e, filename) => {
92
+ const hash = await fileHash(outputFile);
93
+ if (fileHashes[k] !== hash) {
94
+ fileHashes[k] = hash;
95
+ console.log(`< ${e} ${filename} ${hash}`);
96
+ pm.launchNode(k, outputFile);
97
+ }
98
+ });
99
+ }
100
+ catch (e) {
101
+ console.error(e);
102
+ }
103
+ });
104
+ Object.entries(webEntryPoints).forEach(([k, outputFile]) => {
105
+ console.log("watching and running", outputFile);
106
+ pm.launchWeb(k, outputFile);
107
+ watch(outputFile, async (e, filename) => {
108
+ const hash = await fileHash(outputFile);
109
+ console.log(`< ${e} ${filename} ${hash}`);
110
+ if (fileHashes[k] !== hash) {
111
+ fileHashes[k] = hash;
112
+ pm.launchWeb(k, outputFile);
113
+ }
114
+ });
115
+ });
116
+ });
@@ -1,15 +1,14 @@
1
1
  import fs from "fs";
2
2
  import path from "path";
3
+ import { spawn } from "child_process";
3
4
  const otherInputs = {};
4
5
  const register = (entrypoint, sources) => {
5
- console.log("register", entrypoint, sources);
6
6
  if (!otherInputs[entrypoint]) {
7
7
  otherInputs[entrypoint] = new Set();
8
8
  }
9
9
  sources.forEach((s) => otherInputs[entrypoint].add(s));
10
10
  };
11
11
  function tree(meta, key) {
12
- console.log("searching metafile for", key);
13
12
  const outputKey = Object.keys(meta.outputs).find((k) => {
14
13
  return meta.outputs[k].entryPoint === key;
15
14
  });
@@ -49,6 +48,7 @@ export default (platform, entryPoints) => {
49
48
  })
50
49
  .flat();
51
50
  const typeErrorFiles = addableFiles.map((t) => `docs/types/${t}.type_errors.txt`);
51
+ const lintPath = path.join("./docs/", platform, entryPoint.split(".").slice(0, -1).join("."), `lint_errors.txt`);
52
52
  fs.writeFileSync(promptPath, `
53
53
  ${addableFiles
54
54
  .map((x) => {
@@ -58,22 +58,32 @@ ${addableFiles
58
58
 
59
59
  ${typeErrorFiles
60
60
  .map((x) => {
61
- // const f = `docs/types/${x}.type_errors.txt`;
62
61
  return `/read ${x}`;
63
- // if (fs.existsSync(f)) {
64
- // return `/read ${f}`;
65
- // }
66
62
  })
67
63
  .join("\n")}
68
-
64
+
65
+ /read ${lintPath}
69
66
  /read ${testPaths}
70
67
  /read ${stdoutPath}
71
68
  /read ${stderrPath}
72
69
 
73
70
  /load ${featuresPath}
74
71
 
75
- /code Fix the failing tests described in ${testPaths}. Correct any type signature errors described in the files [${typeErrorFiles.join(", ")}]. Implement any method which throws "Function not implemented."
72
+ /code Fix the failing tests described in ${testPaths}. Correct any type signature errors described in the files [${typeErrorFiles.join(", ")}]. Implement any method which throws "Function not implemented. Resolve the lint errors described in ${lintPath}"
76
73
  `);
74
+ const logContent = [];
75
+ const tsc = spawn("eslint", addableFiles);
76
+ tsc.stdout.on("data", (data) => {
77
+ const lines = data.toString().split("\n");
78
+ logContent.push(...lines);
79
+ });
80
+ tsc.stderr.on("data", (data) => {
81
+ console.error(`stderr: ${data}`);
82
+ process.exit(-1);
83
+ });
84
+ tsc.on("close", (code) => {
85
+ fs.writeFileSync(lintPath, logContent.join("\n"));
86
+ });
77
87
  }
78
88
  });
79
89
  }
@@ -3,8 +3,6 @@ import inputFilesPlugin from "./inputFilesPlugin.js";
3
3
  import featuresPlugin from "./featuresPlugin";
4
4
  export default (config, entryPoints) => {
5
5
  const { inputFilesPluginFactory, register } = inputFilesPlugin("node", entryPoints);
6
- // const inputFilesPluginFactory = inputFilesPlugin("node", entryPoints);
7
- // const register = (x) => x;
8
6
  return Object.assign(Object.assign({}, baseEsBuildConfig(config)), { splitting: true, outdir: config.outdir + "/node",
9
7
  // inject: [`./node_modules/testeranto/dist/cjs-shim.js`],
10
8
  metafile: true, supported: {
@@ -22,7 +20,6 @@ export default (config, entryPoints) => {
22
20
  ...config.externals,
23
21
  ], entryPoints: [...entryPoints], plugins: [
24
22
  featuresPlugin,
25
- // markdownPlugin({}),
26
23
  ...(config.nodePlugins.map((p) => p(register, entryPoints)) || []),
27
24
  inputFilesPluginFactory,
28
25
  // inputFilesPlugin("node", entryPoints),
@@ -30,7 +27,7 @@ export default (config, entryPoints) => {
30
27
  name: "rebuild-notify",
31
28
  setup(build) {
32
29
  build.onEnd((result) => {
33
- console.log(`node build ended with ${result.errors.length} errors`);
30
+ console.log(`> node build ended with ${result.errors.length} errors`);
34
31
  if (result.errors.length > 0) {
35
32
  console.log(result);
36
33
  }
@@ -43,7 +43,7 @@ export default (config, entryPoints) => {
43
43
  name: "rebuild-notify",
44
44
  setup(build) {
45
45
  build.onEnd((result) => {
46
- console.log(`web build ended with ${result.errors.length} errors`);
46
+ console.log(`> web build ended with ${result.errors.length} errors`);
47
47
  if (result.errors.length > 0) {
48
48
  console.log(result);
49
49
  }
@@ -41,80 +41,29 @@ export class BaseSuite {
41
41
  this.testResourceConfiguration = testResourceConfiguration;
42
42
  tLog("test resources: ", JSON.stringify(testResourceConfiguration));
43
43
  const suiteArtifactory = (fPath, value) => artifactory(`suite-${this.index}-${this.name}/${fPath}`, value);
44
- console.log("\nSuite:", this.index, this.name);
44
+ // console.log("\nSuite:", this.index, this.name);
45
45
  tLog("\nSuite:", this.index, this.name);
46
46
  const sNdx = this.index;
47
47
  const sName = this.name;
48
- for (const [gNdx, g] of Object.entries(this.givens)) {
48
+ for (const [gKey, g] of Object.entries(this.givens)) {
49
+ // console.log("gKey", gKey);
49
50
  const beforeAllProxy = new Proxy(pm, {
50
51
  get(target, prop, receiver) {
51
52
  if (prop === "customScreenShot") {
52
- return (opts) => target.customScreenShot(Object.assign(Object.assign({}, opts), {
53
+ return (opts, p) => target.customScreenShot(Object.assign(Object.assign({}, opts), {
53
54
  // path: `${filepath}/${opts.path}`,
54
- path: `suite-${sNdx}/beforeAll/${opts.path}` }));
55
+ path: `suite-${sNdx}/beforeAll/${opts.path}` }), p);
55
56
  }
56
57
  if (prop === "writeFileSync") {
57
58
  return (fp, contents) => target[prop](`suite-${sNdx}/beforeAll/${fp}`, contents);
58
59
  }
59
- // if (prop === "browser") {
60
- // return new Proxy(target[prop], {
61
- // get(bTarget, bProp, bReceiver) {
62
- // if (bProp === "pages") {
63
- // return async () => {
64
- // return bTarget.pages().then((pages) => {
65
- // return pages.map((page) => {
66
- // return new Proxy(page, {
67
- // get(pTarget, pProp, pReciever) {
68
- // if (pProp === "screenshot") {
69
- // return async (x) => {
70
- // return pm.customScreenShot(
71
- // {
72
- // ...x,
73
- // path:
74
- // `${testResourceConfiguration.fs}/suite-${sNdx}/beforeAll` +
75
- // "/" +
76
- // x.path,
77
- // },
78
- // page
79
- // );
80
- // // return await window["custom-screenshot"]({
81
- // // ...x,
82
- // // path:
83
- // // `${testResourceConfiguration.fs}/suite-${sNdx}/afterAll` +
84
- // // "/" +
85
- // // x.path,
86
- // // });
87
- // };
88
- // } else if (pProp === "mainFrame") {
89
- // return () => pTarget[pProp]();
90
- // } else if (pProp === "close") {
91
- // return () => pTarget[pProp]();
92
- // }
93
- // // else if (pProp === "mainFrame") {
94
- // // return () => target[pProp](...arguments);
95
- // // }
96
- // else {
97
- // return Reflect.get(...arguments);
98
- // }
99
- // },
100
- // });
101
- // });
102
- // });
103
- // // return (await target.pages()).map((page) => {
104
- // // return new Proxy(page, handler2);
105
- // // });
106
- // };
107
- // }
108
- // },
109
- // });
110
- // }
111
60
  return Reflect.get(...arguments);
112
61
  },
113
62
  });
114
63
  const subject = await this.setup(input, suiteArtifactory, testResourceConfiguration, beforeAllProxy);
115
- const giver = this.givens[gNdx];
64
+ const giver = this.givens[gKey];
116
65
  try {
117
- this.store = await giver.give(subject, gNdx, testResourceConfiguration, this.assertThat, suiteArtifactory, tLog, pm, sNdx);
66
+ this.store = await giver.give(subject, gKey, testResourceConfiguration, this.assertThat, suiteArtifactory, tLog, pm, sNdx);
118
67
  }
119
68
  catch (e) {
120
69
  console.error(e);
@@ -122,64 +71,6 @@ export class BaseSuite {
122
71
  // return this;
123
72
  }
124
73
  }
125
- // const afterAllProxy = new Proxy(pm, {
126
- // get(target, prop, receiver) {
127
- // if (prop === "writeFileSync") {
128
- // return (fp, contents) =>
129
- // target[prop](`suite-${sNdx}/afterAll/${fp}`, contents);
130
- // }
131
- // if (prop === "browser") {
132
- // return new Proxy(target[prop], {
133
- // get(bTarget, bProp, bReceiver) {
134
- // if (bProp === "pages") {
135
- // return async () => {
136
- // return bTarget.pages().then((pages) => {
137
- // return pages.map((page) => {
138
- // return new Proxy(page, {
139
- // get(pTarget, pProp, pReciever) {
140
- // if (pProp === "screenshot") {
141
- // return async (x) => {
142
- // return pm.customScreenShot({
143
- // ...x,
144
- // path:
145
- // `${testResourceConfiguration.fs}/suite-${sNdx}/afterAll` +
146
- // "/" +
147
- // x.path,
148
- // });
149
- // // return await window["custom-screenshot"]({
150
- // // ...x,
151
- // // path:
152
- // // `${testResourceConfiguration.fs}/suite-${sNdx}/afterAll` +
153
- // // "/" +
154
- // // x.path,
155
- // // });
156
- // };
157
- // } else if (pProp === "mainFrame") {
158
- // return () => pTarget[pProp]();
159
- // } else if (pProp === "close") {
160
- // return () => pTarget[pProp]();
161
- // }
162
- // // else if (pProp === "mainFrame") {
163
- // // return () => target[pProp](...arguments);
164
- // // }
165
- // else {
166
- // return Reflect.get(...arguments);
167
- // }
168
- // },
169
- // });
170
- // });
171
- // });
172
- // // return (await target.pages()).map((page) => {
173
- // // return new Proxy(page, handler2);
174
- // // });
175
- // };
176
- // }
177
- // },
178
- // });
179
- // }
180
- // return Reflect.get(...arguments);
181
- // },
182
- // });
183
74
  try {
184
75
  this.afterAll(this.store, artifactory,
185
76
  // afterAllProxy
@@ -217,7 +108,9 @@ export class BaseSuite {
217
108
  }
218
109
  }
219
110
  export class BaseGiven {
220
- constructor(name, features, whens, thens, givenCB, initialValues) {
111
+ constructor(name, features, whens, thens, givenCB, initialValues
112
+ // key: string
113
+ ) {
221
114
  this.name = name;
222
115
  this.features = features;
223
116
  this.whens = whens;
@@ -225,11 +118,15 @@ export class BaseGiven {
225
118
  this.givenCB = givenCB;
226
119
  this.initialValues = initialValues;
227
120
  }
228
- beforeAll(store, artifactory) {
121
+ beforeAll(store,
122
+ // artifactory: ITestArtifactory
123
+ // subject,
124
+ initializer, artifactory, testResource, initialValues, pm) {
229
125
  return store;
230
126
  }
231
127
  toObj() {
232
128
  return {
129
+ key: this.key,
233
130
  name: this.name,
234
131
  whens: this.whens.map((w) => w.toObj()),
235
132
  thens: this.thens.map((t) => t.toObj()),
@@ -242,6 +139,8 @@ export class BaseGiven {
242
139
  return store;
243
140
  }
244
141
  async give(subject, key, testResourceConfiguration, tester, artifactory, tLog, pm, suiteNdx) {
142
+ this.key = key;
143
+ tLog(`\n ${this.key}`);
245
144
  tLog(`\n Given: ${this.name}`);
246
145
  const givenArtifactory = (fPath, value) => artifactory(`given-${key}/${fPath}`, value);
247
146
  try {
@@ -252,15 +151,20 @@ export class BaseGiven {
252
151
  return (fp, contents) => target[prop](`suite-${suiteNdx}/given-${key}/when/beforeEach/${fp}`, contents);
253
152
  }
254
153
  if (prop === "customScreenShot") {
255
- return (opts) => target.customScreenShot(Object.assign(Object.assign({}, opts), {
256
- // path: `${filepath}/${opts.path}`,
257
- path: `suite-${suiteNdx}/given-${key}/when/beforeEach/${opts.path}` }));
154
+ return (opts, p) => target.customScreenShot(Object.assign(Object.assign({}, opts), { path: `suite-${suiteNdx}/given-${key}/when/beforeEach/${opts.path}` }), p);
155
+ }
156
+ if (prop === "screencast") {
157
+ return (opts, p) => target.screencast(Object.assign(Object.assign({}, opts), { path: `suite-${suiteNdx}/given-${key}/when/beforeEach/${opts.path}` }), p);
258
158
  }
259
159
  return Reflect.get(...arguments);
260
160
  },
261
161
  });
262
- this.store = await this.givenThat(subject, testResourceConfiguration, givenArtifactory, this.givenCB, beforeEachProxy);
263
- // console.log("mark6", this.store);
162
+ this.uberCatcher((e) => {
163
+ console.error(e);
164
+ this.error = e.error;
165
+ tLog(e.stack);
166
+ });
167
+ this.store = await this.givenThat(subject, testResourceConfiguration, givenArtifactory, this.givenCB, this.initialValues, beforeEachProxy);
264
168
  for (const [whenNdx, whenStep] of this.whens.entries()) {
265
169
  await whenStep.test(this.store, testResourceConfiguration, tLog, pm, `suite-${suiteNdx}/given-${key}/when/${whenNdx}`);
266
170
  }
@@ -281,7 +185,7 @@ export class BaseGiven {
281
185
  const afterEachProxy = new Proxy(pm, {
282
186
  get(target, prop, receiver) {
283
187
  if (prop === "customScreenShot") {
284
- return (opts) => target.customScreenShot(Object.assign(Object.assign({}, opts), { path: `suite-${suiteNdx}/given-${key}/afterEach/${opts.path}` }));
188
+ return (opts, p) => target.customScreenShot(Object.assign(Object.assign({}, opts), { path: `suite-${suiteNdx}/given-${key}/afterEach/${opts.path}` }), p);
285
189
  }
286
190
  if (prop === "writeFileSync") {
287
191
  return (fp, contents) => target[prop](`suite-${suiteNdx}/given-${key}/afterEach/${fp}`, contents);
@@ -289,7 +193,7 @@ export class BaseGiven {
289
193
  return Reflect.get(...arguments);
290
194
  },
291
195
  });
292
- await this.afterEach(this.store, key, givenArtifactory,
196
+ await this.afterEach(this.store, this.key, givenArtifactory,
293
197
  // pm
294
198
  afterEachProxy);
295
199
  }
@@ -317,91 +221,11 @@ export class BaseWhen {
317
221
  const andWhenProxy = new Proxy(pm, {
318
222
  get(target, prop, receiver) {
319
223
  if (prop === "customScreenShot") {
320
- return (opts) => target.customScreenShot(Object.assign(Object.assign({}, opts), { path: `${filepath}/${opts.path}` }));
224
+ return (opts, p) => target.customScreenShot(Object.assign(Object.assign({}, opts), { path: `${filepath}/${opts.path}` }), p);
321
225
  }
322
226
  if (prop === "writeFileSync") {
323
227
  return (fp, contents) => target[prop](`${filepath}/andWhen/${fp}`, contents);
324
228
  }
325
- /////////////////////
326
- // if (prop === "browser") {
327
- // return new Proxy(target[prop], {
328
- // get(bTarget, bProp, bReceiver) {
329
- // if (bProp === "pages") {
330
- // return async () => {
331
- // return bTarget.pages().then((pages) => {
332
- // return pages.map((page) => {
333
- // return new Proxy(page, {
334
- // get(pTarget, pProp, pReciever) {
335
- // // console.log("mark get", pTarget, pProp, pReciever);
336
- // if (pProp === "screenshot") {
337
- // return async (x) => {
338
- // return pm.customScreenShot(
339
- // {
340
- // ...x,
341
- // path:
342
- // `${testResourceConfiguration.fs}/${key}/afterEach` +
343
- // "/" +
344
- // x.path,
345
- // },
346
- // page
347
- // );
348
- // };
349
- // } else if (pProp === "mainFrame") {
350
- // return () => pTarget[pProp]();
351
- // // return target[pProp];
352
- // // return Reflect.get(...arguments);
353
- // } else if (pProp === "exposeFunction") {
354
- // // return Reflect.get(target, prop, receiver);
355
- // return pTarget[pProp].bind(pTarget);
356
- // // return target[pProp];
357
- // } else if (pProp === "removeExposedFunction") {
358
- // // return Reflect.get(target, prop, receiver);
359
- // return pTarget[pProp].bind(pTarget);
360
- // // return target[pProp];
361
- // } else if (pProp === "click") {
362
- // // console.log("mark12", arguments);
363
- // // return Reflect.get(target, prop, receiver);
364
- // // return pTarget[pProp].bind(pTarget);
365
- // // return target[pProp];
366
- // return (selector, options) => {
367
- // pTarget[pProp](selector, options);
368
- // };
369
- // } else if (pProp === "$eval") {
370
- // // return pTarget[pProp].bind(pTarget);
371
- // return (selector, options) => {
372
- // pTarget[pProp](selector, options);
373
- // };
374
- // } else if (pProp === "$") {
375
- // return Reflect.get(...arguments);
376
- // // return Reflect.get(target, prop, receiver);
377
- // // return pTarget[pProp].bind(pTarget);
378
- // // return target[pProp];
379
- // // return pTarget[pProp].bind(pTarget);
380
- // // return async (s) => {
381
- // // console.log("mark17", s);
382
- // // console.log("pTarget", pTarget);
383
- // // console.log("pProp", pProp);
384
- // // console.log("pReciever", pReciever);
385
- // // // return "XXX";
386
- // // // debugger;
387
- // // return await pTarget[pProp](s);
388
- // // };
389
- // } else {
390
- // return Reflect.get(...arguments);
391
- // }
392
- // },
393
- // });
394
- // });
395
- // });
396
- // // return (await target.pages()).map((page) => {
397
- // // return new Proxy(page, handler2);
398
- // // });
399
- // };
400
- // }
401
- // },
402
- // });
403
- // }
404
- ///////////////////////
405
229
  return Reflect.get(...arguments);
406
230
  },
407
231
  });
@@ -440,67 +264,11 @@ export class BaseThen {
440
264
  const butThenProxy = new Proxy(pm, {
441
265
  get(target, prop, receiver) {
442
266
  if (prop === "customScreenShot") {
443
- return (opts) => target.customScreenShot(Object.assign(Object.assign({}, opts), { path: `${filepath}/${opts.path}` }));
267
+ return (opts, p) => target.customScreenShot(Object.assign(Object.assign({}, opts), { path: `${filepath}/${opts.path}` }), p);
444
268
  }
445
269
  if (prop === "writeFileSync") {
446
270
  return (fp, contents) => target[prop](`${filepath}/${fp}`, contents);
447
271
  }
448
- // if (prop === "browser") {
449
- // return new Proxy(target[prop], {
450
- // get(bTarget, bProp, bReceiver) {
451
- // if (bProp === "pages") {
452
- // return async () => {
453
- // return bTarget.pages().then((pages) => {
454
- // return pages.map((page) => {
455
- // return new Proxy(page, {
456
- // get(pTarget, pProp, pReciever) {
457
- // if (pProp === "screenshot") {
458
- // return async (x) => {
459
- // return pm.customScreenShot(
460
- // {
461
- // ...x,
462
- // path:
463
- // `${testResourceConfiguration.fs}/${filepath}/butThen` +
464
- // "/" +
465
- // x.path,
466
- // },
467
- // page
468
- // );
469
- // // return await window["custom-screenshot"]({
470
- // // ...x,
471
- // // path:
472
- // // `${testResourceConfiguration.fs}/suite-${sNdx}/afterAll` +
473
- // // "/" +
474
- // // x.path,
475
- // // });
476
- // };
477
- // } else if (pProp === "close") {
478
- // return () => pTarget[pProp]();
479
- // } else if (pProp === "mainFrame") {
480
- // return () => pTarget[pProp]();
481
- // } else if (pProp === "exposeFunction") {
482
- // // return Reflect.get(target, prop, receiver);
483
- // return (...a) => pTarget[pProp](...a);
484
- // // return target[pProp];
485
- // } else if (pProp === "removeExposedFunction") {
486
- // // return Reflect.get(target, prop, receiver);
487
- // return pTarget[pProp].bind(pTarget);
488
- // // return target[pProp];
489
- // } else {
490
- // return Reflect.get(...arguments);
491
- // }
492
- // },
493
- // });
494
- // });
495
- // });
496
- // // return (await target.pages()).map((page) => {
497
- // // return new Proxy(page, handler2);
498
- // // });
499
- // };
500
- // }
501
- // },
502
- // });
503
- // }
504
272
  return Reflect.get(...arguments);
505
273
  },
506
274
  });
@@ -11,21 +11,11 @@ export class BaseBuilder {
11
11
  this.checkOverides = checkOverides;
12
12
  this.testSpecification = testSpecification;
13
13
  this.specs = testSpecification(this.Suites(), this.Given(), this.When(), this.Then(), this.Check());
14
- // const f = this.specs[0].features;
15
14
  this.testJobs = this.specs.map((suite) => {
16
15
  const suiteRunner = (suite) => async (puppetMaster, tLog) => {
17
- // const puppeteerBrowser = await puppetMaster.startPuppeteer(
18
- // {
19
- // browserWSEndpoint:
20
- // puppetMaster.testResourceConfiguration.browserWSEndpoint,
21
- // },
22
- // puppetMaster.testResourceConfiguration.fs
23
- // );
24
16
  const x = await suite.run(input, puppetMaster.testResourceConfiguration, (fPath, value) => puppetMaster.testArtiFactoryfileWriter(tLog, (p) => {
25
17
  this.artifacts.push(p);
26
18
  })(puppetMaster.testResourceConfiguration.fs + "/" + fPath, value), tLog, puppetMaster);
27
- // await puppetMaster.browser.disconnect();
28
- // puppeteerBrowser.close();
29
19
  return x;
30
20
  };
31
21
  const runner = suiteRunner(suite);
@@ -59,7 +49,7 @@ export class BaseBuilder {
59
49
  // );
60
50
  // }
61
51
  puppetMaster.writeFileSync(`tests.json`, JSON.stringify(this.toObj(), null, 2));
62
- console.log(`exiting gracefully with ${numberOfFailures} failures.`);
52
+ // console.log(`exiting gracefully with ${numberOfFailures} failures.`);
63
53
  return {
64
54
  failed: numberOfFailures,
65
55
  artifacts: this.artifacts || [],
@@ -7,7 +7,7 @@ export class ClassBuilder extends BaseBuilder {
7
7
  };
8
8
  return a;
9
9
  }, {});
10
- const classyGivens = Object.entries(testImplementation.givens).reduce((a, [key, givEn]) => {
10
+ const classyGivens = Object.entries(testImplementation.givens).reduce((a, [key, g]) => {
11
11
  a[key] = (features, whens, thens, givEn) => {
12
12
  return new givenKlasser.prototype.constructor(key, features, whens, thens, testImplementation.givens[key], givEn);
13
13
  };