testeranto 0.62.0 → 0.70.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 (151) hide show
  1. package/README.md +42 -21
  2. package/dist/cjs-shim.js +2 -2
  3. package/dist/common/Node.js +7 -24
  4. package/dist/common/NodeWriter.js +7 -9
  5. package/dist/common/Project.js +103 -266
  6. package/dist/common/SubPackages/puppeteer.js +1 -1
  7. package/dist/common/SubPackages/react-dom/component/web.js +1 -1
  8. package/dist/common/SubPackages/react-dom/jsx/web.js +15 -7
  9. package/dist/common/SubPackages/react-test-renderer/MemoExoticComponent/node.js +1 -1
  10. package/dist/common/SubPackages/react-test-renderer/component/index.js +0 -1
  11. package/dist/common/SubPackages/react-test-renderer/fc/web.js +1 -1
  12. package/dist/common/SubPackages/react-test-renderer/jsx/index.js +1 -2
  13. package/dist/common/SubPackages/react-test-renderer/jsx/web.js +1 -1
  14. package/dist/common/SubPackages/react-test-renderer/jsx-promised/index.js +1 -1
  15. package/dist/common/Types.js +2 -32
  16. package/dist/common/Web.js +25 -18
  17. package/dist/common/electron.js +177 -107
  18. package/dist/common/esbuildConfigs/index.js +5 -5
  19. package/dist/common/esbuildConfigs/node.js +17 -15
  20. package/dist/common/esbuildConfigs/report.js +12 -47
  21. package/dist/common/esbuildConfigs/tests.js +0 -1
  22. package/dist/common/esbuildConfigs/web.js +14 -11
  23. package/dist/common/lib/abstractBase.js +13 -6
  24. package/dist/common/lib/basebuilder.js +11 -11
  25. package/dist/common/lib/classBuilder.js +2 -3
  26. package/dist/common/lib/core.js +37 -8
  27. package/dist/common/lib/index.js +10 -8
  28. package/dist/common/lib/types.js +2 -0
  29. package/dist/common/preload.js +15 -25
  30. package/dist/common/puppeteerConfiger.js +24 -0
  31. package/dist/common/tsconfig.common.tsbuildinfo +1 -1
  32. package/dist/module/Node.js +7 -24
  33. package/dist/module/NodeWriter.js +7 -9
  34. package/dist/module/Project.js +104 -267
  35. package/dist/module/SubPackages/puppeteer.js +1 -1
  36. package/dist/module/SubPackages/react/jsx/web.js +1 -1
  37. package/dist/module/SubPackages/react-dom/component/node.js +2 -2
  38. package/dist/module/SubPackages/react-dom/component/web.js +1 -1
  39. package/dist/module/SubPackages/react-dom/jsx/web.js +17 -9
  40. package/dist/module/SubPackages/react-test-renderer/MemoExoticComponent/node.js +1 -1
  41. package/dist/module/SubPackages/react-test-renderer/component/index.js +0 -1
  42. package/dist/module/SubPackages/react-test-renderer/fc/web.js +1 -1
  43. package/dist/module/SubPackages/react-test-renderer/jsx/index.js +1 -2
  44. package/dist/module/SubPackages/react-test-renderer/jsx/web.js +1 -1
  45. package/dist/module/SubPackages/react-test-renderer/jsx-promised/index.js +1 -1
  46. package/dist/module/Types.js +3 -30
  47. package/dist/module/Web.js +26 -19
  48. package/dist/module/electron.js +179 -109
  49. package/dist/module/esbuildConfigs/index.js +5 -5
  50. package/dist/module/esbuildConfigs/node.js +17 -15
  51. package/dist/module/esbuildConfigs/report.js +11 -48
  52. package/dist/module/esbuildConfigs/tests.js +0 -1
  53. package/dist/module/esbuildConfigs/web.js +14 -11
  54. package/dist/module/lib/abstractBase.js +13 -6
  55. package/dist/module/lib/basebuilder.js +11 -11
  56. package/dist/module/lib/classBuilder.js +2 -3
  57. package/dist/module/lib/core.js +39 -10
  58. package/dist/module/lib/index.js +10 -8
  59. package/dist/module/lib/types.js +1 -0
  60. package/dist/module/preload.js +12 -25
  61. package/dist/module/puppeteerConfiger.js +19 -0
  62. package/dist/module/tsconfig.module.tsbuildinfo +1 -1
  63. package/dist/types/Node.d.ts +3 -2
  64. package/dist/types/Project.d.ts +1 -2
  65. package/dist/types/SubPackages/puppeteer.d.ts +3 -3
  66. package/dist/types/SubPackages/react/component/node.d.ts +1 -1
  67. package/dist/types/SubPackages/react/component/web.d.ts +1 -1
  68. package/dist/types/SubPackages/react/jsx/index.d.ts +1 -1
  69. package/dist/types/SubPackages/react/jsx/node.d.ts +1 -1
  70. package/dist/types/SubPackages/react/jsx/web.d.ts +2 -2
  71. package/dist/types/SubPackages/react-dom/component/node.d.ts +2 -2
  72. package/dist/types/SubPackages/react-dom/component/web.d.ts +1 -1
  73. package/dist/types/SubPackages/react-dom/jsx/node.d.ts +1 -1
  74. package/dist/types/SubPackages/react-dom/jsx/web.d.ts +1 -1
  75. package/dist/types/SubPackages/react-test-renderer/MemoExoticComponent/node.d.ts +1 -1
  76. package/dist/types/SubPackages/react-test-renderer/component/index.d.ts +1 -1
  77. package/dist/types/SubPackages/react-test-renderer/component/node.d.ts +1 -1
  78. package/dist/types/SubPackages/react-test-renderer/component/web.d.ts +1 -1
  79. package/dist/types/SubPackages/react-test-renderer/fc/node.d.ts +1 -1
  80. package/dist/types/SubPackages/react-test-renderer/fc/web.d.ts +1 -1
  81. package/dist/types/SubPackages/react-test-renderer/jsx/node.d.ts +1 -1
  82. package/dist/types/SubPackages/react-test-renderer/jsx/web.d.ts +3 -3
  83. package/dist/types/SubPackages/react-test-renderer/jsx-promised/index.d.ts +1 -1
  84. package/dist/types/SubPackages/react-test-renderer/jsx-promised/node.d.ts +1 -1
  85. package/dist/types/SubPackages/react-test-renderer/jsx-promised/web.d.ts +1 -1
  86. package/dist/types/Types.d.ts +19 -100
  87. package/dist/types/Web.d.ts +3 -2
  88. package/dist/types/esbuildConfigs/features.d.ts +1 -1
  89. package/dist/types/esbuildConfigs/index.d.ts +1 -1
  90. package/dist/types/esbuildConfigs/node.d.ts +1 -1
  91. package/dist/types/esbuildConfigs/report.d.ts +4 -0
  92. package/dist/types/esbuildConfigs/tests.d.ts +1 -1
  93. package/dist/types/esbuildConfigs/web.d.ts +1 -1
  94. package/dist/types/lib/abstractBase.d.ts +25 -24
  95. package/dist/types/lib/basebuilder.d.ts +8 -7
  96. package/dist/types/lib/classBuilder.d.ts +3 -2
  97. package/dist/types/lib/core.d.ts +3 -2
  98. package/dist/types/lib/index.d.ts +4 -3
  99. package/dist/types/lib/types.d.ts +70 -0
  100. package/dist/types/puppeteerConfiger.d.ts +4 -0
  101. package/dist/types/tsconfig.types.tsbuildinfo +1 -1
  102. package/package.json +4 -3
  103. package/src/Node.ts +24 -54
  104. package/src/NodeWriter.ts +21 -18
  105. package/src/Project.ts +165 -620
  106. package/src/Report.tsx +1 -1
  107. package/src/SubPackages/puppeteer.ts +19 -14
  108. package/src/SubPackages/react/component/node.ts +20 -32
  109. package/src/SubPackages/react/component/web.ts +20 -30
  110. package/src/SubPackages/react/jsx/index.ts +13 -24
  111. package/src/SubPackages/react/jsx/web.ts +10 -8
  112. package/src/SubPackages/react-dom/component/node.ts +17 -23
  113. package/src/SubPackages/react-dom/component/web.ts +30 -50
  114. package/src/SubPackages/react-dom/jsx/web.ts +41 -48
  115. package/src/SubPackages/react-test-renderer/MemoExoticComponent/node.ts +27 -37
  116. package/src/SubPackages/react-test-renderer/component/index.ts +16 -30
  117. package/src/SubPackages/react-test-renderer/component/node.ts +5 -11
  118. package/src/SubPackages/react-test-renderer/component/web.ts +5 -11
  119. package/src/SubPackages/react-test-renderer/fc/node.ts +36 -50
  120. package/src/SubPackages/react-test-renderer/fc/web.ts +37 -50
  121. package/src/SubPackages/react-test-renderer/jsx/index.ts +16 -21
  122. package/src/SubPackages/react-test-renderer/jsx/node.ts +6 -10
  123. package/src/SubPackages/react-test-renderer/jsx/web.ts +7 -7
  124. package/src/SubPackages/react-test-renderer/jsx-promised/index.ts +13 -16
  125. package/src/Types.ts +73 -307
  126. package/src/Web.ts +54 -53
  127. package/src/cjs-shim.js +2 -2
  128. package/src/electron.ts +258 -191
  129. package/src/esbuildConfigs/features.ts +3 -4
  130. package/src/esbuildConfigs/index.ts +8 -8
  131. package/src/esbuildConfigs/node.ts +21 -20
  132. package/src/esbuildConfigs/report.ts +15 -51
  133. package/src/esbuildConfigs/tests.ts +3 -9
  134. package/src/esbuildConfigs/web.ts +18 -18
  135. package/src/lib/abstractBase.ts +78 -125
  136. package/src/lib/basebuilder.ts +109 -134
  137. package/src/lib/classBuilder.ts +26 -45
  138. package/src/lib/core.ts +101 -69
  139. package/src/lib/index.ts +53 -52
  140. package/src/lib/types.ts +206 -0
  141. package/src/preload.ts +12 -28
  142. package/src/puppeteerConfiger.ts +26 -0
  143. package/src/web.html.ts +1 -1
  144. package/dist/common/lib/browser.js +0 -26
  145. package/dist/common/nodeWriterElectron.js +0 -55
  146. package/dist/module/lib/browser.js +0 -22
  147. package/dist/module/nodeWriterElectron.js +0 -52
  148. package/dist/types/lib/browser.d.ts +0 -6
  149. package/dist/types/nodeWriterElectron.d.ts +0 -2
  150. package/src/lib/browser.ts +0 -34
  151. package/src/nodeWriterElectron.ts +0 -71
