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
@@ -0,0 +1,34 @@
1
+ import { Browser, Page } from "puppeteer-core";
2
+
3
+ export class TBrowser {
4
+ browser: Browser;
5
+ constructor(browser: Browser) {
6
+ this.browser = browser;
7
+ }
8
+ pages(): Promise<Page[]> {
9
+
10
+ return new Promise(async (res, rej) => {
11
+
12
+
13
+ res(
14
+ (await this.browser.pages()).map((p) => {
15
+ // const handler = {
16
+ // apply: function (target, thisArg, argumentsList) {
17
+ // console.log('screenshot was called with ' + JSON.stringify(argumentsList));
18
+ // const x: ScreenshotOptions = argumentsList[0]
19
+ // x.path = "./dist/" + x.path;
20
+ // console.log('x.path' + x.path, target, thisArg);
21
+ // return target(...argumentsList);
22
+ // }
23
+ // };
24
+ // p.screenshot = new Proxy(p.screenshot, handler);
25
+ return p;
26
+ })
27
+ );
28
+ });
29
+
30
+ }
31
+ // pages(): Promise<TPage[]> {
32
+ // return super.pages();
33
+ // }
34
+ }
@@ -0,0 +1,137 @@
1
+ import type {
2
+ IBaseTest,
3
+ ICheckKlasser,
4
+ IGivenKlasser,
5
+ ISuiteKlasser,
6
+ ITestImplementation,
7
+ ITestSpecification,
8
+ IThenKlasser,
9
+ IWhenKlasser,
10
+ } from "../Types";
11
+
12
+
13
+ import {
14
+ BaseBuilder
15
+ } from "./basebuilder.js";
16
+
17
+ import {
18
+ ILogWriter,
19
+ ITTestResourceRequest
20
+ } from ".";
21
+
22
+ export abstract class ClassBuilder<
23
+ ITestShape extends IBaseTest
24
+ > extends BaseBuilder<
25
+ ITestShape,
26
+ any,
27
+ any,
28
+ any,
29
+ any,
30
+ any
31
+ > {
32
+
33
+ constructor(
34
+ testImplementation: ITestImplementation<ITestShape, any>,
35
+ testSpecification: ITestSpecification<ITestShape>,
36
+ input: ITestShape['iinput'],
37
+ suiteKlasser: ISuiteKlasser<ITestShape>,
38
+ givenKlasser: IGivenKlasser<ITestShape>,
39
+ whenKlasser: IWhenKlasser<ITestShape>,
40
+ thenKlasser: IThenKlasser<ITestShape>,
41
+ checkKlasser: ICheckKlasser<ITestShape>,
42
+ testResourceRequirement: ITTestResourceRequest,
43
+ logWriter: ILogWriter
44
+ ) {
45
+ const classySuites = Object.entries(testImplementation.suites).reduce(
46
+ (a, [key], index) => {
47
+ a[key] = (somestring, givens, checks) => {
48
+ return new suiteKlasser.prototype.constructor(
49
+ somestring,
50
+ index,
51
+ givens,
52
+ checks
53
+ );
54
+ };
55
+ return a;
56
+ },
57
+ {}
58
+ );
59
+ const classyGivens = Object.entries(testImplementation.givens)
60
+ .reduce(
61
+ (a, [key, givEn]) => {
62
+ a[key] = (
63
+ features,
64
+ whens,
65
+ thens,
66
+ givEn,
67
+ ) => {
68
+ return new (givenKlasser.prototype).constructor(
69
+ key,
70
+ features,
71
+ whens,
72
+ thens,
73
+ testImplementation.givens[key],
74
+ givEn
75
+ );
76
+ };
77
+ return a;
78
+ },
79
+ {}
80
+ );
81
+
82
+ const classyWhens = Object.entries(testImplementation.whens).reduce(
83
+ (a, [key, whEn]: [string, (x) => any]) => {
84
+ a[key] = (payload?: any) => {
85
+ return new whenKlasser.prototype.constructor(
86
+ `${whEn.name}: ${payload && payload.toString()}`,
87
+ whEn(payload)
88
+ );
89
+ };
90
+ return a;
91
+ },
92
+ {}
93
+ );
94
+
95
+ const classyThens = Object.entries(testImplementation.thens).reduce(
96
+ (a, [key, thEn]: [string, (x) => any]) => {
97
+ a[key] = (expected: any, x) => {
98
+ return new thenKlasser.prototype.constructor(
99
+ `${thEn.name}: ${expected && expected.toString()}`,
100
+ thEn(expected)
101
+ );
102
+ };
103
+ return a;
104
+ },
105
+ {}
106
+ );
107
+
108
+ const classyChecks = Object.entries(testImplementation.checks).reduce(
109
+ (a, [key, z]) => {
110
+ a[key] = (somestring, features, callback) => {
111
+ return new checkKlasser.prototype.constructor(
112
+ somestring,
113
+ features,
114
+ callback,
115
+ classyWhens,
116
+ classyThens
117
+ );
118
+ };
119
+ return a;
120
+ },
121
+ {}
122
+ );
123
+
124
+ super(
125
+ input,
126
+ classySuites,
127
+ classyGivens,
128
+ classyWhens,
129
+ classyThens,
130
+ classyChecks,
131
+ logWriter,
132
+ testResourceRequirement,
133
+ testSpecification
134
+ );
135
+ }
136
+
137
+ }
@@ -0,0 +1,182 @@
1
+ import type {
2
+ IBaseTest, ITestImplementation, ITestInterface, ITestSpecification, IUtils
3
+ } from "../Types";
4
+
5
+ import {
6
+ DefaultTestInterface,
7
+ ILogWriter,
8
+ ITTestResourceConfiguration,
9
+ ITTestResourceRequest,
10
+ ITestArtifactory,
11
+ ITestJob,
12
+ defaultTestResourceRequirement
13
+ } from "./index.js";
14
+ import {
15
+ BaseSuite, BaseGiven, BaseWhen, BaseThen, BaseCheck
16
+ } from "./abstractBase.js";
17
+ import {
18
+ ClassBuilder
19
+ } from "./classBuilder.js";
20
+ import { IStore } from "../SubPackages/react/jsx";
21
+
22
+ export default abstract class Testeranto<ITestShape extends IBaseTest> extends ClassBuilder<ITestShape> {
23
+ constructor(
24
+ input: ITestShape['iinput'],
25
+ testSpecification: ITestSpecification<ITestShape>,
26
+ testImplementation: ITestImplementation<ITestShape, object>,
27
+ testResourceRequirement: ITTestResourceRequest = defaultTestResourceRequirement,
28
+ logWriter: ILogWriter,
29
+ testInterface: Partial<ITestInterface<ITestShape>>,
30
+ ) {
31
+ const fullTestInterface = DefaultTestInterface(testInterface);
32
+
33
+ super(
34
+ testImplementation,
35
+ testSpecification,
36
+ input,
37
+
38
+ class extends BaseSuite<
39
+ ITestShape
40
+ > {
41
+
42
+ assertThat(t) {
43
+ fullTestInterface.assertThis(t);
44
+ }
45
+
46
+ async setup(
47
+ s: ITestShape['iinput'],
48
+ artifactory: ITestArtifactory,
49
+ tr,
50
+ // utils: ITestInterface<ITestShape>
51
+ ): Promise<
52
+ ITestShape['isubject']
53
+ > {
54
+ return (fullTestInterface.beforeAll || (async (
55
+ input: ITestShape['iinput'],
56
+ artifactory: ITestArtifactory,
57
+ tr,
58
+ // utils: ITestInterface<ITestShape>
59
+ ) => input as any))(
60
+ s,
61
+ this.testResourceConfiguration,
62
+ artifactory
63
+ );
64
+ }
65
+ } as any,
66
+
67
+ class Given extends BaseGiven<
68
+ ITestShape
69
+ > {
70
+
71
+ async givenThat(subject, testResource, artifactory, initializer) {
72
+ return fullTestInterface.beforeEach(
73
+ subject,
74
+ initializer,
75
+ (fPath: string, value: unknown) =>
76
+ // TODO does not work?
77
+ artifactory(`beforeEach/${fPath}`, value),
78
+ testResource,
79
+ this.initialValues,
80
+ // utils,
81
+ );
82
+ }
83
+
84
+ afterEach(
85
+ store: ITestShape['istore'],
86
+ key: string,
87
+ artifactory
88
+ ): Promise<unknown> {
89
+ return new Promise((res) =>
90
+ res(fullTestInterface.afterEach(store, key, (fPath: string, value: unknown) =>
91
+ artifactory(`after/${fPath}`, value)))
92
+ );
93
+ }
94
+ afterAll(
95
+ store: IStore,
96
+ artifactory: ITestArtifactory,
97
+ utils: IUtils,
98
+ ) {
99
+ return fullTestInterface.afterAll(store, (fPath: string, value: unknown) =>
100
+ // TODO does not work?
101
+ { artifactory(`afterAll4-${this.name}/${fPath}`, value) },
102
+ utils
103
+ );
104
+ }
105
+ } as any,
106
+
107
+ class When extends BaseWhen<
108
+ ITestShape
109
+ > {
110
+ async andWhen(store, whenCB, testResource) {
111
+ return await fullTestInterface.andWhen(store, whenCB, testResource);
112
+ }
113
+ } as any,
114
+
115
+ class Then extends BaseThen<
116
+ ITestShape
117
+ > {
118
+
119
+ async butThen(
120
+ store: any,
121
+ thenCB,
122
+ testResourceConfiguration?: any
123
+ ): Promise<ITestShape['iselection']> {
124
+ return await fullTestInterface.butThen(
125
+ store,
126
+ thenCB,
127
+ testResourceConfiguration);
128
+ }
129
+ } as any,
130
+
131
+ class Check extends BaseCheck<
132
+ ITestShape
133
+ > {
134
+ initialValues: any;
135
+
136
+ constructor(
137
+ name: string,
138
+ features: string[],
139
+ checkCallback: (a, b) => any,
140
+ whens,
141
+ thens,
142
+ initialValues: any
143
+ ) {
144
+ super(name, features, checkCallback, whens, thens);
145
+ this.initialValues = initialValues;
146
+ }
147
+
148
+ async checkThat(subject, testResourceConfiguration, artifactory) {
149
+ return fullTestInterface.beforeEach(
150
+ subject,
151
+ this.initialValues,
152
+ (fPath: string, value: unknown) => artifactory(`before/${fPath}`, value),
153
+ testResourceConfiguration,
154
+ this.initialValues
155
+ );
156
+ }
157
+
158
+ afterEach(
159
+ store: ITestShape['istore'],
160
+ key: string,
161
+ artifactory
162
+ ): Promise<unknown> {
163
+ return new Promise((res) =>
164
+ res(fullTestInterface.afterEach(store, key, (fPath: string, value: unknown) =>
165
+ // TODO does not work?
166
+ artifactory(`afterEach2-${this.name}/${fPath}`, value)))
167
+ );
168
+ }
169
+ } as any,
170
+
171
+ testResourceRequirement,
172
+ logWriter,
173
+ );
174
+ }
175
+
176
+ abstract receiveTestResourceConfig(
177
+ t: ITestJob,
178
+ partialTestResource: ITTestResourceConfiguration,
179
+ utils: IUtils
180
+ );
181
+
182
+ }
@@ -0,0 +1,116 @@
1
+
2
+ import { IBaseTest, ITestInterface, IUtils } from "../Types.js";
3
+ import { IGivens, BaseCheck, BaseSuite, BaseWhen, BaseThen } from "./abstractBase.js";
4
+
5
+ export const BaseTestInterface: ITestInterface<IBaseTest> = {
6
+ beforeAll: (async (s) => s),
7
+ beforeEach: async function (subject: any, initialValues: any, testResource: any) { return subject as any; },
8
+ afterEach: (async (s) => s),
9
+ afterAll: ((store: IBaseTest['istore']) => undefined),
10
+ butThen: (async (store: IBaseTest['istore'], thenCb) => thenCb(store)),
11
+ andWhen: ((a) => a),
12
+ assertThis: (() => null),
13
+ };
14
+
15
+ export const DefaultTestInterface = (p: Partial<ITestInterface<any>>): ITestInterface<any> => {
16
+ return {
17
+ ...BaseTestInterface,
18
+ ...p
19
+ }
20
+ }
21
+
22
+ export type ITTestResourceConfiguration = {
23
+ name: string;
24
+ fs: string;
25
+ ports: number[];
26
+ scheduled: boolean;
27
+ };
28
+
29
+ export type ITTestResourceRequirement = {
30
+ name: string;
31
+ ports: number;
32
+ fs: string;
33
+ };
34
+
35
+ export type ITTestResourceRequest = {
36
+ ports: number;
37
+ };
38
+
39
+ export type ITLog = (...string) => void;
40
+
41
+ export type ILogWriter = {
42
+ createWriteStream: (line: string) => any | any,
43
+ writeFileSync: (fp: string, contents: string) => any
44
+ mkdirSync: (fp: string) => any
45
+ testArtiFactoryfileWriter: (tLog: ITLog, n: (Promise) => void) =>
46
+ (fPath: string, value: unknown) =>
47
+ void
48
+ }
49
+
50
+ export type ITestArtificer = (key: string, data: any) => void;
51
+
52
+ type ITest = {
53
+ toObj(): object;
54
+ name: string;
55
+ givens: IGivens<
56
+ IBaseTest
57
+ >;
58
+ checks: BaseCheck<
59
+ IBaseTest
60
+ >[];
61
+ testResourceConfiguration: ITTestResourceConfiguration;
62
+ };
63
+
64
+ export type ITestJob = {
65
+ toObj(): object;
66
+ test: ITest;
67
+ runner: (x: ITTestResourceConfiguration, t: ITLog) => Promise<
68
+ BaseSuite<
69
+ IBaseTest
70
+ >
71
+ >;
72
+ testResourceRequirement: ITTestResourceRequirement;
73
+ receiveTestResourceConfig: (
74
+ testResource,
75
+ utils: IUtils
76
+ ) => Promise<{
77
+ failed: number,
78
+ artifacts: Promise<unknown>[],
79
+ logPromise: Promise<unknown>
80
+ }>
81
+ };
82
+
83
+ export type ITestResults = Promise<{ test: ITest }>[];
84
+
85
+ export const defaultTestResourceRequirement: ITTestResourceRequest = {
86
+ ports: 0
87
+ };
88
+
89
+ export type ITestArtifactory = (key: string, value: unknown) => unknown;
90
+
91
+ export type ITestCheckCallback<ITestShape extends IBaseTest> = {
92
+ [K in keyof ITestShape["checks"]]: (
93
+ name: string,
94
+ features: string[],
95
+ callbackA: (
96
+ whens: {
97
+ [K in keyof ITestShape["whens"]]: (
98
+ ...unknown
99
+ ) => BaseWhen<
100
+ ITestShape
101
+ >;
102
+ },
103
+ thens: {
104
+ [K in keyof ITestShape["thens"]]: (
105
+ ...unknown
106
+ ) => BaseThen<
107
+ ITestShape
108
+ >;
109
+ }
110
+ ) => Promise<any>,
111
+ ...xtrasA: ITestShape["checks"][K]
112
+ ) => BaseCheck<
113
+ ITestShape
114
+ >;
115
+ };
116
+
@@ -0,0 +1,71 @@
1
+ // import fs from "fs";
2
+ const fs = require("fs");
3
+ // import path from "path";
4
+ const path = require("path");
5
+ import { PassThrough } from "stream";
6
+
7
+ import { ILogWriter, ITLog } from "./lib/index.js";
8
+
9
+ type IFPaths = string[];
10
+ const fPaths: IFPaths = [];
11
+
12
+ export const NodeWriterElectron: ILogWriter = {
13
+ createWriteStream: (filepath: string): fs.WriteStream => {
14
+ return fs.createWriteStream(filepath);
15
+ },
16
+ writeFileSync: (fp: string, contents: string) => {
17
+ fs.writeFileSync(
18
+ fp,
19
+ contents
20
+ );
21
+ },
22
+ mkdirSync: async (fp: string) => {
23
+ await fs.mkdirSync(fp, { recursive: true });
24
+ },
25
+ testArtiFactoryfileWriter:
26
+ (tLog: ITLog, callback: (Promise) => void) =>
27
+ (fPath, value: string | Buffer | PassThrough) => {
28
+ callback(new Promise<void>((res, rej) => {
29
+ tLog("testArtiFactory =>", fPath);
30
+
31
+ const cleanPath = path.resolve(fPath);
32
+ fPaths.push(cleanPath.replace(process.cwd(), ``));
33
+
34
+ const targetDir = cleanPath.split("/").slice(0, -1).join("/");
35
+
36
+ fs.mkdir(targetDir, { recursive: true }, async (error) => {
37
+ if (error) {
38
+ console.error(`❗️testArtiFactory failed`, targetDir, error);
39
+ }
40
+
41
+ fs.writeFileSync(
42
+ path.resolve(targetDir.split("/").slice(0, -1).join("/"), "manifest"),
43
+ fPaths.join(`\n`),
44
+ {
45
+ encoding: "utf-8",
46
+ }
47
+ );
48
+
49
+ if (Buffer.isBuffer(value)) {
50
+ fs.writeFileSync(fPath, value, "binary");
51
+ res();
52
+ } else if (`string` === typeof value) {
53
+ fs.writeFileSync(fPath, value.toString(), {
54
+ encoding: "utf-8",
55
+ });
56
+ res();
57
+ } else {
58
+ /* @ts-ignore:next-line */
59
+ const pipeStream: PassThrough = value;
60
+ const myFile = fs.createWriteStream(fPath);
61
+ pipeStream.pipe(myFile);
62
+ pipeStream.on("close", () => {
63
+ myFile.close();
64
+ res();
65
+ });
66
+ }
67
+ });
68
+ }))
69
+
70
+ }
71
+ }
package/src/preload.ts CHANGED
@@ -1,31 +1,33 @@
1
- import { NodeWriter } from "./NodeWriter";
2
1
  import { ipcRenderer } from "electron";
