testeranto 0.70.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 (94) hide show
  1. package/README.md +9 -18
  2. package/dist/common/Node.js +14 -34
  3. package/dist/common/PM/index.js +71 -0
  4. package/dist/common/PM/main.js +361 -0
  5. package/dist/common/PM/node.js +176 -0
  6. package/dist/common/PM/web.js +174 -0
  7. package/dist/common/Project.js +20 -2
  8. package/dist/common/Puppeteer.js +109 -0
  9. package/dist/common/Reporter.js +119 -0
  10. package/dist/common/Scheduler.js +1 -0
  11. package/dist/common/SubPackages/puppeteer.js +3 -1
  12. package/dist/common/SubPackages/react-dom/component/web.js +98 -45
  13. package/dist/common/SubPackages/react-test-renderer/jsx/index.js +0 -1
  14. package/dist/common/Web.js +24 -43
  15. package/dist/common/esbuildConfigs/web.js +3 -1
  16. package/dist/common/lib/abstractBase.js +189 -41
  17. package/dist/common/lib/basebuilder.js +56 -29
  18. package/dist/common/lib/classBuilder.js +6 -2
  19. package/dist/common/lib/core.js +41 -45
  20. package/dist/common/lib/index.js +2 -1
  21. package/dist/common/preload.js +14 -18
  22. package/dist/common/tsconfig.common.tsbuildinfo +1 -1
  23. package/dist/module/Node.js +14 -34
  24. package/dist/module/PM/index.js +67 -0
  25. package/dist/module/PM/main.js +331 -0
  26. package/dist/module/PM/node.js +168 -0
  27. package/dist/module/PM/web.js +167 -0
  28. package/dist/module/Project.js +20 -2
  29. package/dist/module/Puppeteer.js +104 -0
  30. package/dist/module/Reporter.js +114 -0
  31. package/dist/module/Scheduler.js +1 -0
  32. package/dist/module/SubPackages/puppeteer.js +3 -1
  33. package/dist/module/SubPackages/react/jsx/node.js +1 -1
  34. package/dist/module/SubPackages/react-dom/component/web.js +98 -45
  35. package/dist/module/SubPackages/react-test-renderer/jsx/index.js +0 -1
  36. package/dist/module/Web.js +24 -43
  37. package/dist/module/esbuildConfigs/web.js +3 -1
  38. package/dist/module/lib/abstractBase.js +189 -41
  39. package/dist/module/lib/basebuilder.js +56 -29
  40. package/dist/module/lib/classBuilder.js +6 -2
  41. package/dist/module/lib/core.js +41 -45
  42. package/dist/module/lib/index.js +2 -1
  43. package/dist/module/preload.js +15 -14
  44. package/dist/module/tsconfig.module.tsbuildinfo +1 -1
  45. package/dist/prebuild/Report.css +1616 -584
  46. package/dist/prebuild/Report.js +2635 -2506
  47. package/dist/types/PM/index.d.ts +19 -0
  48. package/dist/types/PM/main.d.ts +28 -0
  49. package/dist/types/PM/node.d.ts +26 -0
  50. package/dist/types/PM/web.d.ts +24 -0
  51. package/dist/types/Reporter.d.ts +1 -0
  52. package/dist/types/Scheduler.d.ts +0 -0
  53. package/dist/types/SubPackages/react-dom/component/web.d.ts +1 -1
  54. package/dist/types/lib/abstractBase.d.ts +13 -12
  55. package/dist/types/lib/basebuilder.d.ts +4 -2
  56. package/dist/types/lib/classBuilder.d.ts +2 -2
  57. package/dist/types/lib/core.d.ts +4 -4
  58. package/dist/types/lib/index.d.ts +6 -5
  59. package/dist/types/lib/types.d.ts +16 -24
  60. package/dist/types/preload.d.ts +0 -1
  61. package/dist/types/tsconfig.types.tsbuildinfo +1 -1
  62. package/package.json +3 -5
  63. package/src/Node.ts +18 -43
  64. package/src/PM/index.ts +102 -0
  65. package/src/PM/main.ts +420 -0
  66. package/src/PM/node.ts +515 -0
  67. package/src/PM/web.ts +497 -0
  68. package/src/Project.ts +21 -2
  69. package/src/Puppeteer.ts +131 -0
  70. package/src/Report.tsx +158 -44
  71. package/src/Reporter.ts +134 -0
  72. package/src/Scheduler.ts +0 -0
  73. package/src/SubPackages/puppeteer.ts +3 -3
  74. package/src/SubPackages/react/jsx/node.ts +5 -8
  75. package/src/SubPackages/react-dom/component/web.ts +126 -67
  76. package/src/SubPackages/react-test-renderer/jsx/index.ts +0 -1
  77. package/src/Web.ts +25 -67
  78. package/src/esbuildConfigs/web.ts +4 -2
  79. package/src/lib/abstractBase.ts +260 -65
  80. package/src/lib/basebuilder.ts +121 -100
  81. package/src/lib/classBuilder.ts +5 -4
  82. package/src/lib/core.ts +58 -59
  83. package/src/lib/index.ts +10 -9
  84. package/src/lib/types.ts +18 -27
  85. package/src/preload.ts +14 -14
  86. package/dist/common/NodeWriter.js +0 -54
  87. package/dist/common/electron.js +0 -266
  88. package/dist/module/NodeWriter.js +0 -48
  89. package/dist/module/electron.js +0 -261
  90. package/dist/types/NodeWriter.d.ts +0 -2
  91. package/src/NodeWriter.ts +0 -72
  92. package/src/electron.ts +0 -317
  93. package/yarn-error.log +0 -3144
  94. /package/dist/types/{electron.d.ts → Puppeteer.d.ts} +0 -0
