testeranto 0.62.0 → 0.73.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 (186) hide show
  1. package/README.md +38 -26
  2. package/dist/cjs-shim.js +2 -2
  3. package/dist/common/Node.js +14 -51
  4. package/dist/common/PM/index.js +71 -0
  5. package/dist/common/PM/main.js +361 -0
  6. package/dist/common/PM/node.js +176 -0
  7. package/dist/common/PM/web.js +174 -0
  8. package/dist/common/Project.js +121 -266
  9. package/dist/common/Puppeteer.js +109 -0
  10. package/dist/common/Reporter.js +119 -0
  11. package/dist/common/Scheduler.js +1 -0
  12. package/dist/common/SubPackages/puppeteer.js +3 -1
  13. package/dist/common/SubPackages/react-dom/component/web.js +98 -45
  14. package/dist/common/SubPackages/react-dom/jsx/web.js +15 -7
  15. package/dist/common/SubPackages/react-test-renderer/MemoExoticComponent/node.js +1 -1
  16. package/dist/common/SubPackages/react-test-renderer/component/index.js +0 -1
  17. package/dist/common/SubPackages/react-test-renderer/fc/web.js +1 -1
  18. package/dist/common/SubPackages/react-test-renderer/jsx/index.js +1 -3
  19. package/dist/common/SubPackages/react-test-renderer/jsx/web.js +1 -1
  20. package/dist/common/SubPackages/react-test-renderer/jsx-promised/index.js +1 -1
  21. package/dist/common/Types.js +2 -32
  22. package/dist/common/Web.js +25 -37
  23. package/dist/common/esbuildConfigs/index.js +5 -5
  24. package/dist/common/esbuildConfigs/node.js +17 -15
  25. package/dist/common/esbuildConfigs/report.js +12 -47
  26. package/dist/common/esbuildConfigs/tests.js +0 -1
  27. package/dist/common/esbuildConfigs/web.js +17 -12
  28. package/dist/common/lib/abstractBase.js +190 -35
  29. package/dist/common/lib/basebuilder.js +56 -29
  30. package/dist/common/lib/classBuilder.js +8 -5
  31. package/dist/common/lib/core.js +42 -17
  32. package/dist/common/lib/index.js +11 -8
  33. package/dist/common/lib/types.js +2 -0
  34. package/dist/common/preload.js +14 -28
  35. package/dist/common/puppeteerConfiger.js +24 -0
  36. package/dist/common/tsconfig.common.tsbuildinfo +1 -1
  37. package/dist/module/Node.js +14 -51
  38. package/dist/module/PM/index.js +67 -0
  39. package/dist/module/PM/main.js +331 -0
  40. package/dist/module/PM/node.js +168 -0
  41. package/dist/module/PM/web.js +167 -0
  42. package/dist/module/Project.js +122 -267
  43. package/dist/module/Puppeteer.js +104 -0
  44. package/dist/module/Reporter.js +114 -0
  45. package/dist/module/Scheduler.js +1 -0
  46. package/dist/module/SubPackages/puppeteer.js +3 -1
  47. package/dist/module/SubPackages/react/jsx/node.js +1 -1
  48. package/dist/module/SubPackages/react/jsx/web.js +1 -1
  49. package/dist/module/SubPackages/react-dom/component/node.js +2 -2
  50. package/dist/module/SubPackages/react-dom/component/web.js +98 -45
  51. package/dist/module/SubPackages/react-dom/jsx/web.js +17 -9
  52. package/dist/module/SubPackages/react-test-renderer/MemoExoticComponent/node.js +1 -1
  53. package/dist/module/SubPackages/react-test-renderer/component/index.js +0 -1
  54. package/dist/module/SubPackages/react-test-renderer/fc/web.js +1 -1
  55. package/dist/module/SubPackages/react-test-renderer/jsx/index.js +1 -3
  56. package/dist/module/SubPackages/react-test-renderer/jsx/web.js +1 -1
  57. package/dist/module/SubPackages/react-test-renderer/jsx-promised/index.js +1 -1
  58. package/dist/module/Types.js +3 -30
  59. package/dist/module/Web.js +26 -38
  60. package/dist/module/esbuildConfigs/index.js +5 -5
  61. package/dist/module/esbuildConfigs/node.js +17 -15
  62. package/dist/module/esbuildConfigs/report.js +11 -48
  63. package/dist/module/esbuildConfigs/tests.js +0 -1
  64. package/dist/module/esbuildConfigs/web.js +17 -12
  65. package/dist/module/lib/abstractBase.js +190 -35
  66. package/dist/module/lib/basebuilder.js +56 -29
  67. package/dist/module/lib/classBuilder.js +8 -5
  68. package/dist/module/lib/core.js +44 -19
  69. package/dist/module/lib/index.js +11 -8
  70. package/dist/module/preload.js +15 -27
  71. package/dist/module/puppeteerConfiger.js +19 -0
  72. package/dist/module/tsconfig.module.tsbuildinfo +1 -1
  73. package/dist/prebuild/Report.css +1616 -584
  74. package/dist/prebuild/Report.js +2635 -2506
  75. package/dist/types/Node.d.ts +3 -2
  76. package/dist/types/PM/index.d.ts +19 -0
  77. package/dist/types/PM/main.d.ts +28 -0
  78. package/dist/types/PM/node.d.ts +26 -0
  79. package/dist/types/PM/web.d.ts +24 -0
  80. package/dist/types/Project.d.ts +1 -2
  81. package/dist/types/Puppeteer.d.ts +1 -0
  82. package/dist/types/Reporter.d.ts +1 -0
  83. package/dist/types/Scheduler.d.ts +0 -0
  84. package/dist/types/SubPackages/puppeteer.d.ts +3 -3
  85. package/dist/types/SubPackages/react/component/node.d.ts +1 -1
  86. package/dist/types/SubPackages/react/component/web.d.ts +1 -1
  87. package/dist/types/SubPackages/react/jsx/index.d.ts +1 -1
  88. package/dist/types/SubPackages/react/jsx/node.d.ts +1 -1
  89. package/dist/types/SubPackages/react/jsx/web.d.ts +2 -2
  90. package/dist/types/SubPackages/react-dom/component/node.d.ts +2 -2
  91. package/dist/types/SubPackages/react-dom/component/web.d.ts +1 -1
  92. package/dist/types/SubPackages/react-dom/jsx/node.d.ts +1 -1
  93. package/dist/types/SubPackages/react-dom/jsx/web.d.ts +1 -1
  94. package/dist/types/SubPackages/react-test-renderer/MemoExoticComponent/node.d.ts +1 -1
  95. package/dist/types/SubPackages/react-test-renderer/component/index.d.ts +1 -1
  96. package/dist/types/SubPackages/react-test-renderer/component/node.d.ts +1 -1
  97. package/dist/types/SubPackages/react-test-renderer/component/web.d.ts +1 -1
  98. package/dist/types/SubPackages/react-test-renderer/fc/node.d.ts +1 -1
  99. package/dist/types/SubPackages/react-test-renderer/fc/web.d.ts +1 -1
  100. package/dist/types/SubPackages/react-test-renderer/jsx/node.d.ts +1 -1
  101. package/dist/types/SubPackages/react-test-renderer/jsx/web.d.ts +3 -3
  102. package/dist/types/SubPackages/react-test-renderer/jsx-promised/index.d.ts +1 -1
  103. package/dist/types/SubPackages/react-test-renderer/jsx-promised/node.d.ts +1 -1
  104. package/dist/types/SubPackages/react-test-renderer/jsx-promised/web.d.ts +1 -1
  105. package/dist/types/Types.d.ts +19 -100
  106. package/dist/types/Web.d.ts +3 -2
  107. package/dist/types/esbuildConfigs/features.d.ts +1 -1
  108. package/dist/types/esbuildConfigs/index.d.ts +1 -1
  109. package/dist/types/esbuildConfigs/node.d.ts +1 -1
  110. package/dist/types/esbuildConfigs/report.d.ts +4 -0
  111. package/dist/types/esbuildConfigs/tests.d.ts +1 -1
  112. package/dist/types/esbuildConfigs/web.d.ts +1 -1
  113. package/dist/types/lib/abstractBase.d.ts +26 -24
  114. package/dist/types/lib/basebuilder.d.ts +10 -7
  115. package/dist/types/lib/classBuilder.d.ts +4 -3
  116. package/dist/types/lib/core.d.ts +5 -4
  117. package/dist/types/lib/index.d.ts +7 -5
  118. package/dist/types/lib/types.d.ts +62 -0
  119. package/dist/types/preload.d.ts +0 -1
  120. package/dist/types/puppeteerConfiger.d.ts +4 -0
  121. package/dist/types/tsconfig.types.tsbuildinfo +1 -1
  122. package/package.json +6 -7
  123. package/src/Node.ts +30 -85
  124. package/src/PM/index.ts +102 -0
  125. package/src/PM/main.ts +420 -0
  126. package/src/PM/node.ts +515 -0
  127. package/src/PM/web.ts +497 -0
  128. package/src/Project.ts +183 -619
  129. package/src/Puppeteer.ts +131 -0
  130. package/src/Report.tsx +158 -44
  131. package/src/Reporter.ts +134 -0
  132. package/src/Scheduler.ts +0 -0
  133. package/src/SubPackages/puppeteer.ts +19 -14
  134. package/src/SubPackages/react/component/node.ts +20 -32
  135. package/src/SubPackages/react/component/web.ts +20 -30
  136. package/src/SubPackages/react/jsx/index.ts +13 -24
  137. package/src/SubPackages/react/jsx/node.ts +5 -8
  138. package/src/SubPackages/react/jsx/web.ts +10 -8
  139. package/src/SubPackages/react-dom/component/node.ts +17 -23
  140. package/src/SubPackages/react-dom/component/web.ts +134 -95
  141. package/src/SubPackages/react-dom/jsx/web.ts +41 -48
  142. package/src/SubPackages/react-test-renderer/MemoExoticComponent/node.ts +27 -37
  143. package/src/SubPackages/react-test-renderer/component/index.ts +16 -30
  144. package/src/SubPackages/react-test-renderer/component/node.ts +5 -11
  145. package/src/SubPackages/react-test-renderer/component/web.ts +5 -11
  146. package/src/SubPackages/react-test-renderer/fc/node.ts +36 -50
  147. package/src/SubPackages/react-test-renderer/fc/web.ts +37 -50
  148. package/src/SubPackages/react-test-renderer/jsx/index.ts +15 -21
  149. package/src/SubPackages/react-test-renderer/jsx/node.ts +6 -10
  150. package/src/SubPackages/react-test-renderer/jsx/web.ts +7 -7
  151. package/src/SubPackages/react-test-renderer/jsx-promised/index.ts +13 -16
  152. package/src/Types.ts +73 -307
  153. package/src/Web.ts +40 -81
  154. package/src/cjs-shim.js +2 -2
  155. package/src/esbuildConfigs/features.ts +3 -4
  156. package/src/esbuildConfigs/index.ts +8 -8
  157. package/src/esbuildConfigs/node.ts +21 -20
  158. package/src/esbuildConfigs/report.ts +15 -51
  159. package/src/esbuildConfigs/tests.ts +3 -9
  160. package/src/esbuildConfigs/web.ts +22 -20
  161. package/src/lib/abstractBase.ts +312 -164
  162. package/src/lib/basebuilder.ts +123 -127
  163. package/src/lib/classBuilder.ts +30 -48
  164. package/src/lib/core.ts +115 -84
  165. package/src/lib/index.ts +58 -56
  166. package/src/lib/types.ts +197 -0
  167. package/src/preload.ts +14 -30
  168. package/src/puppeteerConfiger.ts +26 -0
  169. package/src/web.html.ts +1 -1
  170. package/dist/common/NodeWriter.js +0 -56
  171. package/dist/common/electron.js +0 -196
  172. package/dist/common/lib/browser.js +0 -26
  173. package/dist/common/nodeWriterElectron.js +0 -55
  174. package/dist/module/NodeWriter.js +0 -50
  175. package/dist/module/electron.js +0 -191
  176. package/dist/module/lib/browser.js +0 -22
  177. package/dist/module/nodeWriterElectron.js +0 -52
  178. package/dist/types/NodeWriter.d.ts +0 -2
  179. package/dist/types/lib/browser.d.ts +0 -6
  180. package/dist/types/nodeWriterElectron.d.ts +0 -2
  181. package/src/NodeWriter.ts +0 -69
  182. package/src/electron.ts +0 -250
  183. package/src/lib/browser.ts +0 -34
  184. package/src/nodeWriterElectron.ts +0 -71
  185. package/yarn-error.log +0 -3144
  186. /package/dist/{types/electron.d.ts → module/lib/types.js} +0 -0