package/src/Types.ts CHANGED
@@ -1,351 +1,117 @@
1
- import { BrowserWindow } from "electron";
2
- import { Page, Browser, ScreenshotOptions } from "puppeteer-core";
3
-
1
+ import { ITTestResourceRequest, ITestCheckCallback } from "./lib/index.js";
4
2
  import {
5
- ITTestResourceConfiguration,
6
- ITTestResourceRequest,
7
- ITestArtificer,
8
- ITestCheckCallback
9
- } from "./lib/index.js";
10
- import { IGivens, BaseCheck, BaseSuite, BaseWhen, BaseThen, BaseGiven } from "./lib/abstractBase.js";
3
+ IGivens,
4
+ BaseCheck,
5
+ BaseSuite,
6
+ BaseWhen,
7
+ BaseThen,
8
+ BaseGiven,
9
+ } from "./lib/abstractBase.js";
11
10
  import Testeranto from "./lib/core.js";
12
-
13
- export type IBuiltConfig = {
14
- buildDir: string,
15
- modules: {
16
- module: unknown,
17
- test: string,
18
- runtime: IRunTime
19
- }[]
20
- };
21
-
22
- export type INodeUtils = TBrowser;
23
- export type IWebUtils = BrowserWindow;
24
- export type IUtils = INodeUtils | IWebUtils;
25
-
26
- export type ISuiteKlasser<ITestShape extends IBaseTest> = (
27
- name: string,
28
- index: number,
29
- givens: IGivens<ITestShape>,
30
- checks: BaseCheck<ITestShape>[]
31
- ) => BaseSuite<ITestShape>;
32
-
33
- export type IGivenKlasser<ITestShape extends IBaseTest> = (
34
- name,
35
- features,
36
- whens,
37
- thens,
38
- givenCB
39
- ) => BaseGiven<ITestShape>;
40
-
41
- export type IWhenKlasser<ITestShape extends IBaseTest> = (s, o) =>
42
- BaseWhen<ITestShape>
43
-
44
- export type IThenKlasser<ITestShape extends IBaseTest> = (s, o) =>
45
- BaseThen<ITestShape>;
46
-
47
- export type ICheckKlasser<ITestShape extends IBaseTest> = (
48
- n,
49
- f,
50
- cb,
51
- w,
52
- t
53
- ) => BaseCheck<ITestShape>;
54
-
55
- // export class TPage extends Page {
56
- // // screenshot(options?: puppeteer.ScreenshotOptions) {
57
- // // return super.screenshot({
58
- // // ...options,
59
- // // path: "dist/" + (options ? options : { path: "" }).path,
60
-
61
- // // });
62
- // // }
63
- // }
64
-
65
- export class TBrowser {
66
- browser: Browser;
67
- constructor(browser: Browser) {
68
- this.browser = browser;
69
- }
70
- pages(): Promise<Page[]> {
71
-
72
- return new Promise(async (res, rej) => {
73
-
74
-
75
- res(
76
- (await this.browser.pages()).map((p) => {
77
- // const handler = {
78
- // apply: function (target, thisArg, argumentsList) {
79
- // console.log('screenshot was called with ' + JSON.stringify(argumentsList));
80
- // const x: ScreenshotOptions = argumentsList[0]
81
- // x.path = "./dist/" + x.path;
82
- // console.log('x.path' + x.path, target, thisArg);
83
- // return target(...argumentsList);
84
- // }
85
- // };
86
- // p.screenshot = new Proxy(p.screenshot, handler);
87
- return p;
88
- })
89
- );
90
- });
91
-
92
- }
93
- // pages(): Promise<TPage[]> {
94
- // return super.pages();
95
- // }
96
- }
97
-
98
- export type ITTestShape = {
99
- suites;
100
- givens;
101
- whens;
102
- thens;
103
- checks;
104
- };
105
-
106
- export type IJsonConfig = {
107
- outdir: string,
108
- tests: ITestTypes[]
109
- features: string;
110
- };
111
-
112
- export type IBaseConfig = {
113
- outdir: string,
114
- tests: ITestTypes[]
115
- features: string
116
- externals: string[],
117
- clearScreen: boolean;
118
- devMode: boolean;
119
- webPlugins: any[];
120
- nodePlugins: any[];
121
- minify: boolean;
122
- outbase: string;
123
- ports: string[];
124
- debugger: boolean;
125
- };
11
+ import {
12
+ INodeTestInterface,
13
+ ITestInterface,
14
+ IWebTestInterface,
15
+ } from "./lib/types.js";
126
16
 
