testeranto 0.49.10 → 0.62.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 (241) hide show
  1. package/.nvmrc +1 -0
  2. package/README.md +71 -9
  3. package/dist/cjs-shim.js +12 -0
  4. package/dist/common/Features.js +2 -3
  5. package/dist/common/Node.js +53 -61
  6. package/dist/common/Project.js +272 -606
  7. package/dist/common/SubPackages/puppeteer.js +19 -0
  8. package/dist/common/{subPackages → SubPackages}/react/component/node.js +4 -4
  9. package/dist/common/{subPackages → SubPackages}/react/component/web.js +4 -4
  10. package/dist/common/SubPackages/react/jsx/index.js +13 -0
  11. package/dist/common/SubPackages/react/jsx/node.js +10 -0
  12. package/dist/common/SubPackages/react/jsx/web.js +10 -0
  13. package/dist/common/{subPackages → SubPackages}/react-dom/component/node.js +6 -6
  14. package/dist/common/{subPackages → SubPackages}/react-dom/component/web.js +11 -12
  15. package/dist/common/SubPackages/react-dom/jsx/node.js +39 -0
  16. package/dist/common/{subPackages → SubPackages}/react-dom/jsx/web.js +5 -14
  17. package/dist/common/{subPackages → SubPackages}/react-test-renderer/MemoExoticComponent/node.js +2 -2
  18. package/dist/common/{subPackages → SubPackages}/react-test-renderer/component/index.js +26 -15
  19. package/dist/common/{subPackages/react-test-renderer/jsx → SubPackages/react-test-renderer/component}/node.js +3 -5
  20. package/dist/common/{subPackages/react-test-renderer/jsx → SubPackages/react-test-renderer/component}/web.js +3 -5
  21. package/dist/common/{subPackages → SubPackages}/react-test-renderer/fc/node.js +4 -4
  22. package/dist/common/{subPackages → SubPackages}/react-test-renderer/fc/web.js +4 -4
  23. package/dist/common/{subPackages → SubPackages}/react-test-renderer/jsx/index.js +8 -2
  24. package/dist/common/{subPackages/react-test-renderer/jsx-promised → SubPackages/react-test-renderer/jsx}/node.js +4 -4
  25. package/dist/common/{subPackages/react → SubPackages/react-test-renderer}/jsx/web.js +4 -4
  26. package/dist/common/{subPackages → SubPackages}/react-test-renderer/jsx-promised/index.js +2 -2
  27. package/dist/common/{subPackages/react/jsx → SubPackages/react-test-renderer/jsx-promised}/node.js +2 -2
  28. package/dist/common/Types.js +32 -0
  29. package/dist/common/Web.js +41 -112
  30. package/dist/common/electron.js +188 -44
  31. package/dist/common/esbuildConfigs/features.js +14 -0
  32. package/dist/common/esbuildConfigs/index.js +20 -0
  33. package/dist/common/esbuildConfigs/node.js +35 -0
  34. package/dist/common/esbuildConfigs/report.js +48 -0
  35. package/dist/common/esbuildConfigs/tests.js +14 -0
  36. package/dist/common/esbuildConfigs/web.js +50 -0
  37. package/dist/common/lib/abstractBase.js +193 -0
  38. package/dist/common/lib/basebuilder.js +86 -0
  39. package/dist/common/lib/browser.js +26 -0
  40. package/dist/common/lib/classBuilder.js +41 -0
  41. package/dist/common/lib/core.js +52 -0
  42. package/dist/common/lib/index.js +19 -0
  43. package/dist/common/nodeWriterElectron.js +55 -0
  44. package/dist/common/preload.js +22 -21
  45. package/dist/common/report.html.js +31 -0
  46. package/dist/common/tsconfig.common.tsbuildinfo +1 -1
  47. package/dist/common/web.html.js +22 -0
  48. package/dist/module/Features.js +2 -3
  49. package/dist/module/Node.js +53 -61
  50. package/dist/module/Project.js +272 -583
  51. package/dist/module/SubPackages/puppeteer.js +14 -0
  52. package/dist/module/{subPackages → SubPackages}/react/component/node.js +3 -3
  53. package/dist/module/{subPackages → SubPackages}/react/component/web.js +3 -3
  54. package/dist/module/SubPackages/react/jsx/index.js +10 -0
  55. package/dist/module/SubPackages/react/jsx/node.js +5 -0
  56. package/dist/module/SubPackages/react/jsx/web.js +5 -0
  57. package/dist/module/{subPackages → SubPackages}/react-dom/component/node.js +5 -5
  58. package/dist/module/{subPackages → SubPackages}/react-dom/component/web.js +10 -11
  59. package/dist/module/SubPackages/react-dom/jsx/node.js +31 -0
  60. package/dist/module/{subPackages → SubPackages}/react-dom/jsx/web.js +4 -13
  61. package/dist/module/{subPackages → SubPackages}/react-test-renderer/MemoExoticComponent/node.js +2 -2
  62. package/dist/module/{subPackages → SubPackages}/react-test-renderer/component/index.js +23 -15
  63. package/dist/module/{subPackages → SubPackages}/react-test-renderer/component/node.js +2 -2
  64. package/dist/module/{subPackages → SubPackages}/react-test-renderer/component/web.js +2 -2
  65. package/dist/module/{subPackages → SubPackages}/react-test-renderer/fc/node.js +3 -3
  66. package/dist/module/{subPackages → SubPackages}/react-test-renderer/fc/web.js +3 -3
  67. package/dist/module/{subPackages → SubPackages}/react-test-renderer/jsx/index.js +8 -2
  68. package/dist/module/SubPackages/react-test-renderer/jsx/node.js +5 -0
  69. package/dist/module/SubPackages/react-test-renderer/jsx/web.js +5 -0
  70. package/dist/module/{subPackages → SubPackages}/react-test-renderer/jsx-promised/index.js +2 -2
  71. package/dist/module/{subPackages/react-test-renderer/jsx → SubPackages/react-test-renderer/jsx-promised}/node.js +1 -1
  72. package/dist/module/Types.js +30 -1
  73. package/dist/module/Web.js +41 -112
  74. package/dist/module/electron.js +189 -45
  75. package/dist/module/esbuildConfigs/features.js +12 -0
  76. package/dist/module/esbuildConfigs/index.js +18 -0
  77. package/dist/module/esbuildConfigs/node.js +30 -0
  78. package/dist/module/esbuildConfigs/report.js +48 -0
  79. package/dist/module/esbuildConfigs/tests.js +12 -0
  80. package/dist/module/esbuildConfigs/web.js +45 -0
  81. package/dist/module/lib/abstractBase.js +185 -0
  82. package/dist/module/lib/basebuilder.js +82 -0
  83. package/dist/module/lib/browser.js +22 -0
  84. package/dist/module/lib/classBuilder.js +37 -0
  85. package/dist/module/lib/core.js +49 -0
  86. package/dist/module/lib/index.js +15 -0
  87. package/dist/module/nodeWriterElectron.js +52 -0
  88. package/dist/module/preload.js +22 -21
  89. package/dist/module/report.html.js +29 -0
  90. package/dist/module/tsconfig.module.tsbuildinfo +1 -1
  91. package/dist/module/web.html.js +20 -0
  92. package/dist/prebuild/Report.css +10326 -0
  93. package/dist/prebuild/Report.js +37456 -0
  94. package/dist/types/Features.d.ts +5 -5
  95. package/dist/types/Node.d.ts +4 -11
  96. package/dist/types/NodeWriter.d.ts +1 -1
  97. package/dist/types/Project.d.ts +2 -27
  98. package/dist/types/SubPackages/puppeteer.d.ts +6 -0
  99. package/dist/types/SubPackages/react/component/node.d.ts +7 -0
  100. package/dist/types/SubPackages/react/component/web.d.ts +7 -0
  101. package/dist/types/SubPackages/react/jsx/index.d.ts +15 -0
  102. package/dist/types/SubPackages/react/jsx/node.d.ts +4 -0
  103. package/dist/types/SubPackages/react/jsx/web.d.ts +4 -0
  104. package/dist/types/{subPackages → SubPackages}/react-dom/component/node.d.ts +2 -4
  105. package/dist/types/SubPackages/react-dom/component/web.d.ts +5 -0
  106. package/dist/types/SubPackages/react-dom/jsx/node.d.ts +6 -0
  107. package/dist/types/SubPackages/react-dom/jsx/web.d.ts +5 -0
  108. package/dist/types/SubPackages/react-test-renderer/MemoExoticComponent/node.d.ts +5 -0
  109. package/dist/types/{subPackages → SubPackages}/react-test-renderer/component/index.d.ts +6 -6
  110. package/dist/types/SubPackages/react-test-renderer/component/node.d.ts +9 -0
  111. package/dist/types/SubPackages/react-test-renderer/component/web.d.ts +4 -0
  112. package/dist/types/SubPackages/react-test-renderer/fc/node.d.ts +8 -0
  113. package/dist/types/SubPackages/react-test-renderer/fc/web.d.ts +8 -0
  114. package/dist/types/{subPackages → SubPackages}/react-test-renderer/jsx/index.d.ts +5 -4
  115. package/dist/types/SubPackages/react-test-renderer/jsx/node.d.ts +9 -0
  116. package/dist/types/SubPackages/react-test-renderer/jsx/web.d.ts +9 -0
  117. package/dist/types/{subPackages → SubPackages}/react-test-renderer/jsx-promised/index.d.ts +4 -4
  118. package/dist/types/SubPackages/react-test-renderer/jsx-promised/node.d.ts +5 -0
  119. package/dist/types/SubPackages/react-test-renderer/jsx-promised/web.d.ts +5 -0
  120. package/dist/types/Types.d.ts +116 -3
  121. package/dist/types/Web.d.ts +4 -11
  122. package/dist/types/esbuildConfigs/features.d.ts +4 -0
  123. package/dist/types/esbuildConfigs/index.d.ts +4 -0
  124. package/dist/types/esbuildConfigs/node.d.ts +4 -0
  125. package/dist/types/esbuildConfigs/report.d.ts +0 -0
  126. package/dist/types/esbuildConfigs/tests.d.ts +4 -0
  127. package/dist/types/esbuildConfigs/web.d.ts +4 -0
  128. package/dist/types/lib/abstractBase.d.ts +102 -0
  129. package/dist/types/lib/basebuilder.d.ts +24 -0
  130. package/dist/types/lib/browser.d.ts +6 -0
  131. package/dist/types/lib/classBuilder.d.ts +6 -0
  132. package/dist/types/lib/core.d.ts +7 -0
  133. package/dist/types/lib/index.d.ts +57 -0
  134. package/dist/types/nodeWriterElectron.d.ts +2 -0
  135. package/dist/types/report.html.d.ts +2 -0
  136. package/dist/types/tsconfig.types.tsbuildinfo +1 -1
  137. package/dist/types/web.html.d.ts +2 -0
  138. package/electronBuild.ts +32 -0
  139. package/index.html +30 -0
  140. package/package.json +120 -85
  141. package/src/Features.ts +2 -4
  142. package/src/Node.ts +114 -160
  143. package/src/NodeWriter.ts +1 -4
  144. package/src/Project.ts +610 -753
  145. package/src/Report.tsx +30 -15
  146. package/src/SubPackages/puppeteer.ts +46 -0
  147. package/src/{subPackages → SubPackages}/react/component/node.ts +12 -32
  148. package/src/SubPackages/react/component/web.ts +53 -0
  149. package/src/SubPackages/react/jsx/index.ts +43 -0
  150. package/src/SubPackages/react/jsx/node.ts +29 -0
  151. package/src/SubPackages/react/jsx/web.ts +28 -0
  152. package/src/{subPackages → SubPackages}/react-dom/component/node.ts +11 -25
  153. package/src/{subPackages → SubPackages}/react-dom/component/web.ts +27 -32
  154. package/src/{subPackages → SubPackages}/react-dom/jsx/index.ts +0 -1
  155. package/src/SubPackages/react-dom/jsx/node.ts +68 -0
  156. package/src/{subPackages → SubPackages}/react-dom/jsx/web.ts +18 -54
  157. package/src/{subPackages → SubPackages}/react-test-renderer/MemoExoticComponent/node.ts +9 -28
  158. package/src/{subPackages → SubPackages}/react-test-renderer/component/index.ts +31 -29
  159. package/src/SubPackages/react-test-renderer/component/node.ts +22 -0
  160. package/src/SubPackages/react-test-renderer/component/web.ts +22 -0
  161. package/src/{subPackages → SubPackages}/react-test-renderer/fc/node.ts +14 -28
  162. package/src/{subPackages → SubPackages}/react-test-renderer/fc/web.ts +9 -25
  163. package/src/{subPackages → SubPackages}/react-test-renderer/jsx/index.ts +19 -16
  164. package/src/SubPackages/react-test-renderer/jsx/node.ts +24 -0
  165. package/src/SubPackages/react-test-renderer/jsx/web.ts +20 -0
  166. package/src/{subPackages → SubPackages}/react-test-renderer/jsx-promised/index.ts +7 -15
  167. package/src/SubPackages/react-test-renderer/jsx-promised/node.ts +19 -0
  168. package/src/SubPackages/react-test-renderer/jsx-promised/web.ts +22 -0
  169. package/src/Types.ts +334 -3
  170. package/src/Web.ts +104 -230
  171. package/src/cjs-shim.js +12 -0
  172. package/src/electron.ts +237 -46
  173. package/src/esbuildConfigs/features.ts +18 -0
  174. package/src/esbuildConfigs/index.ts +22 -0
  175. package/src/esbuildConfigs/node.ts +59 -0
  176. package/src/esbuildConfigs/report.ts +51 -0
  177. package/src/esbuildConfigs/tests.ts +20 -0
  178. package/src/esbuildConfigs/web.ts +73 -0
  179. package/src/lib/abstractBase.ts +459 -0
  180. package/src/lib/basebuilder.ts +253 -0
  181. package/src/lib/browser.ts +34 -0
  182. package/src/lib/classBuilder.ts +137 -0
  183. package/src/lib/core.ts +182 -0
  184. package/src/lib/index.ts +116 -0
  185. package/src/nodeWriterElectron.ts +71 -0
  186. package/src/preload.ts +23 -21
  187. package/src/report.html.ts +29 -0
  188. package/src/web.html.ts +20 -0
  189. package/tests/Rectangle.test.ts +189 -0
  190. package/tsconfig.json +19 -6
  191. package/tsconfig.module.json +15 -4
  192. package/tsconfig.types.json +14 -4
  193. package/yarn-error.log +3144 -0
  194. package/dist/common/core.js +0 -397
  195. package/dist/common/subPackages/react/jsx/index.js +0 -26
  196. package/dist/common/subPackages/react-dom/jsx/node.js +0 -95
  197. package/dist/common/subPackages/react-test-renderer/component/node.js +0 -8
  198. package/dist/common/subPackages/react-test-renderer/component/web.js +0 -8
  199. package/dist/module/Report.js +0 -186
  200. package/dist/module/core.js +0 -388
  201. package/dist/module/subPackages/react/jsx/index.js +0 -22
  202. package/dist/module/subPackages/react/jsx/node.js +0 -5
  203. package/dist/module/subPackages/react/jsx/web.js +0 -5
  204. package/dist/module/subPackages/react-dom/jsx/node.js +0 -87
  205. package/dist/module/subPackages/react-test-renderer/jsx/web.js +0 -5
  206. package/dist/module/subPackages/react-test-renderer/jsx-promised/node.js +0 -5
  207. package/dist/types/core.d.ts +0 -220
  208. package/dist/types/subPackages/react/component/node.d.ts +0 -12
  209. package/dist/types/subPackages/react/component/web.d.ts +0 -12
  210. package/dist/types/subPackages/react/jsx/index.d.ts +0 -15
  211. package/dist/types/subPackages/react/jsx/node.d.ts +0 -4
  212. package/dist/types/subPackages/react/jsx/web.d.ts +0 -4
  213. package/dist/types/subPackages/react-dom/component/web.d.ts +0 -19
  214. package/dist/types/subPackages/react-dom/jsx/node.d.ts +0 -8
  215. package/dist/types/subPackages/react-dom/jsx/web.d.ts +0 -5
  216. package/dist/types/subPackages/react-test-renderer/MemoExoticComponent/node.d.ts +0 -8
  217. package/dist/types/subPackages/react-test-renderer/component/node.d.ts +0 -9
  218. package/dist/types/subPackages/react-test-renderer/component/web.d.ts +0 -9
  219. package/dist/types/subPackages/react-test-renderer/fc/node.d.ts +0 -9
  220. package/dist/types/subPackages/react-test-renderer/fc/web.d.ts +0 -9
  221. package/dist/types/subPackages/react-test-renderer/jsx/node.d.ts +0 -4
  222. package/dist/types/subPackages/react-test-renderer/jsx/web.d.ts +0 -4
  223. package/dist/types/subPackages/react-test-renderer/jsx-promised/node.d.ts +0 -4
  224. package/dist/types/subPackages/react-test-renderer/jsx-promised/web.d.ts +0 -4
  225. package/src/core.ts +0 -1399
  226. package/src/subPackages/react/component/web.ts +0 -80
  227. package/src/subPackages/react/jsx/index.ts +0 -64
  228. package/src/subPackages/react/jsx/node.ts +0 -29
  229. package/src/subPackages/react/jsx/web.ts +0 -29
  230. package/src/subPackages/react-dom/jsx/node.ts +0 -145
  231. package/src/subPackages/react-test-renderer/component/node.ts +0 -30
  232. package/src/subPackages/react-test-renderer/component/web.ts +0 -30
  233. package/src/subPackages/react-test-renderer/jsx/node.ts +0 -31
  234. package/src/subPackages/react-test-renderer/jsx/web.ts +0 -31
  235. package/src/subPackages/react-test-renderer/jsx-promised/node.ts +0 -31
  236. package/src/subPackages/react-test-renderer/jsx-promised/web.ts +0 -31
  237. /package/dist/common/{subPackages → SubPackages}/react-dom/jsx/index.js +0 -0
  238. /package/dist/common/{subPackages → SubPackages}/react-test-renderer/jsx-promised/web.js +0 -0
  239. /package/dist/module/{subPackages → SubPackages}/react-dom/jsx/index.js +0 -0
  240. /package/dist/module/{subPackages → SubPackages}/react-test-renderer/jsx-promised/web.js +0 -0
  241. /package/dist/types/{subPackages → SubPackages}/react-dom/jsx/index.d.ts +0 -0