@@ -3,16 +3,16 @@ export default (config) => {
3
3
  target: "esnext",
4
4
  format: "esm",
5
5
  splitting: true,
6
- outExtension: { '.js': '.mjs' },
6
+ outExtension: { ".js": ".mjs" },
7
7
  outbase: config.outbase,
8
- jsx: 'transform',
8
+ jsx: "transform",
9
9
  bundle: true,
10
10
  minify: config.minify === true,
11
11
  write: true,
12
12
  loader: {
13
- '.js': 'jsx',
14
- '.png': 'binary',
15
- '.jpg': 'binary',
13
+ ".js": "jsx",
14
+ ".png": "binary",
15
+ ".jpg": "binary",
16
16
  },
17
17
  };
18
18
  };
@@ -1,30 +1,32 @@
1
1
  import baseEsBuildConfig from "./index.js";
2
- // const jsonConfig = jsonc.parse((await fs.readFileSync("./testeranto.json")).toString()) as IJsonConfig;
3
2
  export default (config, entryPoints) => {
4
- return Object.assign(Object.assign({}, baseEsBuildConfig(config)), { outdir: config.outdir + "/node", inject: [`./node_modules/testeranto/dist/cjs-shim.js`], supported: {
5
- "dynamic-import": true
3
+ return Object.assign(Object.assign({}, baseEsBuildConfig(config)), { splitting: true, outdir: config.outdir + "/node", inject: [`./node_modules/testeranto/dist/cjs-shim.js`], supported: {
4
+ "dynamic-import": true,
6
5
  }, define: {
7
- "process.env.FLUENTFFMPEG_COV": "0"
6
+ "process.env.FLUENTFFMPEG_COV": "0",
8
7
  }, absWorkingDir: process.cwd(), banner: {
9
- js: `import { createRequire } from 'module';const require = createRequire(import.meta.url);`
8
+ js: `import { createRequire } from 'module';const require = createRequire(import.meta.url);`,
10
9
  }, platform: "node", external: [
11
- "testeranto.json",
12
- "features.test.js",
13
- "react",
14
- "events",
10
+ // "testeranto.json",
11
+ // "features.test.js",
12
+ // "react",
13
+ // "events",
15
14
  // "ganache"
16
- ...config.externals
15
+ ...config.externals,
17
16
  ], entryPoints: [...entryPoints], plugins: [
18
17
  ...(config.nodePlugins || []),
19
18
  {
20
- name: 'rebuild-notify',
19
+ name: "rebuild-notify",
21
20
  setup(build) {
22
- build.onEnd(result => {
21
+ build.onEnd((result) => {
23
22
  console.log(`node build ended with ${result.errors.length} errors`);
24
- console.log(result);
25
- result.errors.length !== 0 && process.exit(-1);
23
+ if (result.errors.length > 0) {
24
+ console.log(result);
25
+ }
26
+ // console.log(result);
27
+ // result.errors.length !== 0 && process.exit(-1);
26
28
  });
27
- }
29
+ },
28
30
  },
29
31
  ] });
30
32
  };
@@ -1,48 +1,11 @@
1
- "use strict";
2
- // import { jsonc } from "jsonc";
3
- // import { IBaseConfig, IJsonConfig } from "../Types";
4
- // import baseEsBuildConfig from "./index.js";
5
- // import fs from "fs"
6
- // import { BuildOptions } from "esbuild";
7
- // // import { CssModulesPlugin } from 'esbuild-css-modules-plugin';
8
- // const jsonConfig = jsonc.parse((await fs.readFileSync("./testeranto.json")).toString()) as IJsonConfig;
9
- // export default (config: IBaseConfig): BuildOptions => {
10
- // return {
11
- // bundle: true,
12
- // entryPoints: ["./node_modules/testeranto/dist/module/report.js"],
13
- // minify: config.minify === true,
14
- // outbase: config.outbase,
15
- // write: true,
16
- // outfile: `${jsonConfig.outdir}/report.js`,
17
- // external: [
18
- // "tests.json",
19
- // "features.test.js"
20
- // ],
21
- // // plugins: [
22
- // // CssModulesPlugin({
23
- // // // @see https://github.com/indooorsman/esbuild-css-modules-plugin/blob/main/index.d.ts for more details
24
- // // force: true,
25
- // // emitDeclarationFile: true,
26
- // // localsConvention: 'camelCaseOnly',
27
- // // namedExports: true,
28
- // // inject: false
29
- // // })
30
- // // ]
31
- // }
32
- // // return {
33
- // // bundle: true,
34
- // // entryPoints: [
35
- // // "./node_modules/testeranto/dist/module/Report.js",
36
- // // jsonConfig.features
37
- // // ],
38
- // // minify: config.minify === true,
39
- // // outbase: ".",
40
- // // outdir: 'docs',
41
- // // write: true,
42
- // // // outfile: `${jsonConfig.outdir}/Report.js`,
43
- // // external: [
44
- // // "features.test.js",
45
- // // "testeranto.json"
46
- // // ]
47
- // // }
48
- // }
1
+ export default (config) => {
2
+ return {
3
+ bundle: true,
4
+ entryPoints: ["./node_modules/testeranto/dist/module/report.js"],
5
+ minify: config.minify === true,
6
+ outbase: config.outbase,
7
+ write: true,
8
+ outfile: `${config.outdir}/report.js`,
9
+ external: ["tests.json", "features.test.js"],
10
+ };
11
+ };
@@ -1,4 +1,3 @@
1
- // const jsonConfig = jsonc.parse((await fs.readFileSync("./testeranto.json")).toString()) as IJsonConfig;
2
1
  export default (config) => {
3
2
  return {
4
3
  bundle: true,
@@ -1,20 +1,19 @@
1
1
  import path from "path";
2
2
  import baseEsBuildConfig from "./index.js";
3
- // const jsonConfig = jsonc.parse((await fs.readFileSync("./testeranto.json")).toString()) as IJsonConfig;
4
3
  export default (config, entryPoints) => {
5
4
  return Object.assign(Object.assign({}, baseEsBuildConfig(config)), {
6
- // inject: ['./node_modules/testeranto/dist/cjs-shim.js'],
5
+ // inject: ["./node_modules/testeranto/dist/cjs-shim.js"],
7
6
  // banner: {
8
- // js: `import { createRequire } from 'module';const require = createRequire(import.meta.url);`
7
+ // js: `import { createRequire } from 'module';const require = createRequire(import.meta.url);`,
9
8
  // },
9
+ // splitting: true,
10
10
  outdir: config.outdir + "/web", alias: {
11
- react: path.resolve("./node_modules/react")
11
+ react: path.resolve("./node_modules/react"),
12
12
  }, external: [
13
13
  "testeranto.json",
14
14
  "features.test.ts",
15
- // "url",
15
+ // "url",
16
16
  "react",
17
- "electron",
18
17
  "path",
19
18
  "fs",
20
19
  "stream",
@@ -28,18 +27,24 @@ export default (config, entryPoints) => {
28
27
  "readline",
29
28
  "zlib",
30
29
  "crypto",
31
- "https"
30
+ "https",
31
+ "util",
32
+ "process",
33
+ "dns",
32
34
  ], platform: "browser", entryPoints: [...entryPoints], plugins: [
33
35
  ...(config.webPlugins || []),
34
36
  {
35
- name: 'rebuild-notify',
37
+ name: "rebuild-notify",
36
38
  setup(build) {
37
- build.onEnd(result => {
39
+ build.onEnd((result) => {
38
40
  console.log(`web build ended with ${result.errors.length} errors`);
39
- console.log(result);
40
- result.errors.length !== 0 && process.exit(-1);
41
+ if (result.errors.length > 0) {
42
+ console.log(result);
43
+ }
44
+ // console.log(result);
45
+ // result.errors.length !== 0 && process.exit(-1);
41
46
  });
42
- }
47
+ },
43
48
  },
44
49
  ] });
45
50
  };
@@ -13,38 +13,114 @@ export class BaseSuite {
13
13
  fails: this.fails,
14
14
  };
15
15
  }
16
- setup(s, artifactory, tr, utils) {
16
+ setup(s, artifactory, tr, pm) {
17
17
  return new Promise((res) => res(s));
18
18
  }
19
19
  assertThat(t) {
20
- // console.log("base assertThat")
21
20
  return t;
22
21
  }
23
- async run(input, testResourceConfiguration, artifactory, tLog, utils) {
22
+ afterAll(store, artifactory, pm) {
23
+ return store;
24
+ }
25
+ async run(input, testResourceConfiguration, artifactory, tLog, pm) {
24
26
  this.testResourceConfiguration = testResourceConfiguration;
25
- tLog("test resources: ", testResourceConfiguration);
27
+ tLog("test resources: ", JSON.stringify(testResourceConfiguration));
26
28
  const suiteArtifactory = (fPath, value) => artifactory(`suite-${this.index}-${this.name}/${fPath}`, value);
27
- const subject = await this.setup(input, suiteArtifactory, testResourceConfiguration, utils);
29
+ console.log("\nSuite:", this.index, this.name);
28
30
  tLog("\nSuite:", this.index, this.name);
29
- for (const k of Object.keys(this.givens)) {
30
- const giver = this.givens[k];
31
+ const sNdx = this.index;
32
+ const sName = this.name;
33
+ for (const [gNdx, g] of Object.entries(this.givens)) {
34
+ const subject = await this.setup(input, suiteArtifactory, testResourceConfiguration, pm);
35
+ const giver = this.givens[gNdx];
31
36
  try {
32
- this.store = await giver.give(subject, k, testResourceConfiguration, this.assertThat, suiteArtifactory, tLog, utils);
37
+ this.store = await giver.give(subject, gNdx, testResourceConfiguration, this.assertThat, suiteArtifactory, tLog, pm, sNdx);
33
38
  }
34
39
  catch (e) {
35
40
  console.error(e);
36
41
  this.fails.push(giver);
37
- return this;
42
+ // return this;
38
43
  }
39
44
  }
40
- for (const [ndx, thater] of this.checks.entries()) {
41
- await thater.check(subject, thater.name, testResourceConfiguration, this.assertThat, suiteArtifactory, tLog, utils);
45
+ const afterAllProxy = new Proxy(pm, {
46
+ get(target, prop, receiver) {
47
+ if (prop === "writeFileSync") {
48
+ return (fp, contents) => target[prop](`suite-${sNdx}/afterAll/${fp}`, contents);
49
+ }
50
+ if (prop === "browser") {
51
+ return new Proxy(target[prop], {
52
+ get(bTarget, bProp, bReceiver) {
53
+ if (bProp === "pages") {
54
+ return async () => {
55
+ return bTarget.pages().then((pages) => {
56
+ return pages.map((page) => {
57
+ return new Proxy(page, {
58
+ get(pTarget, pProp, pReciever) {
59
+ if (pProp === "screenshot") {
60
+ return async (x) => {
61
+ // console.log(
62
+ // "custom-screenshot-MARK-afterAllProxy",
63
+ // // arguments,
64
+ // // x,
65
+ // window["custom-screenshot"].toString()
66
+ // );
67
+ return await window["custom-screenshot"](Object.assign(Object.assign({}, x), { path: `${testResourceConfiguration.fs}/suite-${sNdx}/afterAll` +
68
+ "/" +
69
+ x.path }));
70
+ };
71
+ }
72
+ // else if (pProp === "mainFrame") {
73
+ // return () => target[pProp](...arguments);
74
+ // }
75
+ else {
76
+ return Reflect.get(...arguments);
77
+ }
78
+ },
79
+ });
80
+ });
81
+ });
82
+ // return (await target.pages()).map((page) => {
83
+ // return new Proxy(page, handler2);
84
+ // });
85
+ };
86
+ }
87
+ },
88
+ });
89
+ }
90
+ return Reflect.get(...arguments);
91
+ },
92
+ });
93
+ // pm.browser
94
+ try {
95
+ this.afterAll(this.store, artifactory, afterAllProxy);
42
96
  }
43
- // @TODO fix me
44
- for (const k of Object.keys(this.givens)) {
45
- const giver = this.givens[k];
46
- giver.afterAll(this.store, artifactory, utils);
97
+ catch (e) {
98
+ console.error(e);
99
+ // this.fails.push(this);
100
+ // return this;
47
101
  }
102
+ // for (const [ndx, thater] of this.checks.entries()) {
103
+ // await thater.check(
104
+ // subject,
105
+ // thater.name,
106
+ // testResourceConfiguration,
107
+ // this.assertThat,
108
+ // suiteArtifactory,
109
+ // tLog,
110
+ // pm
111
+ // );
112
+ // }
113
+ // @TODO fix me
114
+ // for (const k of Object.keys(this.givens)) {
115
+ // const giver = this.givens[k];
116
+ // try {
117
+ // giver.afterAll(this.store, artifactory, pm);
118
+ // } catch (e) {
119
+ // console.error(e);
120
+ // this.fails.push(giver);
121
+ // return this;
122
+ // }
123
+ // }
48
124
  ////////////////
49
125
  return this;
50
126
  }
@@ -61,32 +137,39 @@ export class BaseGiven {
61
137
  beforeAll(store, artifactory) {
62
138
  return store;
63
139
  }
64
- afterAll(store, artifactory, utils) {
65
- return store;
66
- }
67
140
  toObj() {
68
141
  return {
69
142
  name: this.name,
70
143
  whens: this.whens.map((w) => w.toObj()),
71
144
  thens: this.thens.map((t) => t.toObj()),
72
145
  error: this.error ? [this.error, this.error.stack] : null,
146
+ // fail: this.fail ? [this.fail] : false,
73
147
  features: this.features,
74
148
  };
75
149
  }
76
- async afterEach(store, key, artifactory) {
150
+ async afterEach(store, key, artifactory, pm) {
77
151
  return store;
78
152
  }
79
- async give(subject, key, testResourceConfiguration, tester, artifactory, tLog, utils) {
153
+ async give(subject, key, testResourceConfiguration, tester, artifactory, tLog, pm, suiteNdx) {
80
154
  tLog(`\n Given: ${this.name}`);
81
155
  const givenArtifactory = (fPath, value) => artifactory(`given-${key}/${fPath}`, value);
82
156
  try {
83
- this.store = await this.givenThat(subject, testResourceConfiguration, givenArtifactory, this.givenCB);
84
157
  // tLog(`\n Given this.store`, this.store);
85
- for (const whenStep of this.whens) {
86
- await whenStep.test(this.store, testResourceConfiguration, tLog, utils);
158
+ const beforeEachProxy = new Proxy(pm, {
159
+ get(target, prop, receiver) {
160
+ if (prop === "writeFileSync") {
161
+ console.log("beforeEachProx", arguments, target[prop]);
162
+ return (fp, contents) => target[prop](`suite-${suiteNdx}/given-${key}/when/beforeEach/${fp}`, contents);
163
+ }
164
+ return Reflect.get(...arguments);
165
+ },
166
+ });
167
+ this.store = await this.givenThat(subject, testResourceConfiguration, givenArtifactory, this.givenCB, beforeEachProxy);
168
+ for (const [whenNdx, whenStep] of this.whens.entries()) {
169
+ await whenStep.test(this.store, testResourceConfiguration, tLog, pm, `suite-${suiteNdx}/given-${key}/when/${whenNdx}`);
87
170
  }
88
171
  for (const thenStep of this.thens) {
89
- const t = await thenStep.test(this.store, testResourceConfiguration, tLog, utils);
172
+ const t = await thenStep.test(this.store, testResourceConfiguration, tLog, pm);
90
173
  tester(t);
91
174
  }
92
175
  }
@@ -98,7 +181,66 @@ export class BaseGiven {
98
181
  }
99
182
  finally {
100
183
  try {
101
- await this.afterEach(this.store, key, givenArtifactory);
184
+ // const afterEachProxy = new Proxy(pm, {
185
+ // get(target, prop, receiver) {
186
+ // if (prop === "writeFileSync") {
187
+ // console.log("afterEachProxy", arguments, target[prop]);
188
+ // return (fp, contents) =>
189
+ // // target[prop](`${key}/andWhen/${fp}`, contents);
190
+ // target[prop](`${key}/afterEach/${fp}`, contents);
191
+ // }
192
+ // return Reflect.get(...arguments);
193
+ // },
194
+ // });
195
+ // await this.afterEach(this.store, key, givenArtifactory, afterEachProxy);
196
+ // await this.afterEach(this.store, key, givenArtifactory, pm);
197
+ const afterEachProxy = new Proxy(pm, {
198
+ get(target, prop, receiver) {
199
+ if (prop === "writeFileSync") {
200
+ return (fp, contents) => target[prop](`suite-${suiteNdx}/given-${key}/afterAll/${fp}`, contents);
201
+ }
202
+ if (prop === "browser") {
203
+ return new Proxy(target[prop], {
204
+ get(bTarget, bProp, bReceiver) {
205
+ if (bProp === "pages") {
206
+ return async () => {
207
+ return bTarget.pages().then((pages) => {
208
+ return pages.map((page) => {
209
+ return new Proxy(page, {
210
+ get(pTarget, pProp, pReciever) {
211
+ if (pProp === "screenshot") {
212
+ return async (x) => {
213
+ // console.log(
214
+ // "custom-screenshot-MARK-afterEachProxy",
215
+ // window["custom-screenshot"].toString()
216
+ // );
217
+ return await window["custom-screenshot"](Object.assign(Object.assign({}, x), { path: `${testResourceConfiguration.fs}/suite-${suiteNdx}/given-${key}/afterEach` +
218
+ "/" +
219
+ x.path }));
220
+ };
221
+ }
222
+ // else if (pProp === "mainFrame") {
223
+ // return () => target[pProp](...arguments);
224
+ // }
225
+ else {
226
+ return Reflect.get(...arguments);
227
+ }
228
+ },
229
+ });
230
+ });
231
+ });
232
+ // return (await target.pages()).map((page) => {
233
+ // return new Proxy(page, handler2);
234
+ // });
235
+ };
236
+ }
237
+ },
238
+ });
239
+ }
240
+ return Reflect.get(...arguments);
241
+ },
242
+ });
243
+ await this.afterEach(this.store, key, givenArtifactory, afterEachProxy);
102
244
  }
103
245
  catch (e) {
104
246
  console.error("afterEach failed! no error will be recorded!", e);
@@ -118,10 +260,22 @@ export class BaseWhen {
118
260
  error: this.error,
119
261
  };
120
262
  }
121
- async test(store, testResourceConfiguration, tLog, utils) {
263
+ async test(store, testResourceConfiguration, tLog, pm, key) {
122
264
  tLog(" When:", this.name);
265
+ const name = this.name;
266
+ const andWhenProxy = new Proxy(pm, {
267
+ get(target, prop, receiver) {
268
+ if (prop === "writeFileSync") {
269
+ console.log("andWhenProxy", arguments, target[prop]);
270
+ return (fp, contents) =>
271
+ // target[prop](`${key}/andWhen/${fp}`, contents);
272
+ target[prop](`${key}/andWhen/${fp}`, contents);
273
+ }
274
+ return Reflect.get(...arguments);
275
+ },
276
+ });
123
277
  try {
124
- return await this.andWhen(store, this.whenCB, testResourceConfiguration);
278
+ return await this.andWhen(store, this.whenCB, testResourceConfiguration, andWhenProxy);
125
279
  }
126
280
  catch (e) {
127
281
  this.error = true;
@@ -133,6 +287,7 @@ export class BaseThen {
133
287
  constructor(name, thenCB) {
134
288
  this.name = name;
135
289
  this.thenCB = thenCB;
290
+ this.error = false;
136
291
  }
137
292
  toObj() {
138
293
  return {
@@ -140,15 +295,15 @@ export class BaseThen {
140
295
  error: this.error,
141
296
  };
142
297
  }
143
- async test(store, testResourceConfiguration, tLog, utils) {
298
+ async test(store, testResourceConfiguration, tLog, pm) {
144
299
  tLog(" Then:", this.name);
145
300
  try {
146
- const x = (await this.butThen(store, this.thenCB, testResourceConfiguration));
301
+ const x = await this.butThen(store, this.thenCB, testResourceConfiguration);
147
302
  return x;
148
303
  }
149
304
  catch (e) {
150
305
  console.log("test failed", e);
151
- this.error = true;
306
+ this.error = e.message;
152
307
  throw e;
153
308
  }
154
309
  }
@@ -161,25 +316,25 @@ export class BaseCheck {
161
316
  this.whens = whens;
162
317
  this.thens = thens;
163
318
  }
164
- async afterEach(store, key, cb) {
319
+ async afterEach(store, key, cb, pm) {
165
320
  return;
166
321
  }
167
- async check(subject, key, testResourceConfiguration, tester, artifactory, tLog, utils) {
322
+ async check(subject, key, testResourceConfiguration, tester, artifactory, tLog, pm) {
168
323
  tLog(`\n Check: ${this.name}`);
169
324
  const store = await this.checkThat(subject, testResourceConfiguration, artifactory);
170
325
  await this.checkCB(Object.entries(this.whens).reduce((a, [key, when]) => {
171
326
  a[key] = async (payload) => {
172
- return await when(payload, testResourceConfiguration).test(store, testResourceConfiguration, tLog, utils);
327
+ return await when(payload, testResourceConfiguration).test(store, testResourceConfiguration, tLog, pm, "x");
173
328
  };
174
329
  return a;
175
330
  }, {}), Object.entries(this.thens).reduce((a, [key, then]) => {
176
331
  a[key] = async (payload) => {
177
- const t = await then(payload, testResourceConfiguration).test(store, testResourceConfiguration, tLog, utils);
332
+ const t = await then(payload, testResourceConfiguration).test(store, testResourceConfiguration, tLog, pm);
178
333
  tester(t);
179
334
  };
180
335
  return a;
181
336
  }, {}));
182
- await this.afterEach(store, key);
337
+ await this.afterEach(store, key, () => { }, pm);
183
338
  return;
184
339
  }
185
340
  }
@@ -1,5 +1,7 @@
1
1
  export class BaseBuilder {
2
- constructor(input, suitesOverrides, givenOverides, whenOverides, thenOverides, checkOverides, logWriter, testResourceRequirement, testSpecification) {
2
+ constructor(input, suitesOverrides, givenOverides, whenOverides, thenOverides, checkOverides, testResourceRequirement, testSpecification
3
+ // puppetMaster: PM
4
+ ) {
3
5
  this.input = input;
4
6
  this.artifacts = [];
5
7
  this.artifacts = [];
@@ -10,52 +12,77 @@ export class BaseBuilder {
10
12
  this.thenOverides = thenOverides;
11
13
  this.checkOverides = checkOverides;
12
14
  this.testSpecification = testSpecification;
15
+ // this.puppetMaster = puppetMaster;
13
16
  this.specs = testSpecification(this.Suites(), this.Given(), this.When(), this.Then(), this.Check());
14
- const suiteRunner = (suite, utils) => async (testResourceConfiguration, tLog, utils) => {
15
- return await suite.run(input, testResourceConfiguration, (fPath, value) => logWriter.testArtiFactoryfileWriter(tLog, (p) => {
16
- this.artifacts.push(p);
17
- })(testResourceConfiguration.fs + "/" + fPath, value), tLog, utils);
18
- };
19
- this.testJobs = this.specs.map((suite, utils) => {
20
- const runner = suiteRunner(suite, utils);
17
+ this.testJobs = this.specs.map((suite) => {
18
+ const suiteRunner = (suite) => async (
19
+ // testResourceConfiguration: ITTestResourceConfiguration,
20
+ puppetMaster, tLog) => {
21
+ await puppetMaster.startPuppeteer({
22
+ browserWSEndpoint: puppetMaster.testResourceConfiguration.browserWSEndpoint,
23
+ }, puppetMaster.testResourceConfiguration.fs);
24
+ return await suite.run(input, puppetMaster.testResourceConfiguration, (fPath, value) => puppetMaster.testArtiFactoryfileWriter(tLog, (p) => {
25
+ this.artifacts.push(p);
26
+ })(puppetMaster.testResourceConfiguration.fs + "/" + fPath, value), tLog, puppetMaster);
27
+ };
28
+ const runner = suiteRunner(suite);
21
29
  return {
22
30
  test: suite,
23
- testResourceRequirement,
31
+ // testResourceRequirement,
24
32
  toObj: () => {
25
33
  return suite.toObj();
26
34
  },
27
35
  runner,
28
- receiveTestResourceConfig: async function (testResourceConfiguration = {
29
- name: "",
30
- fs: ".",
31
- ports: [],
32
- scheduled: false
33
- }, y) {
34
- console.log(`testResourceConfiguration ${JSON.stringify(testResourceConfiguration, null, 2)}`);
35
- await logWriter.mkdirSync(testResourceConfiguration.fs);
36
- logWriter.writeFileSync(`${testResourceConfiguration.fs}/tests.json`, JSON.stringify(this.toObj(), null, 2));
37
- const logFilePath = `${testResourceConfiguration.fs}/log.txt`;
38
- const access = await logWriter.createWriteStream(logFilePath);
36
+ receiveTestResourceConfig: async function (
37
+ // testResourceConfiguration = {
38
+ // name: "",
39
+ // fs: ".",
40
+ // ports: [],
41
+ // browserWSEndpoint: "",
42
+ // },
43
+ puppetMaster) {
44
+ // console.log(
45
+ // `testResourceConfiguration! ${JSON.stringify(
46
+ // testResourceConfiguration,
47
+ // null,
48
+ // 2
49
+ // )}`
50
+ // );
51
+ // console.log("puppetMaster", puppetMaster);
52
+ await puppetMaster
53
+ .mkdirSync();
54
+ // if (!puppetMaster.existsSync(destFolder)) {
55
+ // puppetMaster.mkdirSync(destFolder, { recursive: true });
56
+ // }
57
+ // puppetMaster.writeFileSync(
58
+ // // puppetMaster.testResourceConfiguration.fs + `/tests.json`,
59
+ // `tests.json`,
60
+ // JSON.stringify(this.toObj(), null, 2)
61
+ // );
62
+ const logFilePath = "log.txt";
63
+ // puppetMaster.testResourceConfiguration.fs + `/log.txt`;
64
+ const access = await puppetMaster.createWriteStream(logFilePath);
65
+ // console.log("access", access);
39
66
  const tLog = (...l) => {
40
- // console.log(...l);
41
- access.write(`${l.toString()}\n`);
67
+ // access.write(`${l.toString()}\n`);
68
+ // console.log("tLog", l);
69
+ puppetMaster.write(access, `${l.toString()}\n`);
42
70
  };
43
- const suiteDone = await runner(testResourceConfiguration, tLog, y);
44
- const resultsFilePath = (`${testResourceConfiguration.fs}/results.json`);
45
- logWriter.writeFileSync(resultsFilePath, JSON.stringify(suiteDone.toObj(), null, 2));
71
+ const suiteDone = await runner(puppetMaster, tLog);
46
72
  const logPromise = new Promise((res, rej) => {
47
- access.on("finish", () => { res(true); });
73
+ puppetMaster.end(access);
74
+ res(true);
48
75
  });
49
- access.end();
50
76
  const numberOfFailures = Object.keys(suiteDone.givens).filter((k) => {
51
- // console.log(`suiteDone.givens[k].error`, suiteDone.givens[k].error);
52
77
  return suiteDone.givens[k].error;
53
78
  }).length;
79
+ puppetMaster.writeFileSync(`exitcode`, numberOfFailures.toString());
80
+ puppetMaster.writeFileSync(`tests.json`, JSON.stringify(this.toObj(), null, 2));
54
81
  console.log(`exiting gracefully with ${numberOfFailures} failures.`);
55
82
  return {
56
83
  failed: numberOfFailures,
57
84
  artifacts: this.artifacts || [],
58
- logPromise
85
+ logPromise,
59
86
  };
60
87
  },
61
88
  };