@@ -7,54 +7,107 @@ const react_1 = require("react");
7
7
  const client_1 = __importDefault(require("react-dom/client"));
8
8
  const Web_js_1 = __importDefault(require("../../../Web.js"));
9
9
  exports.default = (testInput, testSpecifications, testImplementations) => {
10
+ class TesterantoComponent extends testInput {
11
+ constructor(props) {
12
+ super(props);
13
+ this.done = props.done;
14
+ }
15
+ componentDidMount() {
16
+ super.componentDidMount && super.componentDidMount();
17
+ return this.done(this);
18
+ }
19
+ }
20
+ const t = (0, Web_js_1.default)(testInput, testSpecifications, testImplementations, {
21
+ beforeAll: async (initialProps, artificer) => {
22
+ console.log("mark5", initialProps);
23
+ return await new Promise((resolve, rej) => {
24
+ const htmlElement = document.getElementById("root");
25
+ if (htmlElement) {
26
+ const domRoot = client_1.default.createRoot(htmlElement);
27
+ // Ignore these type errors
28
+ domRoot.render((0, react_1.createElement)(TesterantoComponent, Object.assign(Object.assign({}, initialProps), { done: (reactElement) => {
29
+ resolve({
30
+ htmlElement,
31
+ reactElement,
32
+ domRoot,
33
+ });
34
+ } }), []));
35
+ // resolve({ htmlElement });
36
+ }
37
+ });
38
+ },
39
+ // beforeEach: async (
40
+ // s,
41
+ // initializer,
42
+ // testResource,
43
+ // artificer,
44
+ // initialValues
45
+ // ): Promise<IStore> => {
46
+ // return new Promise((resolve, rej) => {
47
+ // console.log("beforeEach" + TesterantoComponent);
48
+ // // const domRoot = ReactDom.createRoot(htmlElement);
49
+ // // // Ignore these type errors
50
+ // // domRoot.render(
51
+ // // createElement(
52
+ // // TesterantoComponent,
53
+ // // {
54
+ // // ...initializer,
55
+ // // done: (reactElement) => {
56
+ // // resolve({
57
+ // // htmlElement,
58
+ // // reactElement,
59
+ // // domRoot,
60
+ // // });
61
+ // // },
62
+ // // },
63
+ // // []
64
+ // // )
65
+ // // );
66
+ // });
67
+ // },
68
+ andWhen: function (s, whenCB) {
69
+ return whenCB(s);
70
+ },
71
+ butThen: async function (s, thenCB) {
72
+ return thenCB(s);
73
+ },
74
+ afterEach: async function (store, ndx, artificer, utils) {
75
+ console.log("afterEach", store);
76
+ utils.writeFileSync("aftereachlog", store.toString());
77
+ const page = (await utils.browser.pages()).filter((x) => {
78
+ const parsedUrl = new URL(x.url());
79
+ parsedUrl.search = "";
80
+ const strippedUrl = parsedUrl.toString();
81
+ return (strippedUrl ===
82
+ "file:///Users/adam/Code/kokomoBay/docs/web/src/ClassicalComponent/react-dom/client.web.test.html");
83
+ // return true;
84
+ })[0];
85
+ const x = await page.screenshot({
86
+ path: "afterEachLog.jpg",
87
+ });
88
+ console.log("x", x);
89
+ // debugger;
90
+ // const div_root = document.getElementById("root");
91
+ // store.domRoot && store.domRoot.unmount(); //React 18
92
+ // store.remove();
93
+ // store.htmlElement.remove();
94
+ // store.htmlElement = document.createElement("root");
95
+ return store;
96
+ },
97
+ afterAll: async (store, artificer, utils) => {
98
+ // setTimeout(() => {
99
+ // console.log("This will run after 1 second");
100
+ // }, 1000); // 1000 milliseconds = 1 second
101
+ // store.htmlElement.remove();
102
+ // store.htmlElement = document.createElement("root");
103
+ return store;
104
+ },
105
+ });
10
106
  document.addEventListener("DOMContentLoaded", function () {
11
107
  const elem = document.getElementById("root");
12
108
  if (elem) {
13
- class TesterantoComponent extends testInput {
14
- constructor(props) {
15
- super(props);
16
- this.done = props.done;
17
- }
18
- componentDidMount() {
19
- super.componentDidMount && super.componentDidMount();
20
- return this.done(this);
21
- }
22
- }
23
- return (0, Web_js_1.default)(testInput, testSpecifications, testImplementations, {
24
- beforeAll: async (initialProps, artificer) => {
25
- console.log("mark5", initialProps);
26
- return await new Promise((resolve, rej) => {
27
- const elem = document.getElementById("root");
28
- if (elem) {
29
- resolve({ htmlElement: elem });
30
- }
31
- });
32
- },
33
- beforeEach: async ({ htmlElement }, initializer, testResource, artificer, initialValues) => {
34
- return new Promise((resolve, rej) => {
35
- // console.log("beforeEach" + JSON.stringify(initializer) + JSON.stringify(initialValues));
36
- // Ignore these type errors
37
- client_1.default.createRoot(htmlElement).render((0, react_1.createElement)(TesterantoComponent, Object.assign(Object.assign({}, initializer), { done: (reactElement) => {
38
- resolve({
39
- htmlElement,
40
- reactElement,
41
- });
42
- } }), []));
43
- });
44
- },
45
- andWhen: function (s, whenCB) {
46
- return whenCB(s);
47
- },
48
- butThen: async function (s) {
49
- return s;
50
- },
51
- afterEach: async function (store, ndx, artificer) {
52
- return {};
53
- },
54
- afterAll: (store, artificer) => {
55
- return;
56
- },
57
- });
109
+ return t;
58
110
  }
59
111
  });
112
+ return t;
60
113
  };