127
17
  export type IPartialInterface<I extends IBaseTest> = Partial<ITestInterface<I>>;
128
- export type IPartialNodeInterface<I extends IBaseTest> = Partial<INodeTestInterface<I>>;
18
+
19
+ export type IPartialNodeInterface<I extends IBaseTest> = Partial<
20
+ INodeTestInterface<I>
21
+ >;
22
+ export type IPartialWebInterface<I extends IBaseTest> = Partial<
23
+ IWebTestInterface<I>
24
+ >;
129
25
 
130
26
  export type IEntry<ITestShape extends IBaseTest> = (
131
- input: ITestShape['iinput'],
27
+ input: ITestShape["iinput"],
132
28
  testSpecification: ITestSpecification<ITestShape>,
133
29
  testImplementation: ITestImplementation<ITestShape, object>,
134
30
  testInterface: IPartialInterface<ITestShape>,
135
- testResourceRequirement: ITTestResourceRequest,
31
+ testResourceRequirement: ITTestResourceRequest
136
32
  ) => Promise<Testeranto<ITestShape>>;
137
33
 
138
- // type If = {
139
- // (modulePath: string | URL, options?: childProcess.ForkOptions): childProcess.ChildProcess;
140
- // (modulePath: string | URL, args?: readonly string[], options?: childProcess.ForkOptions): childProcess.ChildProcess
141
- // };
142
-
143
- // const f: If = childProcess.fork;
144
-
145
- export type IRunTime = `node` | `web`;
146
-
147
- export type ITestTypes = [
148
- string,
149
- IRunTime,
150
- ITestTypes[]
151
- ];
152
-
153
- export type ITestSpecification<
154
- ITestShape extends IBaseTest
155
- > = (
34
+ export type ITestSpecification<ITestShape extends IBaseTest> = (
156
35
  Suite: {
157
36
  [K in keyof ITestShape["suites"]]: (
158
37
  name: string,
159
- givens: IGivens<
160
- ITestShape
161
- >,
162
- checks: BaseCheck<
163
- ITestShape
164
- >[]
165
- ) => BaseSuite<
166
- ITestShape
167
- >;
38
+ givens: IGivens<ITestShape>,
39
+ checks: BaseCheck<ITestShape>[]
40
+ ) => BaseSuite<ITestShape>;
168
41
  },
169
42
  Given: {
170
43
  [K in keyof ITestShape["givens"]]: (
171
44
  features: string[],
172
- whens: BaseWhen<
173
- ITestShape
174
- >[],
175
- thens: BaseThen<
176
- ITestShape
177
- >[],
45
+ whens: BaseWhen<ITestShape>[],
46
+ thens: BaseThen<ITestShape>[],
178
47
  ...xtrasB: ITestShape["givens"][K]
179
- ) => BaseGiven<
180
- ITestShape
181
- >;
48
+ ) => BaseGiven<ITestShape>;
182
49
  },
