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
@@ -1,41 +1,28 @@
1
+ import { IBaseTest } from "../Types";
2
+
1
3
  import { ITTestResourceConfiguration, ITestArtifactory, ITLog } from ".";
2
- import { IBaseTest, IUtils } from "../Types";
4
+ import { PM } from "../PM/index.js";
5
+ // import { IUtils } from "./types";
3
6
 
4
- export type IGivens<
5
- ITestShape extends IBaseTest
6
- > = Record<
7
+ export type IGivens<ITestShape extends IBaseTest> = Record<
7
8
  string,
8
- BaseGiven<
9
- ITestShape
10
- >
9
+ BaseGiven<ITestShape>
11
10
  >;
12
11
 
13
- export abstract class BaseSuite<
14
- ITestShape extends IBaseTest
15
- > {
12
+ export abstract class BaseSuite<ITestShape extends IBaseTest> {
16
13
  name: string;
17
- givens: IGivens<
18
- ITestShape
19
- >;
20
- checks: BaseCheck<
21
- ITestShape
22
- >[];
23
- store: ITestShape['istore'];
24
- fails: BaseGiven<
25
- ITestShape
26
- >[];
14
+ givens: IGivens<ITestShape>;
15
+ checks: BaseCheck<ITestShape>[];
16
+ store: ITestShape["istore"];
17
+ fails: BaseGiven<ITestShape>[];
27
18
  testResourceConfiguration: ITTestResourceConfiguration;
28
19
  index: number;
29
20
 
30
21
  constructor(
31
22
  name: string,
32
23
  index: number,
33
- givens: IGivens<
34
- ITestShape
35
- > = {},
36
- checks: BaseCheck<
37
- ITestShape
38
- >[] = []
24
+ givens: IGivens<ITestShape> = {},
25
+ checks: BaseCheck<ITestShape>[] = []
39
26
  ) {
40
27
  this.name = name;
41
28
  this.index = index;
@@ -53,114 +40,180 @@ export abstract class BaseSuite<
53
40
  }
54
41
 
55
42
  setup(
56
- s: ITestShape['iinput'],
43
+ s: ITestShape["iinput"],
57
44
  artifactory: ITestArtifactory,
58
45
  tr: ITTestResourceConfiguration,
59
- utils: IUtils
60
- ): Promise<ITestShape['isubject']> {
61
- return new Promise((res) => res(s as unknown as ITestShape['isubject']));
46
+ pm: PM
47
+ ): Promise<ITestShape["isubject"]> {
48
+ return new Promise((res) => res(s as unknown as ITestShape["isubject"]));
62
49
  }
63
50
 
64
- assertThat(t: ITestShape['then']): unknown {
65
- // console.log("base assertThat")
51
+ assertThat(t: ITestShape["then"]): unknown {
66
52
  return t;
67
53
  }
68
54
 
55
+ afterAll(store: ITestShape["istore"], artifactory: ITestArtifactory, pm: PM) {
56
+ return store;
57
+ }
58
+
69
59
  async run(
70
- input: ITestShape['iinput'],
60
+ input: ITestShape["iinput"],
71
61
  testResourceConfiguration: ITTestResourceConfiguration,
72
- artifactory: (
73
- fPath: string,
74
- value: unknown
75
- ) => void,
62
+ artifactory: (fPath: string, value: unknown) => void,
76
63
  tLog: (...string) => void,
77
- utils: IUtils
78
- ): Promise<
79
- BaseSuite<
80
- ITestShape
81
- >
82
- > {
64
+ pm: PM
65
+ ): Promise<BaseSuite<ITestShape>> {
83
66
  this.testResourceConfiguration = testResourceConfiguration;
84
- tLog("test resources: ", testResourceConfiguration);
67
+ tLog("test resources: ", JSON.stringify(testResourceConfiguration));
85
68
 
86
69
  const suiteArtifactory = (fPath: string, value: unknown) =>
87
- artifactory(`suite-${this.index}-${this.name}/${fPath}`, value)
88
- const subject = await this.setup(
89
- input,
90
- suiteArtifactory,
91
- testResourceConfiguration,
92
- utils
93
- );
70
+ artifactory(`suite-${this.index}-${this.name}/${fPath}`, value);
94
71
 
72
+ console.log("\nSuite:", this.index, this.name);
95
73
  tLog("\nSuite:", this.index, this.name);
96
- for (const k of Object.keys(this.givens)) {
97
- const giver = this.givens[k];
74
+ const sNdx = this.index;
75
+ const sName = this.name;
76
+
77
+ for (const [gNdx, g] of Object.entries(this.givens)) {
78
+ const subject = await this.setup(
79
+ input,
80
+ suiteArtifactory,
81
+ testResourceConfiguration,
82
+ pm
83
+ );
84
+
85
+ const giver = this.givens[gNdx];
98
86
  try {
99
87
  this.store = await giver.give(
100
88
  subject,
101
- k,
89
+ gNdx,
102
90
  testResourceConfiguration,
103
91
  this.assertThat,
104
92
  suiteArtifactory,
105
93
  tLog,
106
- utils
94
+ pm,
95
+ sNdx
107
96
  );
108
97
  } catch (e) {
109
98
  console.error(e);
110
99
  this.fails.push(giver);
111
- return this;
100
+ // return this;
112
101
  }
113
102
  }
114
- for (const [ndx, thater] of this.checks.entries()) {
115
- await thater.check(
116
- subject,
117
- thater.name,
118
- testResourceConfiguration,
119
- this.assertThat,
120
- suiteArtifactory,
121
- tLog,
122
- utils
123
- );
103
+
104
+ const afterAllProxy = new Proxy(pm, {
105
+ get(target, prop, receiver) {
106
+ if (prop === "writeFileSync") {
107
+ return (fp, contents) =>
108
+ target[prop](`suite-${sNdx}/afterAll/${fp}`, contents);
109
+ }
110
+
111
+ if (prop === "browser") {
112
+ return new Proxy(target[prop], {
113
+ get(bTarget, bProp, bReceiver) {
114
+ if (bProp === "pages") {
115
+ return async () => {
116
+ return bTarget.pages().then((pages) => {
117
+ return pages.map((page) => {
118
+ return new Proxy(page, {
119
+ get(pTarget, pProp, pReciever) {
120
+ if (pProp === "screenshot") {
121
+ return async (x) => {
122
+ // console.log(
123
+ // "custom-screenshot-MARK-afterAllProxy",
124
+ // // arguments,
125
+ // // x,
126
+ // window["custom-screenshot"].toString()
127
+ // );
128
+ return await window["custom-screenshot"]({
129
+ ...x,
130
+ path:
131
+ `${testResourceConfiguration.fs}/suite-${sNdx}/afterAll` +
132
+ "/" +
133
+ x.path,
134
+ });
135
+ };
136
+ }
137
+ // else if (pProp === "mainFrame") {
138
+ // return () => target[pProp](...arguments);
139
+ // }
140
+ else {
141
+ return Reflect.get(...arguments);
142
+ }
143
+ },
144
+ });
145
+ });
146
+ });
147
+ // return (await target.pages()).map((page) => {
148
+ // return new Proxy(page, handler2);
149
+ // });
150
+ };
151
+ }
152
+ },
153
+ });
154
+ }
155
+
156
+ return Reflect.get(...arguments);
157
+ },
158
+ });
159
+
160
+ // pm.browser
161
+ try {
162
+ this.afterAll(this.store, artifactory, afterAllProxy);
163
+ } catch (e) {
164
+ console.error(e);
165
+ // this.fails.push(this);
166
+ // return this;
124
167
  }
125
168
 
169
+ // for (const [ndx, thater] of this.checks.entries()) {
170
+ // await thater.check(
171
+ // subject,
172
+ // thater.name,
173
+ // testResourceConfiguration,
174
+ // this.assertThat,
175
+ // suiteArtifactory,
176
+ // tLog,
177
+ // pm
178
+ // );
179
+ // }
180
+
126
181
  // @TODO fix me
127
- for (const k of Object.keys(this.givens)) {
128
- const giver = this.givens[k];
129
- giver.afterAll(this.store, artifactory, utils);
130
- }
182
+ // for (const k of Object.keys(this.givens)) {
183
+ // const giver = this.givens[k];
184
+
185
+ // try {
186
+ // giver.afterAll(this.store, artifactory, pm);
187
+ // } catch (e) {
188
+ // console.error(e);
189
+ // this.fails.push(giver);
190
+ // return this;
191
+ // }
192
+ // }
131
193
  ////////////////
132
194
 
133
195
  return this;
134
196
  }
135
197
  }
136
198
 
137
- export abstract class BaseGiven<
138
- ITestShape extends IBaseTest
139
- > {
199
+ export abstract class BaseGiven<ITestShape extends IBaseTest> {
140
200
  name: string;
141
201
  features: string[];
142
- whens: BaseWhen<
143
- ITestShape
144
- >[];
145
- thens: BaseThen<
146
- ITestShape
147
- >[];
202
+ whens: BaseWhen<ITestShape>[];
203
+ thens: BaseThen<ITestShape>[];
148
204
  error: Error;
149
- store: ITestShape['istore'];
205
+ fail: any;
206
+ store: ITestShape["istore"];
150
207
  recommendedFsPath: string;
151
- givenCB: ITestShape['given'];
208
+ givenCB: ITestShape["given"];
152
209
  initialValues: any;
153
210
 
154
211
  constructor(
155
212
  name: string,
156
213
  features: string[],
157
- whens: BaseWhen<
158
- ITestShape
159
- >[],
160
- thens: BaseThen<
161
- ITestShape
162
- >[],
163
- givenCB: ITestShape['given'],
214
+ whens: BaseWhen<ITestShape>[],
215
+ thens: BaseThen<ITestShape>[],
216
+ givenCB: ITestShape["given"],
164
217
  initialValues: any
165
218
  ) {
166
219
  this.name = name;
@@ -171,19 +224,7 @@ export abstract class BaseGiven<
171
224
  this.initialValues = initialValues;
172
225
  }
173
226
 
174
- beforeAll(
175
- store: ITestShape['istore'],
176
- artifactory: ITestArtifactory,
177
-
178
- ) {
179
- return store;
180
- }
181
-
182
- afterAll(
183
- store: ITestShape['istore'],
184
- artifactory: ITestArtifactory,
185
- utils: IUtils
186
- ) {
227
+ beforeAll(store: ITestShape["istore"], artifactory: ITestArtifactory) {
187
228
  return store;
188
229
  }
189
230
 
@@ -193,61 +234,84 @@ export abstract class BaseGiven<
193
234
  whens: this.whens.map((w) => w.toObj()),
194
235
  thens: this.thens.map((t) => t.toObj()),
195
236
  error: this.error ? [this.error, this.error.stack] : null,
237
+ // fail: this.fail ? [this.fail] : false,
196
238
  features: this.features,
197
239
  };
198
240
  }
199
241
 
200
242
  abstract givenThat(
201
- subject: ITestShape['isubject'],
243
+ subject: ITestShape["isubject"],
202
244
  testResourceConfiguration,
203
245
  artifactory: ITestArtifactory,
204
- givenCB: ITestShape['given']
205
- ): Promise<ITestShape['istore']>;
246
+ givenCB: ITestShape["given"],
247
+ pm: PM
248
+ ): Promise<ITestShape["istore"]>;
206
249
 
207
250
  async afterEach(
208
- store: ITestShape['istore'],
251
+ store: ITestShape["istore"],
209
252
  key: string,
210
- artifactory: ITestArtifactory
253
+ artifactory: ITestArtifactory,
254
+ pm: PM
211
255
  ): Promise<unknown> {
212
256
  return store;
213
257
  }
214
258
 
215
259
  async give(
216
- subject: ITestShape['isubject'],
260
+ subject: ITestShape["isubject"],
217
261
  key: string,
218
262
  testResourceConfiguration,
219
- tester,
263
+ tester: (t: Awaited<ITestShape["then"]> | undefined) => boolean,
220
264
  artifactory: ITestArtifactory,
221
265
  tLog: ITLog,
222
- utils: IUtils
266
+ pm: PM,
267
+ suiteNdx: number
223
268
  ) {
224
269
  tLog(`\n Given: ${this.name}`);
225
270
 
226
271
  const givenArtifactory = (fPath: string, value: unknown) =>
227
- artifactory(`given-${key}/${fPath}`, value)
272
+ artifactory(`given-${key}/${fPath}`, value);
228
273
  try {
274
+ // tLog(`\n Given this.store`, this.store);
275
+
276
+ const beforeEachProxy = new Proxy(pm, {
277
+ get(target, prop, receiver) {
278
+ if (prop === "writeFileSync") {
279
+ console.log("beforeEachProx", arguments, target[prop]);
280
+ return (fp, contents) =>
281
+ target[prop](
282
+ `suite-${suiteNdx}/given-${key}/when/beforeEach/${fp}`,
283
+ contents
284
+ );
285
+ }
286
+
287
+ return Reflect.get(...arguments);
288
+ },
289
+ });
290
+
229
291
  this.store = await this.givenThat(
230
292
  subject,
231
293
  testResourceConfiguration,
232
294
  givenArtifactory,
233
- this.givenCB
295
+ this.givenCB,
296
+ beforeEachProxy
234
297
  );
235
298
 
236
- // tLog(`\n Given this.store`, this.store);
237
- for (const whenStep of this.whens) {
299
+ for (const [whenNdx, whenStep] of this.whens.entries()) {
238
300
  await whenStep.test(
239
301
  this.store,
240
302
  testResourceConfiguration,
241
303
  tLog,
242
- utils
304
+ pm,
305
+ `suite-${suiteNdx}/given-${key}/when/${whenNdx}`
243
306
  );
244
307
  }
308
+
245
309
  for (const thenStep of this.thens) {
246
310
  const t = await thenStep.test(
247
311
  this.store,
248
312
  testResourceConfiguration,
249
313
  tLog,
250
- utils
314
+ pm
251
315
  );
252
316
  tester(t);
253
317
  }
@@ -258,7 +322,82 @@ export abstract class BaseGiven<
258
322
  // throw e;
259
323
  } finally {
260
324
  try {
261
- await this.afterEach(this.store, key, givenArtifactory);
325
+ // const afterEachProxy = new Proxy(pm, {
326
+ // get(target, prop, receiver) {
327
+ // if (prop === "writeFileSync") {
328
+ // console.log("afterEachProxy", arguments, target[prop]);
329
+ // return (fp, contents) =>
330
+ // // target[prop](`${key}/andWhen/${fp}`, contents);
331
+ // target[prop](`${key}/afterEach/${fp}`, contents);
332
+ // }
333
+
334
+ // return Reflect.get(...arguments);
335
+ // },
336
+ // });
337
+
338
+ // await this.afterEach(this.store, key, givenArtifactory, afterEachProxy);
339
+
340
+ // await this.afterEach(this.store, key, givenArtifactory, pm);
341
+
342
+ const afterEachProxy = new Proxy(pm, {
343
+ get(target, prop, receiver) {
344
+ if (prop === "writeFileSync") {
345
+ return (fp, contents) =>
346
+ target[prop](
347
+ `suite-${suiteNdx}/given-${key}/afterAll/${fp}`,
348
+ contents
349
+ );
350
+ }
351
+
352
+ if (prop === "browser") {
353
+ return new Proxy(target[prop], {
354
+ get(bTarget, bProp, bReceiver) {
355
+ if (bProp === "pages") {
356
+ return async () => {
357
+ return bTarget.pages().then((pages) => {
358
+ return pages.map((page) => {
359
+ return new Proxy(page, {
360
+ get(pTarget, pProp, pReciever) {
361
+ if (pProp === "screenshot") {
362
+ return async (x) => {
363
+ // console.log(
364
+ // "custom-screenshot-MARK-afterEachProxy",
365
+ // window["custom-screenshot"].toString()
366
+ // );
367
+
368
+ return await window["custom-screenshot"]({
369
+ ...x,
370
+ path:
371
+ `${testResourceConfiguration.fs}/suite-${suiteNdx}/given-${key}/afterEach` +
372
+ "/" +
373
+ x.path,
374
+ });
375
+ };
376
+ }
377
+ // else if (pProp === "mainFrame") {
378
+ // return () => target[pProp](...arguments);
379
+ // }
380
+ else {
381
+ return Reflect.get(...arguments);
382
+ }
383
+ },
384
+ });
385
+ });
386
+ });
387
+ // return (await target.pages()).map((page) => {
388
+ // return new Proxy(page, handler2);
389
+ // });
390
+ };
391
+ }
392
+ },
393
+ });
394
+ }
395
+
396
+ return Reflect.get(...arguments);
397
+ },
398
+ });
399
+
400
+ await this.afterEach(this.store, key, givenArtifactory, afterEachProxy);
262
401
  } catch (e) {
263
402
  console.error("afterEach failed! no error will be recorded!", e);
264
403
  }
@@ -267,24 +406,24 @@ export abstract class BaseGiven<
267
406
  }
268
407
  }
269
408
 
270
- export abstract class BaseWhen<
271
- ITestShape extends IBaseTest
272
- > {
409
+ export abstract class BaseWhen<ITestShape extends IBaseTest> {
273
410
  public name: string;
274
- whenCB: (x: ITestShape['iselection']) => ITestShape['then'];
411
+ whenCB: (x: ITestShape["iselection"]) => ITestShape["then"];
275
412
  error: boolean;
276
413
 
277
414
  constructor(
278
415
  name: string,
279
- whenCB: (xyz: ITestShape['iselection']) => ITestShape['then']) {
416
+ whenCB: (xyz: ITestShape["iselection"]) => ITestShape["then"]
417
+ ) {
280
418
  this.name = name;
281
419
  this.whenCB = whenCB;
282
420
  }
283
421
 
284
422
  abstract andWhen(
285
- store: ITestShape['istore'],
286
- whenCB: (x: ITestShape['iselection']) => ITestShape['then'],
287
- testResource
423
+ store: ITestShape["istore"],
424
+ whenCB: (x: ITestShape["iselection"]) => ITestShape["then"],
425
+ testResource,
426
+ pm: PM
288
427
  );
289
428
 
290
429
  toObj() {
@@ -295,17 +434,34 @@ export abstract class BaseWhen<
295
434
  }
296
435
 
297
436
  async test(
298
- store: ITestShape['istore'],
437
+ store: ITestShape["istore"],
299
438
  testResourceConfiguration,
300
439
  tLog: ITLog,
301
- utils: IUtils
440
+ pm: PM,
441
+ key: string
302
442
  ) {
303
443
  tLog(" When:", this.name);
444
+
445
+ const name = this.name;
446
+ const andWhenProxy = new Proxy(pm, {
447
+ get(target, prop, receiver) {
448
+ if (prop === "writeFileSync") {
449
+ console.log("andWhenProxy", arguments, target[prop]);
450
+ return (fp, contents) =>
451
+ // target[prop](`${key}/andWhen/${fp}`, contents);
452
+ target[prop](`${key}/andWhen/${fp}`, contents);
453
+ }
454
+
455
+ return Reflect.get(...arguments);
456
+ },
457
+ });
458
+
304
459
  try {
305
460
  return await this.andWhen(
306
461
  store,
307
462
  this.whenCB,
308
- testResourceConfiguration
463
+ testResourceConfiguration,
464
+ andWhenProxy
309
465
  );
310
466
  } catch (e) {
311
467
  this.error = true;
@@ -314,16 +470,18 @@ export abstract class BaseWhen<
314
470
  }
315
471
  }
316
472
 
317
- export abstract class BaseThen<
318
- ITestShape extends IBaseTest
319
- > {
473
+ export abstract class BaseThen<ITestShape extends IBaseTest> {
320
474
  public name: string;
321
- thenCB: (storeState: ITestShape['iselection']) => ITestShape['then'];
475
+ thenCB: (storeState: ITestShape["iselection"]) => ITestShape["then"];
322
476
  error: boolean;
323
477
 
324
- constructor(name: string, thenCB: (val: ITestShape['iselection']) => ITestShape['then']) {
478
+ constructor(
479
+ name: string,
480
+ thenCB: (val: ITestShape["iselection"]) => ITestShape["then"]
481
+ ) {
325
482
  this.name = name;
326
483
  this.thenCB = thenCB;
484
+ this.error = false;
327
485
  }
328
486
 
329
487
  toObj() {
@@ -334,54 +492,42 @@ export abstract class BaseThen<
334
492
  }
335
493
 
336
494
  abstract butThen(
337
- store: ITestShape['istore'],
495
+ store: ITestShape["istore"],
338
496
  thenCB,
339
497
  testResourceConfiguration?
340
- ): Promise<ITestShape['iselection']>;
498
+ ): Promise<ITestShape["iselection"]>;
341
499
 
342
500
  async test(
343
- store: ITestShape['istore'],
501
+ store: ITestShape["istore"],
344
502
  testResourceConfiguration,
345
503
  tLog: ITLog,
346
- utils: IUtils
347
- ): Promise<ITestShape['then'] | undefined> {
504
+ pm: PM
505
+ ): Promise<ITestShape["then"] | undefined> {
348
506
  tLog(" Then:", this.name);
349
507
  try {
350
- const x = (await this.butThen(
508
+ const x = await this.butThen(
351
509
  store,
352
510
  this.thenCB,
353
511
  testResourceConfiguration
354
- ));
512
+ );
355
513
  return x;
356
514
  } catch (e) {
357
515
  console.log("test failed", e);
358
- this.error = true;
516
+ this.error = e.message;
359
517
  throw e;
360
518
  }
361
519
  }
362
520
  }
363
521
 
364
- export abstract class BaseCheck<
365
- ITestShape extends IBaseTest
366
- > {
522
+ export abstract class BaseCheck<ITestShape extends IBaseTest> {
367
523
  name: string;
368
524
  features: string[];
369
525
  checkCB: (whens, thens) => any;
370
526
  whens: {
371
- [K in keyof ITestShape["whens"]]: (
372
- p,
373
- tc
374
- ) => BaseWhen<
375
- ITestShape
376
- >;
527
+ [K in keyof ITestShape["whens"]]: (p, tc) => BaseWhen<ITestShape>;
377
528
  };
378
529
  thens: {
379
- [K in keyof ITestShape["thens"]]: (
380
- p,
381
- tc
382
- ) => BaseThen<
383
- ITestShape
384
- >;
530
+ [K in keyof ITestShape["thens"]]: (p, tc) => BaseThen<ITestShape>;
385
531
  };
386
532
 
387
533
  constructor(
@@ -399,27 +545,28 @@ export abstract class BaseCheck<
399
545
  }
400
546
 
401
547
  abstract checkThat(
402
- subject: ITestShape['isubject'],
548
+ subject: ITestShape["isubject"],
403
549
  testResourceConfiguration,
404
550
  artifactory: ITestArtifactory
405
- ): Promise<ITestShape['istore']>;
551
+ ): Promise<ITestShape["istore"]>;
406
552
 
407
553
  async afterEach(
408
- store: ITestShape['istore'],
554
+ store: ITestShape["istore"],
409
555
  key: string,
410
- cb?
556
+ cb,
557
+ pm: PM
411
558
  ): Promise<unknown> {
412
559
  return;
413
560
  }
414
561
 
415
562
  async check(
416
- subject: ITestShape['isubject'],
563
+ subject: ITestShape["isubject"],
417
564
  key: string,
418
565
  testResourceConfiguration,
419
566
  tester,
420
567
  artifactory: ITestArtifactory,
421
568
  tLog: ITLog,
422
- utils: IUtils
569
+ pm: PM
423
570
  ) {
424
571
  tLog(`\n Check: ${this.name}`);
425
572
  const store = await this.checkThat(
@@ -434,7 +581,8 @@ export abstract class BaseCheck<
434
581
  store,
435
582
  testResourceConfiguration,
436
583
  tLog,
437
- utils
584
+ pm,
585
+ "x"
438
586
  );
439
587
  };
440
588
  return a;
@@ -445,7 +593,7 @@ export abstract class BaseCheck<
445
593
  store,
446
594
  testResourceConfiguration,
447
595
  tLog,
448
- utils
596
+ pm
449
597
  );
450
598
  tester(t);
451
599
  };
@@ -453,7 +601,7 @@ export abstract class BaseCheck<
453
601
  }, {})
454
602
  );
455
603
 
456
- await this.afterEach(store, key);
604
+ await this.afterEach(store, key, () => {}, pm);
457
605
  return;
458
606
  }
459
607
  }