@@ -35,7 +35,6 @@ exports.testInterface = {
35
35
  return thenCB(s);
36
36
  },
37
37
  beforeEach: function (CComponent, props) {
38
- console.log("ASDASDx");
39
38
  let component;
40
39
  (0, react_test_renderer_1.act)(() => {
41
40
  component = react_test_renderer_1.default.create(react_1.default.createElement(CComponent, props, []));
@@ -3,55 +3,36 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ const web_1 = require("./PM/web");
6
7
  const core_js_1 = __importDefault(require("./lib/core.js"));
7
8
  const index_js_1 = require("./lib/index.js");
8
- // const remote = require("@electron/remote");
9
- // import remote from "@electron/remote";
10
- // const electron = require("electron");
11
- // const remote =
12
- // process.type === "browser" ? electron : require("@electron/remote");
13
9
  class WebTesteranto extends core_js_1.default {
14
10
  constructor(input, testSpecification, testImplementation, testResourceRequirement, testInterface) {
15
- super(input, testSpecification, testImplementation, testResourceRequirement, window.NodeWriter, testInterface);
16
- const testResourceArg = decodeURIComponent(new URLSearchParams(location.search).get("requesting") || "");
17
- try {
18
- const partialTestResource = JSON.parse(testResourceArg);
19
- this.receiveTestResourceConfig(this.testJobs[0], partialTestResource);
20
- }
21
- catch (e) {
22
- console.error(e);
23
- // process.exit(-1);
24
- }
25
- const requesting = new URLSearchParams(location.search).get("requesting");
26
- if (requesting) {
27
- const testResourceArg = decodeURIComponent(requesting);
28
- try {
29
- const partialTestResource = JSON.parse(testResourceArg);
30
- console.log("initial test resource", partialTestResource);
31
- this.receiveTestResourceConfig(this.testJobs[0], partialTestResource);
32
- }
33
- catch (e) {
34
- console.error(e);
35
- // process.exit(-1);
36
- }
37
- }
11
+ super(input, testSpecification, testImplementation, testResourceRequirement, testInterface);
38
12
  }
39
- async receiveTestResourceConfig(t, partialTestResource) {
40
- const { failed, artifacts, logPromise } = await t.receiveTestResourceConfig(partialTestResource, {
41
- browser: await window.browser,
42
- ipc: window.ipcRenderer,
43
- });
13
+ async receiveTestResourceConfig(partialTestResource) {
14
+ const t = partialTestResource; //JSON.parse(partialTestResource);
15
+ const pm = new web_1.PM_Web(t);
16
+ const { failed, artifacts, logPromise } = await this.testJobs[0].receiveTestResourceConfig(pm);
44
17
  console.log("test is done, awaiting test result write to fs");
45
- Promise.all([...artifacts, logPromise]).then(async () => {
46
- // we can't close the window becuase we might be taking a screenshot
47
- // window.close();
48
- // console.log(
49
- // "(window as any).browser",
50
- // JSON.stringify(await (window as any).browser)
51
- // );
52
- // var currentWindow = (await (window as any).browser).getCurrentWindow();
53
- // currentWindow.close();
54
- });
18
+ pm.customclose();
19
+ // Promise.all([...artifacts, logPromise]).then(async () => {
20
+ // console.log("hello world");
21
+ // pm.customclose();
22
+ // // we can't close the window becuase we might be taking a screenshot
23
+ // // window.close();
24
+ // // console.log(
25
+ // // "(window as any).browser",
26
+ // // JSON.stringify(await (window as any).browser)
27
+ // // );
28
+ // // var currentWindow = (await (window as any).browser).getCurrentWindow();
29
+ // // window.close();
30
+ // // var customWindow = window.open("", "_blank", "");
31
+ // // customWindow.close();
32
+ // // this.puppetMaster.browser.page
33
+ // // window["customclose"]();
34
+ // // console.log("goodbye", window["customclose"]());
35
+ // });
55
36
  }
56
37
  }
57
38
  exports.default = async (input, testSpecification, testImplementation, testInterface, testResourceRequirement = index_js_1.defaultTestResourceRequirement) => {
@@ -19,7 +19,6 @@ exports.default = (config, entryPoints) => {
19
19
  "features.test.ts",
20
20
  // "url",
21
21
  "react",
22
- "electron",
23
22
  "path",
24
23
  "fs",
25
24
  "stream",
@@ -34,6 +33,9 @@ exports.default = (config, entryPoints) => {
34
33
  "zlib",
35
34
  "crypto",
36
35
  "https",
36
+ "util",
37
+ "process",
38
+ "dns",
37
39
  ], platform: "browser", entryPoints: [...entryPoints], plugins: [
38
40
  ...(config.webPlugins || []),
39
41
  {
@@ -16,45 +16,114 @@ class BaseSuite {
16
16
  fails: this.fails,
17
17
  };
18
18
  }
19
- setup(s, artifactory, tr, utils) {
19
+ setup(s, artifactory, tr, pm) {
20
20
  return new Promise((res) => res(s));
21
21
  }
22
22
  assertThat(t) {
23
- // console.log("base assertThat")
24
23
  return t;
25
24
  }
26
- async run(input, testResourceConfiguration, artifactory, tLog, utils) {
25
+ afterAll(store, artifactory, pm) {
26
+ return store;
27
+ }
28
+ async run(input, testResourceConfiguration, artifactory, tLog, pm) {
27
29
  this.testResourceConfiguration = testResourceConfiguration;
28
- tLog("test resources: ", testResourceConfiguration);
30
+ tLog("test resources: ", JSON.stringify(testResourceConfiguration));
29
31
  const suiteArtifactory = (fPath, value) => artifactory(`suite-${this.index}-${this.name}/${fPath}`, value);
30
- const subject = await this.setup(input, suiteArtifactory, testResourceConfiguration, utils);
32
+ console.log("\nSuite:", this.index, this.name);
31
33
  tLog("\nSuite:", this.index, this.name);
32
- for (const k of Object.keys(this.givens)) {
33
- const giver = this.givens[k];
34
+ const sNdx = this.index;
35
+ const sName = this.name;
36
+ for (const [gNdx, g] of Object.entries(this.givens)) {
37
+ const subject = await this.setup(input, suiteArtifactory, testResourceConfiguration, pm);
38
+ const giver = this.givens[gNdx];
34
39
  try {
35
- this.store = await giver.give(subject, k, testResourceConfiguration, this.assertThat, suiteArtifactory, tLog, utils);
40
+ this.store = await giver.give(subject, gNdx, testResourceConfiguration, this.assertThat, suiteArtifactory, tLog, pm, sNdx);
36
41
  }
37
42
  catch (e) {
38
43
  console.error(e);
39
44
  this.fails.push(giver);
40
- return this;
45
+ // return this;
41
46
  }
42
47
  }
43
- for (const [ndx, thater] of this.checks.entries()) {
44
- await thater.check(subject, thater.name, testResourceConfiguration, this.assertThat, suiteArtifactory, tLog, utils);
48
+ const afterAllProxy = new Proxy(pm, {
49
+ get(target, prop, receiver) {
50
+ if (prop === "writeFileSync") {
51
+ return (fp, contents) => target[prop](`suite-${sNdx}/afterAll/${fp}`, contents);
52
+ }
53
+ if (prop === "browser") {
54
+ return new Proxy(target[prop], {
55
+ get(bTarget, bProp, bReceiver) {
56
+ if (bProp === "pages") {
57
+ return async () => {
58
+ return bTarget.pages().then((pages) => {
59
+ return pages.map((page) => {
60
+ return new Proxy(page, {
61
+ get(pTarget, pProp, pReciever) {
62
+ if (pProp === "screenshot") {
63
+ return async (x) => {
64
+ // console.log(
65
+ // "custom-screenshot-MARK-afterAllProxy",
66
+ // // arguments,
67
+ // // x,
68
+ // window["custom-screenshot"].toString()
69
+ // );
70
+ return await window["custom-screenshot"](Object.assign(Object.assign({}, x), { path: `${testResourceConfiguration.fs}/suite-${sNdx}/afterAll` +
71
+ "/" +
72
+ x.path }));
73
+ };
74
+ }
75
+ // else if (pProp === "mainFrame") {
76
+ // return () => target[pProp](...arguments);
77
+ // }
78
+ else {
79
+ return Reflect.get(...arguments);
80
+ }
81
+ },
82
+ });
83
+ });
84
+ });
85
+ // return (await target.pages()).map((page) => {
86
+ // return new Proxy(page, handler2);
87
+ // });
88
+ };
89
+ }
90
+ },
91
+ });
92
+ }
93
+ return Reflect.get(...arguments);
94
+ },
95
+ });
96
+ // pm.browser
97
+ try {
98
+ this.afterAll(this.store, artifactory, afterAllProxy);
45
99
  }
46
- // @TODO fix me
47
- for (const k of Object.keys(this.givens)) {
48
- const giver = this.givens[k];
49
- try {
50
- giver.afterAll(this.store, artifactory, utils);
51
- }
52
- catch (e) {
53
- console.error(e);
54
- this.fails.push(giver);
55
- return this;
56
- }
100
+ catch (e) {
101
+ console.error(e);
102
+ // this.fails.push(this);
103
+ // return this;
57
104
  }
105
+ // for (const [ndx, thater] of this.checks.entries()) {
106
+ // await thater.check(
107
+ // subject,
108
+ // thater.name,
109
+ // testResourceConfiguration,
110
+ // this.assertThat,
111
+ // suiteArtifactory,
112
+ // tLog,
113
+ // pm
114
+ // );
115
+ // }
116
+ // @TODO fix me
117
+ // for (const k of Object.keys(this.givens)) {
118
+ // const giver = this.givens[k];
119
+ // try {
120
+ // giver.afterAll(this.store, artifactory, pm);
121
+ // } catch (e) {
122
+ // console.error(e);
123
+ // this.fails.push(giver);
124
+ // return this;
125
+ // }
126
+ // }
58
127
  ////////////////
59
128
  return this;
60
129
  }
@@ -72,32 +141,39 @@ class BaseGiven {
72
141
  beforeAll(store, artifactory) {
73
142
  return store;
74
143
  }
75
- afterAll(store, artifactory, utils) {
76
- return store;
77
- }
78
144
  toObj() {
79
145
  return {
80
146
  name: this.name,
81
147
  whens: this.whens.map((w) => w.toObj()),
82
148
  thens: this.thens.map((t) => t.toObj()),
83
149
  error: this.error ? [this.error, this.error.stack] : null,
150
+ // fail: this.fail ? [this.fail] : false,
84
151
  features: this.features,
85
152
  };
86
153
  }
87
- async afterEach(store, key, artifactory, utils) {
154
+ async afterEach(store, key, artifactory, pm) {
88
155
  return store;
89
156
  }
90
- async give(subject, key, testResourceConfiguration, tester, artifactory, tLog, utils) {
157
+ async give(subject, key, testResourceConfiguration, tester, artifactory, tLog, pm, suiteNdx) {
91
158
  tLog(`\n Given: ${this.name}`);
92
159
  const givenArtifactory = (fPath, value) => artifactory(`given-${key}/${fPath}`, value);
93
160
  try {
94
- this.store = await this.givenThat(subject, testResourceConfiguration, givenArtifactory, this.givenCB);
95
161
  // tLog(`\n Given this.store`, this.store);
96
- for (const whenStep of this.whens) {
97
- await whenStep.test(this.store, testResourceConfiguration, tLog, utils);
162
+ const beforeEachProxy = new Proxy(pm, {
163
+ get(target, prop, receiver) {
164
+ if (prop === "writeFileSync") {
165
+ console.log("beforeEachProx", arguments, target[prop]);
166
+ return (fp, contents) => target[prop](`suite-${suiteNdx}/given-${key}/when/beforeEach/${fp}`, contents);
167
+ }
168
+ return Reflect.get(...arguments);
169
+ },
170
+ });
171
+ this.store = await this.givenThat(subject, testResourceConfiguration, givenArtifactory, this.givenCB, beforeEachProxy);
172
+ for (const [whenNdx, whenStep] of this.whens.entries()) {
173
+ await whenStep.test(this.store, testResourceConfiguration, tLog, pm, `suite-${suiteNdx}/given-${key}/when/${whenNdx}`);
98
174
  }
99
175
  for (const thenStep of this.thens) {
100
- const t = await thenStep.test(this.store, testResourceConfiguration, tLog, utils);
176
+ const t = await thenStep.test(this.store, testResourceConfiguration, tLog, pm);
101
177
  tester(t);
102
178
  }
103
179
  }
@@ -109,7 +185,66 @@ class BaseGiven {
109
185
  }
110
186
  finally {
111
187
  try {
112
- await this.afterEach(this.store, key, givenArtifactory, utils);
188
+ // const afterEachProxy = new Proxy(pm, {
189
+ // get(target, prop, receiver) {
190
+ // if (prop === "writeFileSync") {
191
+ // console.log("afterEachProxy", arguments, target[prop]);
192
+ // return (fp, contents) =>
193
+ // // target[prop](`${key}/andWhen/${fp}`, contents);
194
+ // target[prop](`${key}/afterEach/${fp}`, contents);
195
+ // }
196
+ // return Reflect.get(...arguments);
197
+ // },
198
+ // });
199
+ // await this.afterEach(this.store, key, givenArtifactory, afterEachProxy);
200
+ // await this.afterEach(this.store, key, givenArtifactory, pm);
201
+ const afterEachProxy = new Proxy(pm, {
202
+ get(target, prop, receiver) {
203
+ if (prop === "writeFileSync") {
204
+ return (fp, contents) => target[prop](`suite-${suiteNdx}/given-${key}/afterAll/${fp}`, contents);
205
+ }
206
+ if (prop === "browser") {
207
+ return new Proxy(target[prop], {
208
+ get(bTarget, bProp, bReceiver) {
209
+ if (bProp === "pages") {
210
+ return async () => {
211
+ return bTarget.pages().then((pages) => {
212
+ return pages.map((page) => {
213
+ return new Proxy(page, {
214
+ get(pTarget, pProp, pReciever) {
215
+ if (pProp === "screenshot") {
216
+ return async (x) => {
217
+ // console.log(
218
+ // "custom-screenshot-MARK-afterEachProxy",
219
+ // window["custom-screenshot"].toString()
220
+ // );
221
+ return await window["custom-screenshot"](Object.assign(Object.assign({}, x), { path: `${testResourceConfiguration.fs}/suite-${suiteNdx}/given-${key}/afterEach` +
222
+ "/" +
223
+ x.path }));
224
+ };
225
+ }
226
+ // else if (pProp === "mainFrame") {
227
+ // return () => target[pProp](...arguments);
228
+ // }
229
+ else {
230
+ return Reflect.get(...arguments);
231
+ }
232
+ },
233
+ });
234
+ });
235
+ });
236
+ // return (await target.pages()).map((page) => {
237
+ // return new Proxy(page, handler2);
238
+ // });
239
+ };
240
+ }
241
+ },
242
+ });
243
+ }
244
+ return Reflect.get(...arguments);
245
+ },
246
+ });
247
+ await this.afterEach(this.store, key, givenArtifactory, afterEachProxy);
113
248
  }
114
249
  catch (e) {
115
250
  console.error("afterEach failed! no error will be recorded!", e);
@@ -130,10 +265,22 @@ class BaseWhen {
130
265
  error: this.error,
131
266
  };
132
267
  }
133
- async test(store, testResourceConfiguration, tLog, utils) {
268
+ async test(store, testResourceConfiguration, tLog, pm, key) {
134
269
  tLog(" When:", this.name);
270
+ const name = this.name;
271
+ const andWhenProxy = new Proxy(pm, {
272
+ get(target, prop, receiver) {
273
+ if (prop === "writeFileSync") {
274
+ console.log("andWhenProxy", arguments, target[prop]);
275
+ return (fp, contents) =>
276
+ // target[prop](`${key}/andWhen/${fp}`, contents);
277
+ target[prop](`${key}/andWhen/${fp}`, contents);
278
+ }
279
+ return Reflect.get(...arguments);
280
+ },
281
+ });
135
282
  try {
136
- return await this.andWhen(store, this.whenCB, testResourceConfiguration);
283
+ return await this.andWhen(store, this.whenCB, testResourceConfiguration, andWhenProxy);
137
284
  }
138
285
  catch (e) {
139
286
  this.error = true;
@@ -146,6 +293,7 @@ class BaseThen {
146
293
  constructor(name, thenCB) {
147
294
  this.name = name;
148
295
  this.thenCB = thenCB;
296
+ this.error = false;
149
297
  }
150
298
  toObj() {
151
299
  return {
@@ -153,7 +301,7 @@ class BaseThen {
153
301
  error: this.error,
154
302
  };
155
303
  }
156
- async test(store, testResourceConfiguration, tLog, utils) {
304
+ async test(store, testResourceConfiguration, tLog, pm) {
157
305
  tLog(" Then:", this.name);
158
306
  try {
159
307
  const x = await this.butThen(store, this.thenCB, testResourceConfiguration);
@@ -161,7 +309,7 @@ class BaseThen {
161
309
  }
162
310
  catch (e) {
163
311
  console.log("test failed", e);
164
- this.error = true;
312
+ this.error = e.message;
165
313
  throw e;
166
314
  }
167
315
  }
@@ -175,25 +323,25 @@ class BaseCheck {
175
323
  this.whens = whens;
176
324
  this.thens = thens;
177
325
  }
178
- async afterEach(store, key, cb, utils) {
326
+ async afterEach(store, key, cb, pm) {
179
327
  return;
180
328
  }
181
- async check(subject, key, testResourceConfiguration, tester, artifactory, tLog, utils) {
329
+ async check(subject, key, testResourceConfiguration, tester, artifactory, tLog, pm) {
182
330
  tLog(`\n Check: ${this.name}`);
183
331
  const store = await this.checkThat(subject, testResourceConfiguration, artifactory);
184
332
  await this.checkCB(Object.entries(this.whens).reduce((a, [key, when]) => {
185
333
  a[key] = async (payload) => {
186
- return await when(payload, testResourceConfiguration).test(store, testResourceConfiguration, tLog, utils);
334
+ return await when(payload, testResourceConfiguration).test(store, testResourceConfiguration, tLog, pm, "x");
187
335
  };
188
336
  return a;
189
337
  }, {}), Object.entries(this.thens).reduce((a, [key, then]) => {
190
338
  a[key] = async (payload) => {
191
- const t = await then(payload, testResourceConfiguration).test(store, testResourceConfiguration, tLog, utils);
339
+ const t = await then(payload, testResourceConfiguration).test(store, testResourceConfiguration, tLog, pm);
192
340
  tester(t);
193
341
  };
194
342
  return a;
195
343
  }, {}));
196
- await this.afterEach(store, key, () => { }, utils);
344
+ await this.afterEach(store, key, () => { }, pm);
197
345
  return;
198
346
  }
199
347
  }