3
2
 
3
+ console.log("hello preloader");
4
+ import { NodeWriter } from "./NodeWriter";
5
+
4
6
  (window as any).NodeWriter = NodeWriter;
5
7
  (window as any).exit = (x) => {
6
8
  ipcRenderer.invoke('quit-app', x);
7
9
  }
8
10
 
9
- var oldLog = console.log;
10
- console.log = function (message) {
11
- ipcRenderer.invoke('web-log', message.toString());
12
- oldLog.apply(console, arguments);
13
- };
11
+ // var oldLog = console.log;
12
+ // console.log = function (message) {
13
+ // ipcRenderer.invoke('web-log', message.toString());
14
+ // oldLog.apply(console, arguments);
15
+ // };
14
16
 
15
- var oldLog = console.error;
16
- console.error = function (message) {
17
- ipcRenderer.invoke('web-error', message.toString());
18
- oldLog.apply(console, arguments);
19
- };
17
+ // var oldLog = console.error;
18
+ // console.error = function (message) {
19
+ // ipcRenderer.invoke('web-error', message.toString());
20
+ // oldLog.apply(console, arguments);
21
+ // };
20
22
 
21
- var oldLog = console.warn;
22
- console.warn = function (message) {
23
- ipcRenderer.invoke('web-warn', message.toString());
24
- oldLog.apply(console, arguments);
25
- };
23
+ // var oldLog = console.warn;
24
+ // console.warn = function (message) {
25
+ // ipcRenderer.invoke('web-warn', message.toString());
26
+ // oldLog.apply(console, arguments);
27
+ // };
26
28
 