183
50
  When: {
184
51
  [K in keyof ITestShape["whens"]]: (
185
52
  ...xtrasC: ITestShape["whens"][K]
186
- ) => BaseWhen<
187
- ITestShape
188
- >;
53
+ ) => BaseWhen<ITestShape>;
189
54
  },
190
55
  Then: {
191
56
  [K in keyof ITestShape["thens"]]: (
192
57
  ...xtrasD: ITestShape["thens"][K]
193
- ) => BaseThen<
194
- ITestShape
195
- >;
58
+ ) => BaseThen<ITestShape>;
196
59
  },
197
60
  Check: ITestCheckCallback<ITestShape>
198
61
  ) => any[];
199
62
 
200
63
  export type ITestImplementation<
201
64
  ITestShape extends IBaseTest,
65
+ IMod = object
66
+ > = Modify<
67
+ {
68
+ suites: {
69
+ [K in keyof ITestShape["suites"]]: string;
70
+ };
71
+ givens: {
72
+ [K in keyof ITestShape["givens"]]: (
73
+ ...Ig: ITestShape["givens"][K]
74
+ ) => ITestShape["given"];
75
+ };
76
+ whens: {
77
+ [K in keyof ITestShape["whens"]]: (
78
+ ...Iw: ITestShape["whens"][K]
79
+ ) => (zel: ITestShape["iselection"]) => ITestShape["when"];
80
+ };
81
+ thens: {
82
+ [K in keyof ITestShape["thens"]]: (
83
+ ...It: ITestShape["thens"][K]
84
+ ) => (ssel: ITestShape["iselection"]) => ITestShape["then"];
85
+ };
86
+ checks: {
87
+ [K in keyof ITestShape["checks"]]: (
88
+ ...Ic: ITestShape["checks"][K]
89
+ ) => ITestShape["given"];
90
+ };
91
+ },
202
92
  IMod