package/src/Types.ts CHANGED
@@ -1,16 +1,147 @@
1
+ import { BrowserWindow } from "electron";
2
+ import { Page, Browser, ScreenshotOptions } from "puppeteer-core";
3
+
4
+ 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";
11
+ 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
+
1
112
  export type IBaseConfig = {
113
+ outdir: string,
114
+ tests: ITestTypes[]
115
+ features: string
116
+ externals: string[],
2
117
  clearScreen: boolean;
3
118
  devMode: boolean;
4
- features: string;
5
119
  webPlugins: any[];
6
120
  nodePlugins: any[];
7
121
  minify: boolean;
8
122
  outbase: string;
9
- outdir: string;
10
123
  ports: string[];
11
- tests: string;
124
+ debugger: boolean;
12
125
  };
13
126
 
127
+ export type IPartialInterface<I extends IBaseTest> = Partial<ITestInterface<I>>;
128
+ export type IPartialNodeInterface<I extends IBaseTest> = Partial<INodeTestInterface<I>>;
129
+
130
+ export type IEntry<ITestShape extends IBaseTest> = (
131
+ input: ITestShape['iinput'],
132
+ testSpecification: ITestSpecification<ITestShape>,
133
+ testImplementation: ITestImplementation<ITestShape, object>,
134
+ testInterface: IPartialInterface<ITestShape>,
135
+ testResourceRequirement: ITTestResourceRequest,
136
+ ) => Promise<Testeranto<ITestShape>>;
137
+
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
+
14
145
  export type IRunTime = `node` | `web`;