27
- var oldLog = console.info;
28
- console.info = function (message) {
29
- ipcRenderer.invoke('web-info', message.toString());
30
- oldLog.apply(console, arguments);
31
- };
29
+ // var oldLog = console.info;
30
+ // console.info = function (message) {
31
+ // ipcRenderer.invoke('web-info', message.toString());
32
+ // oldLog.apply(console, arguments);
33
+ // };
@@ -0,0 +1,29 @@
1
+ export default () => `
2
+ <!DOCTYPE html>
3
+ <html lang="en">
4
+
5
+ <head>
6
+ <meta name="description" content="Webpage description goes here" />
7
+ <meta charset="utf-8" />
8
+ <title>kokomoBay - testeranto</title>
9
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
10
+ <meta name="author" content="" />
11
+
12
+ <link rel="stylesheet" href="./Report.css">
13
+
14
+ <script type="importmap">
15
+ {
16
+ "imports": {
17
+ "features.test.js": "./features.test.js",
18
+ "testeranto.json": "./testeranto.json"
19
+ }
20
+ }
21
+ </script>
22
+
23
+ <script type="module" src="./Report.js"></script>
24
+ </head>
25
+
26
+ <body><div id="root">react is loading</div></body>
27
+
28
+ </html>
29
+ `;
@@ -0,0 +1,20 @@
1
+ export default (jsfilePath: string, htmlFilePath: string) => `
2
+ <!DOCTYPE html>
3
+ <html lang="en">
4
+
5
+ <head>
6
+ <script type="module" src="${jsfilePath}"></script>
7
+
8
+ </head>
9
+
10
+ <body>
11
+ <h1>${htmlFilePath}</h1>
12
+ <div id="root">
13
+
14
+ </div>
15
+ </body>
16
+
17
+ <footer></footer>
18
+
19
+ </html>
20
+ `