203
- > = Modify<{
204
- suites: {
205
- [K in keyof ITestShape["suites"]]: string;
206
- };
207
- givens: {
208
- [K in keyof ITestShape["givens"]]: (
209
- ...Ig: ITestShape["givens"][K]
210
- ) => ITestShape['given'];
211
- };
212
- whens: {
213
- [K in keyof ITestShape["whens"]]: (
214
- ...Iw: ITestShape["whens"][K]
215
- ) =>
216
- (zel: ITestShape['iselection']) =>
217
- ITestShape['when'];
218
- };
219
- thens: {
220
- [K in keyof ITestShape["thens"]]: (
221
- ...It: ITestShape["thens"][K]
222
- ) => (ssel: ITestShape['iselection']) =>
223
- ITestShape['then'];
224
- };
225
- checks: {
226
- [K in keyof ITestShape["checks"]]: (
227
- ...Ic: ITestShape["checks"][K]
228
- ) => ITestShape['given'];
229
- };
230
- }, IMod>;
231
-
232
-
233
-
234
- export type ITestInterface<
235
- ITestShape extends IBaseTest
236
- > = {
237
- assertThis: (x: ITestShape['then']) => void,
238
-
239
- andWhen: (
240
- store: ITestShape['istore'],
241
- whenCB: ITestShape['when'],
242
- testResource: ITTestResourceConfiguration
243
- ) => Promise<ITestShape['istore']>;
244
- butThen: (
245
- store: ITestShape['istore'],
246
- thenCB,
247
- testResource: ITTestResourceConfiguration
248
- ) => Promise<ITestShape['iselection']>;
249
-
250
- afterAll: (
251
- store: ITestShape['istore'],
252
- artificer: ITestArtificer,
253
- utils: IUtils
254
- ) => any;
255
- afterEach: (
256
- store: ITestShape['istore'],
257
- key: string,
258
- artificer: ITestArtificer,
259
- // utils: IUtils
260
- ) => Promise<unknown>;
261
- beforeAll: (
262
- input: ITestShape['iinput'],
263
- testResource: ITTestResourceConfiguration,
264
- artificer: ITestArtificer,
265
- // utils: IUtils
266
- ) => Promise<ITestShape['isubject']>;
267
- beforeEach: (
268
- subject: ITestShape['isubject'],
269
- initializer: (c?) => ITestShape['given'],
270
- artificer: ITestArtificer,
271
- testResource: ITTestResourceConfiguration,
272
- initialValues,
273
- // utils: IUtils
274
- ) => Promise<ITestShape['istore']>;
275
- };
276
-
277
- export type INodeTestInterface<
278
- ITestShape extends IBaseTest
279
- > = {
280
- assertThis: (x: ITestShape['then']) => void,
281
-
282
- andWhen: (
283
- store: ITestShape['istore'],
284
- whenCB: ITestShape['when'],
285
- testResource: ITTestResourceConfiguration
286
- ) => Promise<ITestShape['istore']>;
287
- butThen: (
288
- store: ITestShape['istore'],
289
- thenCB,
290
- testResource: ITTestResourceConfiguration
291
- ) => Promise<ITestShape['iselection']>;
292
-
293
- afterAll: (
294
- store: ITestShape['istore'],
295
- artificer: ITestArtificer,
296
- browser: INodeUtils
297
- ) => any;
298
- afterEach: (
299
- store: ITestShape['istore'],
300
- key: string,
301
- artificer: ITestArtificer,
302
- // utils: IUtils
303
- ) => Promise<unknown>;
304
- beforeAll: (
305
- input: ITestShape['iinput'],
306
- testResource: ITTestResourceConfiguration,
307
- artificer: ITestArtificer,
308
- // utils: IUtils
309
- ) => Promise<ITestShape['isubject']>;
310
- beforeEach: (
311
- subject: ITestShape['isubject'],
312
- initializer: (c?) => ITestShape['given'],
313
- artificer: ITestArtificer,
314
- testResource: ITTestResourceConfiguration,
315
- initialValues,
316
- // utils: IUtils
317
- ) => Promise<ITestShape['istore']>;
318
- } & ITestInterface<ITestShape>;
93
+ >;
319
94
 