15
146
 
16
147
  export type ITestTypes = [
@@ -18,3 +149,203 @@ export type ITestTypes = [
18
149
  IRunTime,
19
150
  ITestTypes[]
20
151
  ];
152
+
153
+ export type ITestSpecification<
154
+ ITestShape extends IBaseTest
155
+ > = (
156
+ Suite: {
157
+ [K in keyof ITestShape["suites"]]: (
158
+ name: string,
159
+ givens: IGivens<
160
+ ITestShape
161
+ >,
162
+ checks: BaseCheck<
163
+ ITestShape
164
+ >[]
165
+ ) => BaseSuite<
166
+ ITestShape
167
+ >;
168
+ },
169
+ Given: {
170
+ [K in keyof ITestShape["givens"]]: (
171
+ features: string[],
172
+ whens: BaseWhen<
173
+ ITestShape
174
+ >[],
175
+ thens: BaseThen<
176
+ ITestShape
177
+ >[],
178
+ ...xtrasB: ITestShape["givens"][K]
179
+ ) => BaseGiven<
180
+ ITestShape
181
+ >;
182
+ },
183
+ When: {
184
+ [K in keyof ITestShape["whens"]]: (
185
+ ...xtrasC: ITestShape["whens"][K]
186
+ ) => BaseWhen<
187
+ ITestShape
188
+ >;
189
+ },
190
+ Then: {
191
+ [K in keyof ITestShape["thens"]]: (
192
+ ...xtrasD: ITestShape["thens"][K]
193
+ ) => BaseThen<
194
+ ITestShape
195
+ >;
196
+ },
197
+ Check: ITestCheckCallback<ITestShape>
198
+ ) => any[];
199
+
200
+ export type ITestImplementation<
201
+ ITestShape extends IBaseTest,
202
+ 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>;
319
+
320
+ type Modify<T, R> = Omit<T, keyof R> & R;
321
+
322
+ export type IBaseTest = {
323
+ iinput; // input
324
+ isubject; // subject
325
+ istore; // store
326
+ iselection;
327
+ // iinitial;
328
+
329
+ given;
330
+ when;
331
+ 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[]>;
337
+ };
338
+
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
+ };
package/src/Web.ts CHANGED
@@ -1,241 +1,115 @@
1
+ import type {
2
+ IBaseTest,
3
+ ITestImplementation,
4
+ ITestInterface,
5
+ ITestSpecification
6
+ } from "./Types";
7
+ import Testeranto from "./lib/core.js";
1
8
  import {
2
9
  ITTestResourceConfiguration,
3
10
  ITTestResourceRequest,
4
- ITTestShape,
5
- ITestArtificer,
6
11
  ITestJob,
7
- ITestSpecification,
8
- defaultTestResourceRequirement,
9
- } from "./core";
10
- import TesterantoLevelTwo from "./core";
11
-
12
- let webSocket: WebSocket;
13
- try {
14
- webSocket = new WebSocket("ws://localhost:8080");
15
- } catch (e) {
16
- console.error(e)
17
- }
18
-
19
-
20
- const receiveTestResourceConfigUnscheduled = async (t, testresource) => {
21
- const {
22
- failed,
23
- artifacts,
24
- logPromise
25
- } = await t.receiveTestResourceConfig(testresource);
26
-
27
- Promise.all([...artifacts, logPromise]).then(async () => {
28
- // ipcRenderer.invoke('quit-app', failed);
29
- (window as any).exit(failed)
30
- })
31
- }
32
-
33
- const receiveTestResourceConfigScheduled = async (t, testresource) => {
34
- const {
35
- failed,
36
- artifacts,
37
- logPromise
38
- } = await t.receiveTestResourceConfig(testresource);
39
-
40
- webSocket.send(
41
- JSON.stringify({
42
- type: "testeranto:adios",
43
- data: {
44
- failed,
45
- testResourceConfiguration:
46
- t.test.testResourceConfiguration,
47
- results: t.toObj(),
48
- },
12
+ defaultTestResourceRequirement
13
+ } from "./lib/index.js";
14
+
15
+ const remote = require('@electron/remote')
16
+
17
+ class WebTesteranto<
18
+ TestShape extends IBaseTest,
19
+ > extends Testeranto<
20
+ TestShape
21
+ > {
22
+ constructor(
23
+ input: TestShape["iinput"],
24
+ testSpecification: ITestSpecification<TestShape>,
25
+ testImplementation: ITestImplementation<TestShape, object>,
26
+ testResourceRequirement: ITTestResourceRequest,
27
+ testInterface: Partial<ITestInterface<TestShape>>,
28
+ ) {
29
+ super(
30
+ input,
31
+ testSpecification,
32
+ testImplementation,
33
+ testResourceRequirement,
34
+ (window as any).NodeWriter,
35
+ testInterface,
36
+ // BrowserWindow
37
+ );
38
+
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;
48
+
49
+ this.receiveTestResourceConfig(this.testJobs[0], partialTestResource);
50
+
51
+ } catch (e) {
52
+ console.error(e);
53
+ // process.exit(-1);
54
+ }
55
+ } else {
56
+ // no-op
57
+ }
58
+
59
+ const requesting = new URLSearchParams(location.search).get('requesting');
60
+ if (requesting) {
61
+ const testResourceArg = decodeURIComponent(requesting);
62
+
63
+ try {
64
+ const partialTestResource = JSON.parse(
65
+ testResourceArg
66
+ ) as ITTestResourceConfiguration;
67
+
68
+ console.log("initial test resource", partialTestResource);
69
+ this.receiveTestResourceConfig(this.testJobs[0], partialTestResource);
70
+
71
+ } catch (e) {
72
+ console.error(e);
73
+ // process.exit(-1);
74
+ }
75
+ }
76
+ // const t: ITestJob = this.testJobs[0];
77
+
78
+
79
+
80
+ }
81
+
82
+ async receiveTestResourceConfig(t: ITestJob, partialTestResource: ITTestResourceConfiguration) {
83
+ const {
84
+ failed,
85
+ artifacts,
86
+ logPromise
87
+ } = await t.receiveTestResourceConfig(
88
+ partialTestResource,
89
+ remote
90
+ );
91
+
92
+ Promise.all([...artifacts, logPromise]).then(async () => {
93
+ var window = remote.getCurrentWindow();
94
+ // window.close();
49
95
  })
50
- );
51
-
52
- Promise.all([...artifacts, logPromise]).then(async () => {
53
- // ipcRenderer.invoke('quit-app', failed);
54
- (window as any).exit(failed)
55
- })
56
- }
57
-
58
- export default async <
59
- TestShape extends ITTestShape,
60
- IInput,
61
- ISubject,
62
- IStore,
63
- ISelection,
64
- WhenShape,
65
- IThenShape,
66
- IState
67
- >(
68
- input: IInput,
69
- testSpecification: ITestSpecification<
70
- TestShape,
71
- ISubject,
72
- IStore,
73
- ISelection,
74
- IThenShape
75
- >,
76
- testImplementation,
77
- testInterface: {
78
- actionHandler?: (b: (...any) => any) => any;
79
- andWhen: (
80
- store: IStore,
81
- actioner,
82
- testResource: ITTestResourceConfiguration
83
- ) => Promise<ISelection>;
84
- butThen?: (
85
- store: IStore,
86
- callback,
87
- testResource: ITTestResourceConfiguration
88
- ) => Promise<ISelection>;
89
- assertioner?: (t: IThenShape) => any;
90
-
91
- afterAll?: (store: IStore, artificer: ITestArtificer) => any;
92
- afterEach?: (
93
- store: IStore,
94
- key: string,
95
- artificer: ITestArtificer
96
- ) => Promise<unknown>;
97
- beforeAll?: (input: IInput, artificer: ITestArtificer) => Promise<ISubject>;
98
- beforeEach?: (
99
- subject: ISubject,
100
- initialValues,
101
- testResource: ITTestResourceConfiguration,
102
- artificer: ITestArtificer
103
- ) => Promise<IStore>;
104
- },
105
- testResourceRequirement: ITTestResourceRequest = defaultTestResourceRequirement
106
- ) => {
107
-
108
- console.log("web NodeWriter", (window as any).NodeWriter);
109
-
110
- const mrt = new TesterantoLevelTwo(
96
+ }
97
+
98
+ };
99
+
100
+ export default async <ITestShape extends IBaseTest>(
101
+ input: ITestShape['iinput'],
102
+ testSpecification: ITestSpecification<ITestShape>,
103
+ testImplementation: ITestImplementation<ITestShape, object>,
104
+ testInterface: Partial<ITestInterface<ITestShape>>,
105
+ testResourceRequirement: ITTestResourceRequest = defaultTestResourceRequirement,
106
+ ): Promise<Testeranto<ITestShape>> => {
107
+ return new WebTesteranto<ITestShape>(
111
108
  input,
112
109
  testSpecification,
113
110
  testImplementation,
114
- testInterface,
115
111
  testResourceRequirement,
116
- testInterface.assertioner || (async (t) => t as any),
117
- testInterface.beforeEach ||
118
- async function (subject: any, initialValues: any, testResource: any) {
119
- return subject as any;
120
- },
121
- testInterface.afterEach || (async (s) => s),
122
- testInterface.afterAll || ((store: IStore) => undefined),
123
- testInterface.butThen || (async (a) => a as any),
124
- testInterface.andWhen,
125
- testInterface.actionHandler ||
126
- function (b: (...any: any[]) => any) {
127
- return b;
128
- },
129
- (window as any).NodeWriter
130
- );
131
-
132
- const tl2: TesterantoLevelTwo<any, any, any, any, any, any, any, any> = mrt;
133
- const t: ITestJob = tl2.testJobs[0];
134
- const testResourceArg = decodeURIComponent(
135
- new URLSearchParams(location.search).get('requesting') || ''
136
- );
137
-
138
- try {
139
- const partialTestResource = JSON.parse(
140
- testResourceArg
141
- ) as ITTestResourceConfiguration;
142
-
143
- console.log("initial test resource", partialTestResource);
144
-
145
- if (partialTestResource.scheduled) {
146
- console.log("test is scheduled");
147
-
148
- console.log("awaiting test resources via WS...");
149
- webSocket.addEventListener("open", (event) => {
150
- webSocket.addEventListener("message", (event) => {
151
- console.log("Message from server ", event.data);
152
- });
153
-
154
- const r = JSON.stringify({
155
- type: "testeranto:hola",
156
- data: {
157
- requirement: {
158
- ...testResourceRequirement,
159
- name: partialTestResource.name
160
- }
161
- },
162
- });
163
-
164
- webSocket.send(r);
165
-
166
- console.log("awaiting test resources via websocket...", r);
167
- webSocket.onmessage = (
168
- async (msg: MessageEvent<any>) => {
169
- console.log("message: ", msg);
170
-
171
- const resourcesFromWs = JSON.parse(msg.data);
172
- console.log("secondary test resource", resourcesFromWs);
173
-
174
- const secondTestResource = {
175
- fs: ".",
176
- ...JSON.parse(JSON.stringify(partialTestResource)),
177
- ...JSON.parse(JSON.stringify(resourcesFromWs)),
178
- } as ITTestResourceConfiguration;
179
-
180
- console.log("final test resource", secondTestResource);
181
- receiveTestResourceConfigScheduled(t, secondTestResource);
182
- }
183
- );
184
- });
185
- } else {
186
- receiveTestResourceConfigUnscheduled(t, partialTestResource);
187
- }
112
+ testInterface,
113
+ )
188
114
 
189
- // const partialTestResource = JSON.parse(
190
- // testResourceArg
191
- // ) as ITTestResourceConfiguration;
192
-
193
- // if (partialTestResource.fs && partialTestResource.ports) {
194
- // receiveTestResourceConfig(t, partialTestResource);
195
-
196
-
197
- // } else {
198
- // console.log("test configuration is incomplete", partialTestResource);
199
- // console.log(
200
- // "requesting test resources via ws",
201
- // testResourceRequirement
202
- // );
203
-
204
- // webSocket.addEventListener("open", (event) => {
205
- // webSocket.addEventListener("message", (event) => {
206
- // console.log("Message from server ", event.data);
207
- // });
208
-
209
- // const r = JSON.stringify({
210
- // type: "testeranto:hola",
211
- // data: {
212
- // testResourceRequirement,
213
- // },
214
- // });
215
-
216
- // webSocket.send(r);
217
-
218
- // console.log("awaiting test resources via websocket...", r);
219
- // webSocket.onmessage = (
220
- // async (msg: MessageEvent<any>) => {
221
- // console.log("message: ", msg);
222
-
223
- // const resourcesFromPm2 = msg.data.testResourceConfiguration;
224
- // const secondTestResource = {
225
- // fs: ".",
226
- // ...JSON.parse(JSON.stringify(partialTestResource)),
227
- // ...JSON.parse(JSON.stringify(resourcesFromPm2)),
228
- // } as ITTestResourceConfiguration;
229
-
230
- // console.log("secondTestResource", secondTestResource);
231
- // receiveTestResourceConfig(t, secondTestResource);
232
- // }
233
- // );
234
- // });
235
- // }
236
-
237
- } catch (e) {
238
- console.error(e);
239
- // process.exit(-1);
240
- }
241
115
  };
@@ -0,0 +1,12 @@
1
+ import { createRequire } from 'node:module';
2
+ import path from 'node:path';
3
+ import url from 'node:url';
4
+
5
+ // globalThis.require = createRequire(import.meta.url);
6
+ // globalThis.__filename = url.fileURLToPath(import.meta.url);
7
+ // globalThis.__dirname = path.dirname(__filename);
8
+
9
+ // const p = `${import.meta.url}/..`;
10
+ // globalThis.require = createRequire(`${import.meta.url}/..`);
11
+ // globalThis.__filename = url.fileURLToPath(`${import.meta.url}/..`);
12
+ // globalThis.__dirname = path.dirname(`${__filename}/..`);