320
95
  type Modify<T, R> = Omit<T, keyof R> & R;
321
96
 
322
- export type IBaseTest = {
323
- iinput; // input
324
- isubject; // subject
325
- istore; // store
326
- iselection;
97
+ export type IBaseTest<Shape = any, II = Shape> = {
98
+ iinput: II;
99
+ isubject: Shape;
100
+ istore: Shape;
101
+ iselection: Shape;
327
102
  // iinitial;
328
103
 
329
104
  given;
330
105
  when;
331
106
  then;
332
- suites: Record<string, any[]>;
333
- givens: Record<string, any[]>;
334
- whens: Record<string, any[]>;
335
- thens: Record<string, any[]>;
336
- checks: Record<string, any[]>;
107
+
108
+ suites: Record<string, any>;
109
+ givens: Record<string, any>;
110
+ whens: Record<string, any>;
111
+ thens: Record<string, any>;
112
+ checks: Record<string, any>;
337
113
  };
338
114
 
339
- export type ITestShaper<
340
- T extends IBaseTest,
341
- modifier
342
- > = {
343
- given;
344
- when;
345
- then;
346
- suites;
347
- givens;
348
- whens;
349
- thens;
350
- checks;
351
- };
115
+ // export type ITTestShape = {
116
+
117
+ // };
package/src/Web.ts CHANGED
@@ -1,30 +1,35 @@
1
1
  import type {
2
2
  IBaseTest,
3
3
  ITestImplementation,
4
- ITestInterface,
5
- ITestSpecification
4
+ ITestSpecification,
6
5
  } from "./Types";
7
6
  import Testeranto from "./lib/core.js";
8
7
  import {
9
8
  ITTestResourceConfiguration,
10
9
  ITTestResourceRequest,
11
10
  ITestJob,
12
- defaultTestResourceRequirement
11
+ defaultTestResourceRequirement,
13
12
  } from "./lib/index.js";
13
+ import {
14
+ INodeUtils,
15
+ ITestInterface,
16
+ IWebTestInterface,
17
+ IWebUtils,
18
+ } from "./lib/types";
14
19
 
15
- const remote = require('@electron/remote')
20
+ // const remote = require("@electron/remote");
21
+ // import remote from "@electron/remote";
22
+ // const electron = require("electron");
23
+ // const remote =
24
+ // process.type === "browser" ? electron : require("@electron/remote");
16
25
 
17
- class WebTesteranto<
18
- TestShape extends IBaseTest,
19
- > extends Testeranto<
20
- TestShape
21
- > {
26
+ class WebTesteranto<TestShape extends IBaseTest> extends Testeranto<TestShape> {
22
27
  constructor(
23
28
  input: TestShape["iinput"],
24
29
  testSpecification: ITestSpecification<TestShape>,
25
- testImplementation: ITestImplementation<TestShape, object>,
30
+ testImplementation: ITestImplementation<TestShape>,
26
31
  testResourceRequirement: ITTestResourceRequest,
27
- testInterface: Partial<ITestInterface<TestShape>>,
32
+ testInterface: Partial<ITestInterface<TestShape>>
28
33
  ) {
29
34
  super(
30
35
  input,
@@ -32,31 +37,25 @@ class WebTesteranto<
32
37
  testImplementation,
33
38
  testResourceRequirement,
34
39
  (window as any).NodeWriter,
35
- testInterface,
36
- // BrowserWindow
40
+ testInterface
37
41
  );
38
42
 
39
- if (process.argv[2]) {
40
- const testResourceArg = decodeURIComponent(
41
- new URLSearchParams(location.search).get('requesting') || ''
42
- );
43
-
44
- try {
45
- const partialTestResource = JSON.parse(
46
- testResourceArg
47
- ) as ITTestResourceConfiguration;
43
+ const testResourceArg = decodeURIComponent(
44
+ new URLSearchParams(location.search).get("requesting") || ""
45
+ );
48
46
 
49
- this.receiveTestResourceConfig(this.testJobs[0], partialTestResource);
47
+ try {
48
+ const partialTestResource = JSON.parse(
49
+ testResourceArg
50
+ ) as ITTestResourceConfiguration;
50
51
 
51
- } catch (e) {
52
- console.error(e);
53
- // process.exit(-1);
54
- }
55
- } else {
56
- // no-op
52
+ this.receiveTestResourceConfig(this.testJobs[0], partialTestResource);
53
+ } catch (e) {
54
+ console.error(e);
55
+ // process.exit(-1);
57
56
  }
58
57
 
59
- const requesting = new URLSearchParams(location.search).get('requesting');
58
+ const requesting = new URLSearchParams(location.search).get("requesting");
60
59
  if (requesting) {
61
60
  const testResourceArg = decodeURIComponent(requesting);
62
61
 
@@ -67,49 +66,51 @@ class WebTesteranto<
67
66
 
68
67
  console.log("initial test resource", partialTestResource);
69
68
  this.receiveTestResourceConfig(this.testJobs[0], partialTestResource);
70
-
71
69
  } catch (e) {
72
70
  console.error(e);
73
71
  // process.exit(-1);
74
72
  }
75
73
  }
76
- // const t: ITestJob = this.testJobs[0];
77
-
78
-
79
-
80
74
  }
81
75
 
82
- async receiveTestResourceConfig(t: ITestJob, partialTestResource: ITTestResourceConfiguration) {
83
- const {
84
- failed,
85
- artifacts,
86
- logPromise
87
- } = await t.receiveTestResourceConfig(
76
+ async receiveTestResourceConfig(
77
+ t: ITestJob<IWebUtils>,
78
+ partialTestResource: ITTestResourceConfiguration
79
+ ) {
80
+ const { failed, artifacts, logPromise } = await t.receiveTestResourceConfig(
88
81
  partialTestResource,
89
- remote
82
+ {
83
+ browser: await (window as any).browser,
84
+ ipc: (window as any).ipcRenderer,
85
+ }
90
86
  );
91
87
 
88
+ console.log("test is done, awaiting test result write to fs");
92
89
  Promise.all([...artifacts, logPromise]).then(async () => {
93
- var window = remote.getCurrentWindow();
90
+ // we can't close the window becuase we might be taking a screenshot
94
91
  // window.close();
95
- })
92
+ // console.log(
93
+ // "(window as any).browser",
94
+ // JSON.stringify(await (window as any).browser)
95
+ // );
96
+ // var currentWindow = (await (window as any).browser).getCurrentWindow();
97
+ // currentWindow.close();
98
+ });
96
99
  }
97
-
98
- };
100
+ }
99
101
 
100
102
  export default async <ITestShape extends IBaseTest>(
101
- input: ITestShape['iinput'],
103
+ input: ITestShape["iinput"],
102
104
  testSpecification: ITestSpecification<ITestShape>,
103
- testImplementation: ITestImplementation<ITestShape, object>,
104
- testInterface: Partial<ITestInterface<ITestShape>>,
105
- testResourceRequirement: ITTestResourceRequest = defaultTestResourceRequirement,
105
+ testImplementation: ITestImplementation<ITestShape>,
106
+ testInterface: Partial<IWebTestInterface<ITestShape>>,
107
+ testResourceRequirement: ITTestResourceRequest = defaultTestResourceRequirement
106
108
  ): Promise<Testeranto<ITestShape>> => {
107
109
  return new WebTesteranto<ITestShape>(
108
110
  input,
109
111
  testSpecification,
110
112
  testImplementation,
111
113
  testResourceRequirement,
112
- testInterface,
113
- )
114
-
114
+ testInterface
115
+ );
115
116
  };
package/src/cjs-shim.js CHANGED
@@ -3,8 +3,8 @@ import path from 'node:path';
3
3
  import url from 'node:url';
4
4
 
5
5
  // globalThis.require = createRequire(import.meta.url);
6
- // globalThis.__filename = url.fileURLToPath(import.meta.url);
7
- // globalThis.__dirname = path.dirname(__filename);
6
+ globalThis.__filename = url.fileURLToPath(import.meta.url);
7
+ globalThis.__dirname = path.dirname(__filename);
8
8
 
9
9
  // const p = `${import.meta.url}/..`;
10
10
  // globalThis.require = createRequire(`${import.meta.url}/..`);