testeranto 0.134.0 → 0.140.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 (221) hide show
  1. package/.aider.chat.history.md +14577 -0
  2. package/.aider.input.history +566 -0
  3. package/.aider.tags.cache.v3/{8d/fa/12860238755bcfab9af8a93c52ab.val → bd/91/b71f967fd074cf4b757081b429b7.val} +0 -0
  4. package/.aider.tags.cache.v3/cache.db +0 -0
  5. package/.aider.tags.cache.v3/{18/8b/7dfca822129dad10b5cacadf7728.val → fb/96/b0f91c7e75e08fc5a6907633cf99.val} +0 -0
  6. package/README.md +29 -423
  7. package/bundle.js +1 -1
  8. package/dist/common/src/CoreTypes.js +2 -0
  9. package/dist/common/src/Init.js +4 -1
  10. package/dist/common/src/Node.js +1 -1
  11. package/dist/common/src/PM/PM_WithEslintAndTsc.js +10 -8
  12. package/dist/common/src/PM/__tests__/nodeSidecar.testeranto.js +2 -2
  13. package/dist/common/src/PM/main.js +12 -7
  14. package/dist/common/src/PM/node.js +10 -3
  15. package/dist/common/src/Web.js +2 -2
  16. package/dist/common/src/build.js +7 -72
  17. package/dist/common/src/defaultConfig.js +0 -1
  18. package/dist/common/src/esbuildConfigs/eslint-formatter-testeranto.js +16 -1
  19. package/dist/common/src/esbuildConfigs/node.js +2 -16
  20. package/dist/common/src/esbuildConfigs/pure.js +2 -16
  21. package/dist/common/src/esbuildConfigs/rebuildPlugin.js +22 -0
  22. package/dist/common/src/esbuildConfigs/web.js +2 -16
  23. package/dist/common/src/lib/abstractBase.js +8 -1
  24. package/dist/common/src/lib/basebuilder.js +4 -0
  25. package/dist/common/src/lib/classBuilder.js +2 -3
  26. package/dist/common/src/lib/core.js +2 -0
  27. package/dist/common/src/run.js +1 -1
  28. package/dist/common/src/utils/buildTemplates.js +88 -0
  29. package/dist/common/tsconfig.common.tsbuildinfo +1 -1
  30. package/dist/module/src/Init.js +4 -1
  31. package/dist/module/src/Node.js +1 -1
  32. package/dist/module/src/PM/PM_WithEslintAndTsc.js +10 -8
  33. package/dist/module/src/PM/__tests__/nodeSidecar.testeranto.js +2 -2
  34. package/dist/module/src/PM/main.js +12 -7
  35. package/dist/module/src/PM/node.js +10 -3
  36. package/dist/module/src/Project.js +41 -47
  37. package/dist/module/src/TestReport.js +34 -31
  38. package/dist/module/src/Web.js +2 -2
  39. package/dist/module/src/build.js +7 -72
  40. package/dist/module/src/defaultConfig.js +0 -1
  41. package/dist/module/src/esbuildConfigs/eslint-formatter-testeranto.js +16 -1
  42. package/dist/module/src/esbuildConfigs/node.js +2 -16
  43. package/dist/module/src/esbuildConfigs/pure.js +2 -16
  44. package/dist/module/src/esbuildConfigs/rebuildPlugin.js +17 -0
  45. package/dist/module/src/esbuildConfigs/web.js +2 -16
  46. package/dist/module/src/lib/abstractBase.js +8 -1
  47. package/dist/module/src/lib/basebuilder.js +4 -0
  48. package/dist/module/src/lib/classBuilder.js +2 -3
  49. package/dist/module/src/lib/core.js +2 -0
  50. package/dist/module/src/run.js +1 -1
  51. package/dist/module/src/utils/buildTemplates.js +82 -0
  52. package/dist/module/tsconfig.module.tsbuildinfo +1 -1
  53. package/dist/prebuild/Project.js +77 -29
  54. package/dist/prebuild/TestReport.js +51 -32
  55. package/dist/prebuild/build.mjs +132 -131
  56. package/dist/prebuild/esbuildConfigs/eslint-formatter-testeranto.mjs +14 -1
  57. package/dist/prebuild/init-docs.mjs +0 -4
  58. package/dist/prebuild/run.mjs +50 -31
  59. package/dist/tsconfig.tsbuildinfo +1 -0
  60. package/dist/types/src/CoreTypes.d.ts +53 -0
  61. package/dist/types/src/Node.d.ts +3 -3
  62. package/dist/types/src/PM/__tests__/nodeSidecar.testeranto.d.ts +2 -4
  63. package/dist/types/src/PM/__tests__/pureSidecar.testeranto.d.ts +2 -4
  64. package/dist/types/src/PM/__tests__/webSidecar.testeranto.d.ts +2 -4
  65. package/dist/types/src/PM/index.d.ts +1 -1
  66. package/dist/types/src/PM/nodeSidecar.d.ts +2 -2
  67. package/dist/types/src/Pure.d.ts +3 -3
  68. package/dist/types/src/Types.d.ts +21 -61
  69. package/dist/types/src/Web.d.ts +3 -3
  70. package/dist/types/src/esbuildConfigs/rebuildPlugin.d.ts +6 -0
  71. package/dist/types/src/lib/abstractBase.d.ts +10 -16
  72. package/dist/types/src/lib/basebuilder.d.ts +3 -3
  73. package/dist/types/src/lib/classBuilder.d.ts +2 -2
  74. package/dist/types/src/lib/core.d.ts +2 -2
  75. package/dist/types/src/lib/index.d.ts +7 -6
  76. package/dist/types/src/lib/types.d.ts +8 -8
  77. package/dist/types/src/mothership/test.d.ts +2 -2
  78. package/dist/types/src/utils/buildTemplates.d.ts +3 -0
  79. package/dist/types/tsconfig.types.tsbuildinfo +1 -1
  80. package/docs/index.md +567 -0
  81. package/docs/style.md +116 -0
  82. package/docs.html +537 -0
  83. package/example.css +351 -0
  84. package/fonts/M_PLUS_Rounded_1c/MPLUSRounded1c-Black.ttf +0 -0
  85. package/fonts/M_PLUS_Rounded_1c/MPLUSRounded1c-Bold.ttf +0 -0
  86. package/fonts/M_PLUS_Rounded_1c/MPLUSRounded1c-ExtraBold.ttf +0 -0
  87. package/fonts/M_PLUS_Rounded_1c/MPLUSRounded1c-Light.ttf +0 -0
  88. package/fonts/M_PLUS_Rounded_1c/MPLUSRounded1c-Medium.ttf +0 -0
  89. package/fonts/M_PLUS_Rounded_1c/MPLUSRounded1c-Regular.ttf +0 -0
  90. package/fonts/M_PLUS_Rounded_1c/MPLUSRounded1c-Thin.ttf +0 -0
  91. package/fonts/M_PLUS_Rounded_1c/OFL.txt +91 -0
  92. package/index.html +245 -24
  93. package/logo.svg +72 -0
  94. package/package.json +11 -2
  95. package/scripts/compile-docs.js +89 -0
  96. package/src/CoreTypes.ts +152 -0
  97. package/src/Init.ts +4 -4
  98. package/src/Node.ts +13 -13
  99. package/src/PM/PM_WithEslintAndTsc.ts +46 -15
  100. package/src/PM/__tests__/nodeSidecar.testeranto.ts +13 -20
  101. package/src/PM/__tests__/pureSidecar.testeranto.ts +8 -15
  102. package/src/PM/__tests__/webSidecar.testeranto.ts +8 -15
  103. package/src/PM/index.ts +1 -1
  104. package/src/PM/main.ts +17 -16
  105. package/src/PM/node.ts +10 -10
  106. package/src/PM/nodeSidecar.ts +2 -2
  107. package/src/PM/pure.ts +0 -4
  108. package/src/Project.tsx +289 -292
  109. package/src/Pure.ts +13 -14
  110. package/src/PureSidecar.ts +1 -0
  111. package/src/TestReport.tsx +179 -165
  112. package/src/Types.ts +52 -151
  113. package/src/Web.ts +15 -14
  114. package/src/build.ts +22 -72
  115. package/src/defaultConfig.ts +2 -1
  116. package/src/esbuildConfigs/eslint-formatter-testeranto.ts +17 -1
  117. package/src/esbuildConfigs/node.ts +2 -18
  118. package/src/esbuildConfigs/pure.ts +2 -18
  119. package/src/esbuildConfigs/rebuildPlugin.ts +23 -0
  120. package/src/esbuildConfigs/web.ts +2 -18
  121. package/src/lib/BaseSuite.test.ts +457 -0
  122. package/src/lib/BaseSuite.ts +155 -0
  123. package/src/lib/abstractBase.ts +13 -163
  124. package/src/lib/basebuilder.ts +11 -11
  125. package/src/lib/classBuilder.ts +13 -7
  126. package/src/lib/core.ts +13 -17
  127. package/src/lib/index.ts +21 -24
  128. package/src/lib/types.ts +23 -9
  129. package/src/mothership/test.ts +13 -10
  130. package/src/run.ts +1 -1
  131. package/src/style.css +1 -1
  132. package/src/utils/buildTemplates.ts +88 -0
  133. package/style.css +496 -0
  134. package/testeranto/bundles/node/{mothership/chunk-V2EQEXU2.mjs → allTests/chunk-4PJCC2XT.mjs} +66 -59
  135. package/testeranto/bundles/node/allTests/metafile.json +4151 -0
  136. package/testeranto/bundles/node/allTests/src/PM/__tests__/nodeSidecar.testeranto.mjs +187 -0
  137. package/testeranto/bundles/node/{mothership → allTests}/src/PM/__tests__/pureSidecar.testeranto.mjs +1 -1
  138. package/testeranto/bundles/node/{mothership → allTests}/src/PM/__tests__/webSidecar.testeranto.mjs +1 -1
  139. package/testeranto/bundles/node/allTests/src/lib/BaseSuite.test.mjs +305 -0
  140. package/testeranto/bundles/node/{mothership → allTests}/src/mothership/test.mjs +1 -1
  141. package/testeranto/dev.html +29 -0
  142. package/testeranto/index.html +28 -27
  143. package/testeranto/reports/allTests/config.json +57 -0
  144. package/testeranto/reports/{mothership/index.html → allTests/dev.html} +2 -0
  145. package/testeranto/reports/allTests/index.html +26 -0
  146. package/testeranto/reports/{mothership/src/PM/__tests__/sidecar.testeranto/node/index.html → allTests/src/PM/__tests__/nodeSidecar.testeranto/node/dev.html} +4 -3
  147. package/testeranto/reports/allTests/src/PM/__tests__/nodeSidecar.testeranto/node/index.html +21 -0
  148. package/testeranto/reports/allTests/src/PM/__tests__/nodeSidecar.testeranto/node/lint_errors.json +80 -0
  149. package/testeranto/reports/allTests/src/PM/__tests__/nodeSidecar.testeranto/node/message +1 -0
  150. package/testeranto/reports/allTests/src/PM/__tests__/nodeSidecar.testeranto/node/prompt.txt +8 -0
  151. package/testeranto/reports/allTests/src/PM/__tests__/nodeSidecar.testeranto/node/type_errors.txt +28 -0
  152. package/testeranto/reports/{mothership/src/PM/__tests__/webSidecar.testeranto/node/index.html → allTests/src/PM/__tests__/pureSidecar.testeranto/node/dev.html} +4 -3
  153. package/testeranto/reports/allTests/src/PM/__tests__/pureSidecar.testeranto/node/index.html +21 -0
  154. package/testeranto/reports/{mothership → allTests}/src/PM/__tests__/pureSidecar.testeranto/node/lint_errors.json +12 -12
  155. package/testeranto/reports/allTests/src/PM/__tests__/pureSidecar.testeranto/node/message +1 -0
  156. package/testeranto/reports/allTests/src/PM/__tests__/pureSidecar.testeranto/node/prompt.txt +8 -0
  157. package/testeranto/reports/allTests/src/PM/__tests__/pureSidecar.testeranto/node/type_errors.txt +32 -0
  158. package/testeranto/reports/{mothership/src/PM/__tests__/nodeSidecar.testeranto/node/index.html → allTests/src/PM/__tests__/webSidecar.testeranto/node/dev.html} +4 -3
  159. package/testeranto/reports/allTests/src/PM/__tests__/webSidecar.testeranto/node/index.html +21 -0
  160. package/testeranto/reports/{mothership → allTests}/src/PM/__tests__/webSidecar.testeranto/node/lint_errors.json +12 -12
  161. package/testeranto/reports/allTests/src/PM/__tests__/webSidecar.testeranto/node/message +1 -0
  162. package/testeranto/reports/allTests/src/PM/__tests__/webSidecar.testeranto/node/prompt.txt +8 -0
  163. package/testeranto/reports/allTests/src/PM/__tests__/webSidecar.testeranto/node/type_errors.txt +32 -0
  164. package/testeranto/reports/allTests/src/lib/BaseSuite.test/node/console_log.txt +35 -0
  165. package/testeranto/reports/{mothership/src/PM/__tests__/pureSidecar.testeranto/node/index.html → allTests/src/lib/BaseSuite.test/node/dev.html} +4 -3
  166. package/testeranto/reports/allTests/src/lib/BaseSuite.test/node/index.html +21 -0
  167. package/testeranto/reports/allTests/src/lib/BaseSuite.test/node/lint_errors.json +608 -0
  168. package/testeranto/reports/allTests/src/lib/BaseSuite.test/node/message +1 -0
  169. package/testeranto/reports/allTests/src/lib/BaseSuite.test/node/prompt.txt +7 -0
  170. package/testeranto/reports/allTests/src/lib/BaseSuite.test/node/type_errors.txt +68 -0
  171. package/testeranto/reports/allTests/src/mothership/test/node/dev.html +21 -0
  172. package/testeranto/reports/allTests/src/mothership/test/node/index.html +21 -0
  173. package/testeranto/reports/allTests/src/mothership/test/node/message +1 -0
  174. package/testeranto/reports/allTests/src/mothership/test/node/prompt.txt +8 -0
  175. package/testeranto/reports/allTests/src/mothership/test/node/type_errors.txt +24 -0
  176. package/testeranto/reports/allTests/summary.json +37 -0
  177. package/testeranto.config.ts +16 -26
  178. package/tsc.log +66 -69
  179. package/.aider.tags.cache.v3/cache.db-shm +0 -0
  180. package/.aider.tags.cache.v3/cache.db-wal +0 -0
  181. package/dist/common/src/SP__Polygon.test.js +0 -10
  182. package/dist/module/src/ReportClient.js +0 -132
  183. package/dist/module/src/SP__Polygon.test.js +0 -8
  184. package/dist/prebuild/ReportClient.js +0 -3
  185. package/src/ReportClient.tsx +0 -164
  186. package/src/SP__Polygon.test.ts +0 -13
  187. package/testeranto/ReportClient.css +0 -11367
  188. package/testeranto/ReportClient.js +0 -24641
  189. package/testeranto/bundles/node/mothership/metafile.json +0 -389
  190. package/testeranto/bundles/node/mothership/src/PM/__tests__/nodeSidecar.testeranto.mjs +0 -1219
  191. package/testeranto/bundles/node/mothership/src/PM/__tests__/sidecar.testeranto.mjs +0 -1199
  192. package/testeranto/reports/mothership/config.json +0 -25
  193. package/testeranto/reports/mothership/src/PM/__tests__/nodeSidecar.testeranto/node/console_log.txt +0 -0
  194. package/testeranto/reports/mothership/src/PM/__tests__/nodeSidecar.testeranto/node/lint_errors.json +0 -1564
  195. package/testeranto/reports/mothership/src/PM/__tests__/nodeSidecar.testeranto/node/prompt.txt +0 -22
  196. package/testeranto/reports/mothership/src/PM/__tests__/nodeSidecar.testeranto/node/type_errors.txt +0 -35
  197. package/testeranto/reports/mothership/src/PM/__tests__/pureSidecar.testeranto/node/prompt.txt +0 -12
  198. package/testeranto/reports/mothership/src/PM/__tests__/pureSidecar.testeranto/node/type_errors.txt +0 -26
  199. package/testeranto/reports/mothership/src/PM/__tests__/sidecar.testeranto/node/bdd_errors.txt +0 -1
  200. package/testeranto/reports/mothership/src/PM/__tests__/sidecar.testeranto/node/console_log.txt +0 -0
  201. package/testeranto/reports/mothership/src/PM/__tests__/sidecar.testeranto/node/lint_errors.json +0 -1564
  202. package/testeranto/reports/mothership/src/PM/__tests__/sidecar.testeranto/node/log.txt +0 -0
  203. package/testeranto/reports/mothership/src/PM/__tests__/sidecar.testeranto/node/prompt.txt +0 -22
  204. package/testeranto/reports/mothership/src/PM/__tests__/sidecar.testeranto/node/tests.json +0 -56
  205. package/testeranto/reports/mothership/src/PM/__tests__/sidecar.testeranto/node/type_errors.txt +0 -29
  206. package/testeranto/reports/mothership/src/PM/__tests__/webSidecar.testeranto/node/prompt.txt +0 -12
  207. package/testeranto/reports/mothership/src/PM/__tests__/webSidecar.testeranto/node/type_errors.txt +0 -26
  208. package/testeranto/reports/mothership/src/mothership/test/node/bdd_errors.txt +0 -1
  209. package/testeranto/reports/mothership/src/mothership/test/node/console_log.txt +0 -4
  210. package/testeranto/reports/mothership/src/mothership/test/node/index.html +0 -20
  211. package/testeranto/reports/mothership/src/mothership/test/node/log.txt +0 -0
  212. package/testeranto/reports/mothership/src/mothership/test/node/prompt.txt +0 -12
  213. package/testeranto/reports/mothership/src/mothership/test/node/tests.json +0 -24
  214. package/testeranto/reports/mothership/src/mothership/test/node/type_errors.txt +0 -18
  215. package/testeranto/reports/mothership/summary.json +0 -9
  216. /package/dist/{types/src/SP__Polygon.test.d.ts → module/src/CoreTypes.js} +0 -0
  217. /package/testeranto/bundles/node/{mothership → allTests}/chunk-PG6KUKNP.mjs +0 -0
  218. /package/testeranto/bundles/pure/{mothership → allTests}/metafile.json +0 -0
  219. /package/testeranto/bundles/web/{mothership → allTests}/metafile.json +0 -0
  220. /package/testeranto/reports/{mothership/src/PM/__tests__/nodeSidecar.testeranto → allTests/src/lib/BaseSuite.test}/node/log.txt +0 -0
  221. /package/testeranto/reports/{mothership → allTests}/src/mothership/test/node/lint_errors.json +0 -0
@@ -1,1199 +0,0 @@
1
- import { createRequire } from 'module';const require = createRequire(import.meta.url);
2
-
3
- // src/PM/nodeSidecar.ts
4
- import net from "net";
5
-
6
- // src/PM/sidecar.ts
7
- var PM_sidecar = class {
8
- testArtiFactoryfileWriter(tLog, callback) {
9
- return (fPath, value) => {
10
- callback(Promise.resolve());
11
- };
12
- }
13
- // abstract $(selector: string): any;
14
- // abstract click(selector: string): any;
15
- // abstract closePage(p): any;
16
- // abstract createWriteStream(
17
- // filepath: string,
18
- // testName: string
19
- // ): Promise<string>;
20
- // abstract customclose();
21
- // abstract customScreenShot(opts: object, page?: string): any;
22
- // abstract end(uid: number): Promise<boolean>;
23
- // abstract existsSync(fp: string): Promise<boolean>;
24
- // abstract focusOn(selector: string): any;
25
- // abstract getAttribute(selector: string, attribute: string): any;
26
- // abstract getValue(value: string): any;
27
- // abstract goto(p, url: string): any;
28
- // abstract isDisabled(selector: string): Promise<boolean>;
29
- // abstract mkdirSync(a: string);
30
- // abstract newPage(): Promise<string>;
31
- // abstract page(): Promise<string | undefined>;
32
- // abstract pages(): Promise<string[]>;
33
- // abstract screencast(o: ScreenRecorderOptions, p: Page | string): any;
34
- // abstract screencastStop(s: string): any;
35
- // abstract typeInto(selector: string, value: string): any;
36
- // abstract waitForSelector(p, sel: string);
37
- // abstract write(uid: number, contents: string): Promise<boolean>;
38
- // abstract writeFileSync(f: string, c: string, t: string): Promise<boolean>;
39
- // abstract launchSideCar(
40
- // n: number
41
- // ): Promise<[number, ITTestResourceConfiguration]>;
42
- // abstract stopSideCar(n: number): Promise<any>;
43
- };
44
-
45
- // src/PM/nodeSidecar.ts
46
- var PM_Node_Sidecar = class extends PM_sidecar {
47
- constructor(t) {
48
- super();
49
- this.testResourceConfiguration = t;
50
- this.client = {};
51
- }
52
- start(stopper) {
53
- return new Promise((res) => {
54
- process.on("message", async (message) => {
55
- if (message === "stop") {
56
- console.log("STOP!", stopper.toString());
57
- await stopper();
58
- process.exit();
59
- } else if (message.path) {
60
- this.client = net.createConnection(message.path, () => {
61
- res();
62
- });
63
- }
64
- });
65
- });
66
- }
67
- stop() {
68
- return new Promise((resolve) => {
69
- if (this.client) {
70
- this.client.end(() => resolve());
71
- } else {
72
- resolve();
73
- }
74
- });
75
- }
76
- testArtiFactoryfileWriter(tLog, callback) {
77
- return (fPath, value) => {
78
- callback(Promise.resolve());
79
- };
80
- }
81
- send(command, ...argz) {
82
- return new Promise((res) => {
83
- const key = Math.random().toString();
84
- const myListener = (event) => {
85
- const x = JSON.parse(event);
86
- if (x.key === key) {
87
- process.removeListener("message", myListener);
88
- res(x.payload);
89
- }
90
- };
91
- process.addListener("message", myListener);
92
- this.client.write(JSON.stringify([command, ...argz, key]));
93
- });
94
- }
95
- };
96
-
97
- // src/lib/index.ts
98
- var BaseTestInterface = {
99
- beforeAll: async (s) => s,
100
- beforeEach: async function(subject, initialValues, x, testResource, pm) {
101
- return subject;
102
- },
103
- afterEach: async (s) => s,
104
- afterAll: (store) => void 0,
105
- butThen: async (store, thenCb) => {
106
- return thenCb(store);
107
- },
108
- andWhen: async (store, whenCB, testResource, pm) => {
109
- await whenCB(store, testResource, pm);
110
- },
111
- assertThis: (x) => x
112
- };
113
- var DefaultTestInterface = (p) => {
114
- return {
115
- ...BaseTestInterface,
116
- ...p
117
- };
118
- };
119
- var defaultTestResourceRequirement = {
120
- ports: 0
121
- };
122
-
123
- // src/lib/pmProxy.ts
124
- var prxy = function(pm, mappings) {
125
- return new Proxy(pm, {
126
- get: (target, prop, receiver) => {
127
- for (const mapping of mappings) {
128
- const method = mapping[0];
129
- const arger = mapping[1];
130
- if (prop === method) {
131
- return (...x) => target[prop](arger(...x));
132
- }
133
- }
134
- return (...x) => target[prop](...x);
135
- }
136
- });
137
- };
138
- var butThenProxy = (pm, filepath) => prxy(pm, [
139
- [
140
- "screencast",
141
- (opts, p) => [
142
- {
143
- ...opts,
144
- path: `${filepath}/butThen/${opts.path}`
145
- },
146
- p
147
- ]
148
- ],
149
- ["createWriteStream", (fp) => [`${filepath}/butThen/${fp}`]],
150
- [
151
- "writeFileSync",
152
- (fp, contents) => [`${filepath}/butThen/${fp}`, contents]
153
- ],
154
- [
155
- "customScreenShot",
156
- (opts, p) => [
157
- {
158
- ...opts,
159
- path: `${filepath}/butThen/${opts.path}`
160
- },
161
- p
162
- ]
163
- ]
164
- ]);
165
- var andWhenProxy = (pm, filepath) => prxy(pm, [
166
- [
167
- "screencast",
168
- (opts, p) => [
169
- {
170
- ...opts,
171
- path: `${filepath}/andWhen/${opts.path}`
172
- },
173
- p
174
- ]
175
- ],
176
- ["createWriteStream", (fp) => [`${filepath}/andWhen/${fp}`]],
177
- ["writeFileSync", (fp, contents) => [`${filepath}/andWhen${fp}`, contents]],
178
- [
179
- "customScreenShot",
180
- (opts, p) => [
181
- {
182
- ...opts,
183
- path: `${filepath}/andWhen${opts.path}`
184
- },
185
- p
186
- ]
187
- ]
188
- ]);
189
- var afterEachProxy = (pm, suite, given) => prxy(pm, [
190
- [
191
- "screencast",
192
- (opts, p) => [
193
- {
194
- ...opts,
195
- path: `suite-${suite}/given-${given}/afterEach/${opts.path}`
196
- },
197
- p
198
- ]
199
- ],
200
- ["createWriteStream", (fp) => [`suite-${suite}/afterEach/${fp}`]],
201
- [
202
- "writeFileSync",
203
- (fp, contents) => [
204
- `suite-${suite}/given-${given}/afterEach/${fp}`,
205
- contents
206
- ]
207
- ],
208
- [
209
- "customScreenShot",
210
- (opts, p) => [
211
- {
212
- ...opts,
213
- path: `suite-${suite}/given-${given}/afterEach/${opts.path}`
214
- },
215
- p
216
- ]
217
- ]
218
- ]);
219
- var beforeEachProxy = (pm, suite) => prxy(pm, [
220
- [
221
- "screencast",
222
- (opts, p) => [
223
- {
224
- ...opts,
225
- path: `suite-${suite}/beforeEach/${opts.path}`
226
- },
227
- p
228
- ]
229
- ],
230
- [
231
- "writeFileSync",
232
- (fp, contents) => [`suite-${suite}/beforeEach/${fp}`, contents]
233
- ],
234
- [
235
- "customScreenShot",
236
- (opts, p) => [
237
- {
238
- ...opts,
239
- path: `suite-${suite}/beforeEach/${opts.path}`
240
- },
241
- p
242
- ]
243
- ],
244
- ["createWriteStream", (fp) => [`suite-${suite}/beforeEach/${fp}`]]
245
- ]);
246
- var beforeAllProxy = (pm, suite) => prxy(pm, [
247
- [
248
- "writeFileSync",
249
- (fp, contents) => [`suite-${suite}/beforeAll/${fp}`, contents]
250
- ],
251
- [
252
- "customScreenShot",
253
- (opts, p) => [
254
- {
255
- ...opts,
256
- path: `suite-${suite}/beforeAll/${opts.path}`
257
- },
258
- p
259
- ]
260
- ],
261
- ["createWriteStream", (fp) => [`suite-${suite}/beforeAll/${fp}`]]
262
- ]);
263
- var afterAllProxy = (pm, suite) => prxy(pm, [
264
- ["createWriteStream", (fp) => [`suite-${suite}/afterAll/${fp}`]],
265
- [
266
- "writeFileSync",
267
- (fp, contents) => [`suite-${suite}/afterAll/${fp}`, contents]
268
- ],
269
- [
270
- "customScreenShot",
271
- (opts, p) => [
272
- {
273
- ...opts,
274
- path: `suite-${suite}/afterAll/${opts.path}`
275
- },
276
- p
277
- ]
278
- ]
279
- ]);
280
-
281
- // src/lib/abstractBase.ts
282
- var BaseSuite = class {
283
- constructor(name, index, givens = {}, checks = []) {
284
- this.name = name;
285
- this.index = index;
286
- this.givens = givens;
287
- this.checks = checks;
288
- this.fails = 0;
289
- }
290
- features() {
291
- const features = Object.keys(this.givens).map((k) => this.givens[k].features).flat().filter((value, index, array) => {
292
- return array.indexOf(value) === index;
293
- });
294
- return features || [];
295
- }
296
- toObj() {
297
- const givens = Object.keys(this.givens).map((k) => this.givens[k].toObj());
298
- const checks = Object.keys(this.checks).map((k) => this.checks[k].toObj());
299
- return {
300
- name: this.name,
301
- givens,
302
- checks,
303
- fails: this.fails,
304
- failed: this.failed,
305
- features: this.features()
306
- };
307
- }
308
- setup(s, artifactory, tr, pm) {
309
- return new Promise((res) => res(s));
310
- }
311
- assertThat(t) {
312
- return !!t;
313
- }
314
- afterAll(store, artifactory, pm) {
315
- return store;
316
- }
317
- async run(input, testResourceConfiguration, artifactory, tLog, pm) {
318
- this.testResourceConfiguration = testResourceConfiguration;
319
- const suiteArtifactory = (fPath, value) => artifactory(`suite-${this.index}-${this.name}/${fPath}`, value);
320
- tLog("\nSuite:", this.index, this.name);
321
- const sNdx = this.index;
322
- const subject = await this.setup(
323
- input,
324
- suiteArtifactory,
325
- testResourceConfiguration,
326
- beforeAllProxy(pm, sNdx.toString())
327
- );
328
- for (const [gKey, g] of Object.entries(this.givens)) {
329
- const giver = this.givens[gKey];
330
- try {
331
- this.store = await giver.give(
332
- subject,
333
- gKey,
334
- testResourceConfiguration,
335
- this.assertThat,
336
- suiteArtifactory,
337
- tLog,
338
- pm,
339
- sNdx
340
- );
341
- } catch (e) {
342
- this.failed = true;
343
- this.fails = this.fails + 1;
344
- }
345
- }
346
- for (const [ndx, thater] of this.checks.entries()) {
347
- await thater.check(
348
- subject,
349
- thater.name,
350
- testResourceConfiguration,
351
- this.assertThat,
352
- suiteArtifactory,
353
- tLog,
354
- pm
355
- );
356
- }
357
- try {
358
- this.afterAll(
359
- this.store,
360
- artifactory,
361
- afterAllProxy(pm, sNdx.toString())
362
- );
363
- } catch (e) {
364
- console.error(e);
365
- }
366
- return this;
367
- }
368
- };
369
- var BaseGiven = class {
370
- constructor(name, features, whens, thens, givenCB, initialValues) {
371
- this.name = name;
372
- this.features = features;
373
- this.whens = whens;
374
- this.thens = thens;
375
- this.givenCB = givenCB;
376
- this.initialValues = initialValues;
377
- }
378
- beforeAll(store) {
379
- return store;
380
- }
381
- toObj() {
382
- return {
383
- key: this.key,
384
- name: this.name,
385
- whens: this.whens.map((w) => w.toObj()),
386
- thens: this.thens.map((t) => t.toObj()),
387
- error: this.error ? [this.error, this.error.stack] : null,
388
- failed: this.failed,
389
- features: this.features
390
- };
391
- }
392
- async afterEach(store, key, artifactory, pm) {
393
- return store;
394
- }
395
- async give(subject, key, testResourceConfiguration, tester, artifactory, tLog, pm, suiteNdx) {
396
- this.key = key;
397
- tLog(`
398
- ${this.key}`);
399
- tLog(`
400
- Given: ${this.name}`);
401
- const givenArtifactory = (fPath, value) => artifactory(`given-${key}/${fPath}`, value);
402
- this.uberCatcher((e) => {
403
- console.error(e);
404
- this.error = e.error;
405
- tLog(e.stack);
406
- });
407
- try {
408
- this.store = await this.givenThat(
409
- subject,
410
- testResourceConfiguration,
411
- givenArtifactory,
412
- this.givenCB,
413
- this.initialValues,
414
- beforeEachProxy(pm, suiteNdx.toString())
415
- );
416
- } catch (e) {
417
- console.error("failure 4 ", e);
418
- this.error = e;
419
- throw e;
420
- }
421
- try {
422
- for (const [whenNdx, whenStep] of this.whens.entries()) {
423
- await whenStep.test(
424
- this.store,
425
- testResourceConfiguration,
426
- tLog,
427
- pm,
428
- `suite-${suiteNdx}/given-${key}/when/${whenNdx}`
429
- );
430
- }
431
- for (const [thenNdx, thenStep] of this.thens.entries()) {
432
- const t = await thenStep.test(
433
- this.store,
434
- testResourceConfiguration,
435
- tLog,
436
- pm,
437
- `suite-${suiteNdx}/given-${key}/then-${thenNdx}`
438
- );
439
- return tester(t);
440
- }
441
- } catch (e) {
442
- this.failed = true;
443
- tLog(e.stack);
444
- throw e;
445
- } finally {
446
- try {
447
- await this.afterEach(
448
- this.store,
449
- this.key,
450
- givenArtifactory,
451
- afterEachProxy(pm, suiteNdx.toString(), key)
452
- );
453
- } catch (e) {
454
- console.error("afterEach failed!", e);
455
- this.failed = e;
456
- throw e;
457
- }
458
- }
459
- return this.store;
460
- }
461
- };
462
- var BaseWhen = class {
463
- constructor(name, whenCB) {
464
- this.name = name;
465
- this.whenCB = whenCB;
466
- }
467
- toObj() {
468
- console.log("toObj error", this.error);
469
- return {
470
- name: this.name,
471
- error: this.error && this.error.name + this.error.stack
472
- };
473
- }
474
- async test(store, testResourceConfiguration, tLog, pm, filepath) {
475
- tLog(" When:", this.name);
476
- return await this.andWhen(
477
- store,
478
- this.whenCB,
479
- testResourceConfiguration,
480
- andWhenProxy(pm, filepath)
481
- ).catch((e) => {
482
- console.log("MARK9", e);
483
- this.error = e;
484
- throw e;
485
- });
486
- }
487
- };
488
- var BaseThen = class {
489
- constructor(name, thenCB) {
490
- this.name = name;
491
- this.thenCB = thenCB;
492
- this.error = false;
493
- }
494
- toObj() {
495
- return {
496
- name: this.name,
497
- error: this.error
498
- };
499
- }
500
- async test(store, testResourceConfiguration, tLog, pm, filepath) {
501
- return this.butThen(
502
- store,
503
- async (s) => {
504
- tLog(" Then!!!:", this.name);
505
- if (typeof this.thenCB === "function") {
506
- return await this.thenCB(s);
507
- } else {
508
- return this.thenCB;
509
- }
510
- },
511
- testResourceConfiguration,
512
- butThenProxy(pm, filepath)
513
- ).catch((e) => {
514
- console.log("test failed 3", e);
515
- this.error = e;
516
- throw e;
517
- });
518
- }
519
- check() {
520
- }
521
- };
522
- var BaseCheck = class {
523
- constructor(name, features, checker, x, checkCB) {
524
- this.name = name;
525
- this.features = features;
526
- this.checkCB = checkCB;
527
- this.checker = checker;
528
- }
529
- toObj() {
530
- return {
531
- key: this.key,
532
- name: this.name,
533
- // functionAsString: this.checkCB.toString(),
534
- features: this.features
535
- };
536
- }
537
- async afterEach(store, key, artifactory, pm) {
538
- return store;
539
- }
540
- beforeAll(store) {
541
- return store;
542
- }
543
- async check(subject, key, testResourceConfiguration, tester, artifactory, tLog, pm) {
544
- this.key = key;
545
- tLog(`
546
- Check: ${this.name}`);
547
- this.store = await this.checkThat(
548
- subject,
549
- testResourceConfiguration,
550
- artifactory,
551
- this.checkCB,
552
- this.initialValues,
553
- pm
554
- );
555
- await this.checker(this.store, pm);
556
- return;
557
- }
558
- };
559
-
560
- // src/lib/basebuilder.ts
561
- var BaseBuilder = class {
562
- constructor(input, suitesOverrides, givenOverides, whenOverides, thenOverides, checkOverides, testResourceRequirement, testSpecification) {
563
- this.artifacts = [];
564
- this.artifacts = [];
565
- this.testResourceRequirement = testResourceRequirement;
566
- this.suitesOverrides = suitesOverrides;
567
- this.givenOverides = givenOverides;
568
- this.whenOverides = whenOverides;
569
- this.thenOverides = thenOverides;
570
- this.checkOverides = checkOverides;
571
- this.testSpecification = testSpecification;
572
- this.specs = testSpecification(
573
- this.Suites(),
574
- this.Given(),
575
- this.When(),
576
- this.Then(),
577
- this.Check()
578
- );
579
- this.testJobs = this.specs.map((suite) => {
580
- const suiteRunner = (suite2) => async (puppetMaster, tLog) => {
581
- const x = await suite2.run(
582
- input,
583
- puppetMaster.testResourceConfiguration,
584
- (fPath, value) => puppetMaster.testArtiFactoryfileWriter(
585
- tLog,
586
- (p) => {
587
- this.artifacts.push(p);
588
- }
589
- )(puppetMaster.testResourceConfiguration.fs + "/" + fPath, value),
590
- tLog,
591
- puppetMaster
592
- );
593
- return x;
594
- };
595
- const runner = suiteRunner(suite);
596
- return {
597
- test: suite,
598
- toObj: () => {
599
- return suite.toObj();
600
- },
601
- runner,
602
- receiveTestResourceConfig: async function(puppetMaster) {
603
- const logFilePath = "log.txt";
604
- const access = await puppetMaster.createWriteStream(
605
- logFilePath
606
- );
607
- const tLog = async (...l) => {
608
- };
609
- const suiteDone = await runner(puppetMaster, tLog);
610
- const logPromise = new Promise(async (res) => {
611
- await puppetMaster.end(access);
612
- res(true);
613
- });
614
- const fails = suiteDone.fails;
615
- await puppetMaster.writeFileSync(`bdd_errors.txt`, fails.toString());
616
- await puppetMaster.writeFileSync(
617
- `tests.json`,
618
- JSON.stringify(this.toObj(), null, 2)
619
- );
620
- return {
621
- failed: fails > 0,
622
- fails,
623
- artifacts: this.artifacts || [],
624
- logPromise,
625
- features: suiteDone.features()
626
- };
627
- }
628
- };
629
- });
630
- }
631
- // testsJson() {
632
- // puppetMaster.writeFileSync(
633
- // `tests.json`,
634
- // JSON.stringify({ features: suiteDone.features() }, null, 2)
635
- // );
636
- // }
637
- Specs() {
638
- return this.specs;
639
- }
640
- Suites() {
641
- return this.suitesOverrides;
642
- }
643
- Given() {
644
- return this.givenOverides;
645
- }
646
- When() {
647
- return this.whenOverides;
648
- }
649
- Then() {
650
- return this.thenOverides;
651
- }
652
- Check() {
653
- return this.checkOverides;
654
- }
655
- };
656
-
657
- // src/lib/classBuilder.ts
658
- var ClassBuilder = class extends BaseBuilder {
659
- constructor(testImplementation, testSpecification, input, suiteKlasser, givenKlasser, whenKlasser, thenKlasser, checkKlasser, testResourceRequirement) {
660
- const classySuites = Object.entries(testImplementation.suites).reduce(
661
- (a, [key], index) => {
662
- a[key] = (somestring, givens, checks) => {
663
- return new suiteKlasser.prototype.constructor(
664
- somestring,
665
- index,
666
- givens,
667
- checks
668
- );
669
- };
670
- return a;
671
- },
672
- {}
673
- );
674
- const classyGivens = Object.entries(testImplementation.givens).reduce(
675
- (a, [key, g]) => {
676
- a[key] = (features, whens, thens, ...initialValues) => {
677
- return new givenKlasser.prototype.constructor(
678
- key,
679
- features,
680
- whens,
681
- thens,
682
- testImplementation.givens[key],
683
- initialValues
684
- );
685
- };
686
- return a;
687
- },
688
- {}
689
- );
690
- const classyWhens = Object.entries(testImplementation.whens).reduce(
691
- (a, [key, whEn]) => {
692
- a[key] = (payload) => {
693
- return new whenKlasser.prototype.constructor(
694
- `${whEn.name}: ${payload && payload.toString()}`,
695
- whEn(payload)
696
- );
697
- };
698
- return a;
699
- },
700
- {}
701
- );
702
- const classyThens = Object.entries(testImplementation.thens).reduce(
703
- (a, [key, thEn]) => {
704
- a[key] = (expected, ...x) => {
705
- return new thenKlasser.prototype.constructor(
706
- `${thEn.name}: ${expected && expected.toString()}`,
707
- thEn(expected, ...x)
708
- );
709
- };
710
- return a;
711
- },
712
- {}
713
- );
714
- const classyChecks = Object.entries(testImplementation.checks).reduce(
715
- (a, [key, chEck]) => {
716
- a[key] = (name, features, checker) => {
717
- return new checkKlasser.prototype.constructor(
718
- key,
719
- features,
720
- chEck,
721
- checker
722
- );
723
- };
724
- return a;
725
- },
726
- {}
727
- );
728
- super(
729
- input,
730
- classySuites,
731
- classyGivens,
732
- classyWhens,
733
- classyThens,
734
- classyChecks,
735
- testResourceRequirement,
736
- testSpecification
737
- );
738
- }
739
- };
740
-
741
- // src/lib/core.ts
742
- var Testeranto = class extends ClassBuilder {
743
- constructor(input, testSpecification, testImplementation, testResourceRequirement = defaultTestResourceRequirement, testInterface2, uberCatcher) {
744
- const fullTestInterface = DefaultTestInterface(testInterface2);
745
- super(
746
- testImplementation,
747
- testSpecification,
748
- input,
749
- class extends BaseSuite {
750
- afterAll(store, artifactory, pm) {
751
- return fullTestInterface.afterAll(store, pm);
752
- }
753
- assertThat(t) {
754
- return fullTestInterface.assertThis(t);
755
- }
756
- async setup(s, artifactory, tr, pm) {
757
- return (fullTestInterface.beforeAll || (async (input2, artifactory2, tr2, pm2) => input2))(
758
- s,
759
- this.testResourceConfiguration,
760
- // artifactory,
761
- pm
762
- );
763
- }
764
- },
765
- class Given extends BaseGiven {
766
- constructor() {
767
- super(...arguments);
768
- this.uberCatcher = uberCatcher;
769
- }
770
- async givenThat(subject, testResource, artifactory, initializer, initialValues, pm) {
771
- return fullTestInterface.beforeEach(
772
- subject,
773
- initializer,
774
- testResource,
775
- initialValues,
776
- pm
777
- );
778
- }
779
- afterEach(store, key, artifactory, pm) {
780
- return new Promise(
781
- (res) => res(fullTestInterface.afterEach(store, key, pm))
782
- );
783
- }
784
- },
785
- class When extends BaseWhen {
786
- async andWhen(store, whenCB, testResource, pm) {
787
- return await fullTestInterface.andWhen(
788
- store,
789
- whenCB,
790
- testResource,
791
- pm
792
- );
793
- }
794
- },
795
- class Then extends BaseThen {
796
- async butThen(store, thenCB, testResource, pm) {
797
- return await fullTestInterface.butThen(
798
- store,
799
- thenCB,
800
- testResource,
801
- pm
802
- );
803
- }
804
- },
805
- class Check extends BaseCheck {
806
- constructor(name, features, checkCallback, x, i, c) {
807
- super(name, features, checkCallback, x, c);
808
- this.initialValues = i;
809
- }
810
- async checkThat(subject, testResourceConfiguration, artifactory, initializer, initialValues, pm) {
811
- return fullTestInterface.beforeEach(
812
- subject,
813
- initializer,
814
- testResourceConfiguration,
815
- initialValues,
816
- pm
817
- );
818
- }
819
- afterEach(store, key, artifactory, pm) {
820
- return new Promise(
821
- (res) => res(fullTestInterface.afterEach(store, key, pm))
822
- );
823
- }
824
- },
825
- testResourceRequirement
826
- );
827
- }
828
- };
829
-
830
- // src/PM/node.ts
831
- import net2 from "net";
832
- import fs from "fs";
833
- import path from "path";
834
-
835
- // src/PM/index.ts
836
- var PM = class {
837
- };
838
-
839
- // src/PM/node.ts
840
- var fPaths = [];
841
- var PM_Node = class extends PM {
842
- constructor(t, ipcFile) {
843
- super();
844
- this.testResourceConfiguration = t;
845
- this.client = net2.createConnection(ipcFile, () => {
846
- return;
847
- });
848
- }
849
- start() {
850
- throw new Error("DEPREFECATED");
851
- }
852
- stop() {
853
- throw new Error("stop not implemented.");
854
- }
855
- send(command, ...argz) {
856
- const key = Math.random().toString();
857
- if (!this.client) {
858
- console.error(
859
- `Tried to send "${command} (${argz})" but the test has not been started and the IPC client is not established. Exiting as failure!`
860
- );
861
- process.exit(-1);
862
- }
863
- return new Promise((res) => {
864
- const myListener = (event) => {
865
- const x = JSON.parse(event);
866
- if (x.key === key) {
867
- process.removeListener("message", myListener);
868
- res(x.payload);
869
- }
870
- };
871
- process.addListener("message", myListener);
872
- this.client.write(JSON.stringify([command, ...argz, key]));
873
- });
874
- }
875
- async launchSideCar(n) {
876
- return this.send(
877
- "launchSideCar",
878
- n,
879
- this.testResourceConfiguration.name
880
- );
881
- }
882
- stopSideCar(n) {
883
- return this.send(
884
- "stopSideCar",
885
- n,
886
- this.testResourceConfiguration.name
887
- );
888
- }
889
- async pages() {
890
- return this.send("pages", ...arguments);
891
- }
892
- waitForSelector(p, s) {
893
- return this.send("waitForSelector", ...arguments);
894
- }
895
- closePage(p) {
896
- return this.send("closePage", ...arguments);
897
- }
898
- goto(page, url) {
899
- return this.send("goto", ...arguments);
900
- }
901
- async newPage() {
902
- return this.send("newPage");
903
- }
904
- $(selector, page) {
905
- return this.send("$", ...arguments);
906
- }
907
- isDisabled(selector) {
908
- return this.send("isDisabled", ...arguments);
909
- }
910
- getAttribute(selector, attribute, p) {
911
- return this.send("getAttribute", ...arguments);
912
- }
913
- getInnerHtml(selector, p) {
914
- return this.send("getInnerHtml", ...arguments);
915
- }
916
- // setValue(selector: string) {
917
- // return this.send("getValue", ...arguments);
918
- // }
919
- focusOn(selector) {
920
- return this.send("focusOn", ...arguments);
921
- }
922
- typeInto(selector) {
923
- return this.send("typeInto", ...arguments);
924
- }
925
- page() {
926
- return this.send("page");
927
- }
928
- click(selector) {
929
- return this.send("click", ...arguments);
930
- }
931
- screencast(opts, page) {
932
- return this.send(
933
- "screencast",
934
- {
935
- ...opts,
936
- path: this.testResourceConfiguration.fs + "/" + opts.path
937
- },
938
- page,
939
- this.testResourceConfiguration.name
940
- );
941
- }
942
- screencastStop(p) {
943
- return this.send("screencastStop", ...arguments);
944
- }
945
- customScreenShot(x, y) {
946
- const opts = x[0];
947
- const page = x[1];
948
- return this.send(
949
- "customScreenShot",
950
- {
951
- ...opts,
952
- path: this.testResourceConfiguration.fs + "/" + opts.path
953
- },
954
- this.testResourceConfiguration.name,
955
- page
956
- );
957
- }
958
- async existsSync(destFolder) {
959
- return await this.send(
960
- "existsSync",
961
- this.testResourceConfiguration.fs + "/" + destFolder
962
- );
963
- }
964
- mkdirSync() {
965
- return this.send("mkdirSync", this.testResourceConfiguration.fs + "/");
966
- }
967
- async write(uid, contents) {
968
- return await this.send("write", ...arguments);
969
- }
970
- async writeFileSync(filepath, contents) {
971
- return await this.send(
972
- "writeFileSync",
973
- this.testResourceConfiguration.fs + "/" + filepath,
974
- contents,
975
- this.testResourceConfiguration.name
976
- );
977
- }
978
- async createWriteStream(filepath) {
979
- return await this.send(
980
- "createWriteStream",
981
- this.testResourceConfiguration.fs + "/" + filepath,
982
- this.testResourceConfiguration.name
983
- );
984
- }
985
- async end(uid) {
986
- return await this.send("end", ...arguments);
987
- }
988
- async customclose() {
989
- return await this.send(
990
- "customclose",
991
- this.testResourceConfiguration.fs,
992
- this.testResourceConfiguration.name
993
- );
994
- }
995
- testArtiFactoryfileWriter(tLog, callback) {
996
- return (fPath, value) => {
997
- callback(
998
- new Promise((res, rej) => {
999
- tLog("testArtiFactory =>", fPath);
1000
- const cleanPath = path.resolve(fPath);
1001
- fPaths.push(cleanPath.replace(process.cwd(), ``));
1002
- const targetDir = cleanPath.split("/").slice(0, -1).join("/");
1003
- fs.mkdir(targetDir, { recursive: true }, async (error) => {
1004
- if (error) {
1005
- console.error(`\u2757\uFE0FtestArtiFactory failed`, targetDir, error);
1006
- }
1007
- fs.writeFileSync(
1008
- path.resolve(
1009
- targetDir.split("/").slice(0, -1).join("/"),
1010
- "manifest"
1011
- ),
1012
- fPaths.join(`
1013
- `),
1014
- {
1015
- encoding: "utf-8"
1016
- }
1017
- );
1018
- if (Buffer.isBuffer(value)) {
1019
- fs.writeFileSync(fPath, value, "binary");
1020
- res();
1021
- } else if (`string` === typeof value) {
1022
- fs.writeFileSync(fPath, value.toString(), {
1023
- encoding: "utf-8"
1024
- });
1025
- res();
1026
- } else {
1027
- const pipeStream = value;
1028
- const myFile = fs.createWriteStream(fPath);
1029
- pipeStream.pipe(myFile);
1030
- pipeStream.on("close", () => {
1031
- myFile.close();
1032
- res();
1033
- });
1034
- }
1035
- });
1036
- })
1037
- );
1038
- };
1039
- }
1040
- // launch(options?: PuppeteerLaunchOptions): Promise<Browser>;
1041
- startPuppeteer(options) {
1042
- }
1043
- };
1044
-
1045
- // src/Node.ts
1046
- var ipcfile;
1047
- var NodeTesteranto = class extends Testeranto {
1048
- constructor(input, testSpecification, testImplementation, testResourceRequirement, testInterface2) {
1049
- super(
1050
- input,
1051
- testSpecification,
1052
- testImplementation,
1053
- testResourceRequirement,
1054
- testInterface2,
1055
- () => {
1056
- }
1057
- );
1058
- }
1059
- async receiveTestResourceConfig(partialTestResource) {
1060
- const t = JSON.parse(partialTestResource);
1061
- const pm = new PM_Node(t, ipcfile);
1062
- return await this.testJobs[0].receiveTestResourceConfig(pm);
1063
- }
1064
- };
1065
- var testeranto = async (input, testSpecification, testImplementation, testInterface2, testResourceRequirement = defaultTestResourceRequirement) => {
1066
- const t = new NodeTesteranto(
1067
- input,
1068
- testSpecification,
1069
- testImplementation,
1070
- testResourceRequirement,
1071
- testInterface2
1072
- );
1073
- process.on("unhandledRejection", (reason, promise) => {
1074
- console.error("Unhandled Rejection at:", promise, "reason:", reason);
1075
- });
1076
- try {
1077
- ipcfile = process.argv[3];
1078
- const f = await t.receiveTestResourceConfig(process.argv[2]);
1079
- console.error("goodbye node error", f.fails);
1080
- process.exit(f.fails);
1081
- } catch (e) {
1082
- console.error("goodbye node error", e);
1083
- process.exit(-1);
1084
- }
1085
- return t;
1086
- };
1087
- var Node_default = testeranto;
1088
-
1089
- // src/PM/__tests__/sidecar.testeranto.ts
1090
- var specification = (Suite, Given, When, Then) => {
1091
- return [
1092
- Suite.SidecarInitialized(
1093
- "Sidecar message passing works correctly",
1094
- {
1095
- basicSend: Given.SidecarReady(
1096
- ["can send and receive messages"],
1097
- [When.SendTestMessage("test-message")],
1098
- [Then.MessageReceived("test-message")]
1099
- ),
1100
- cleanup: Given.SidecarReady(
1101
- ["cleans up listeners after message"],
1102
- [When.VerifyCleanup()],
1103
- [Then.ListenersCleaned()]
1104
- )
1105
- },
1106
- []
1107
- )
1108
- ];
1109
- };
1110
- var implementation = {
1111
- suites: { SidecarInitialized: (x) => x },
1112
- givens: {
1113
- SidecarReady: () => {
1114
- const config = {
1115
- name: "test-sidecar",
1116
- fs: "/tmp",
1117
- ports: [3001],
1118
- browserWSEndpoint: ""
1119
- };
1120
- return new PM_Node_Sidecar(config);
1121
- }
1122
- },
1123
- whens: {
1124
- SendTestMessage: (message) => async (sidecar) => {
1125
- let callbackFn;
1126
- process.on = (event, callback) => {
1127
- if (event === "message") {
1128
- callbackFn = callback;
1129
- callback(
1130
- JSON.stringify({
1131
- key: "mock-key",
1132
- payload: message
1133
- })
1134
- );
1135
- }
1136
- };
1137
- let writeCalled = false;
1138
- sidecar.client.write = (data) => {
1139
- writeCalled = true;
1140
- return true;
1141
- };
1142
- await sidecar.send("test-command", message);
1143
- return { writeCalled, callbackFn };
1144
- },
1145
- VerifyCleanup: () => async (sidecar) => {
1146
- let addListenerCalled = false;
1147
- let removeListenerCalled = false;
1148
- process.addListener = () => addListenerCalled = true;
1149
- process.removeListener = () => removeListenerCalled = true;
1150
- await sidecar.send("test-command", "test");
1151
- return { addListenerCalled, removeListenerCalled };
1152
- }
1153
- },
1154
- thens: {
1155
- MessageReceived: (expected) => (actual) => {
1156
- if (actual !== expected) {
1157
- throw new Error(`Expected "${expected}" but got "${actual}"`);
1158
- }
1159
- return actual;
1160
- },
1161
- ListenersCleaned: () => (result, { removeListenerCalled }) => {
1162
- if (!removeListenerCalled) {
1163
- throw new Error("Expected removeListener to be called");
1164
- }
1165
- return result;
1166
- }
1167
- },
1168
- checks: { SidecarState: () => "unknown" }
1169
- };
1170
- var testInterface = {
1171
- beforeEach: async (subject, initializer, testResource, initialValues, pm) => {
1172
- const sidecar = initializer();
1173
- sidecar.client = {
1174
- write: () => true,
1175
- end: () => {
1176
- },
1177
- on: () => {
1178
- }
1179
- };
1180
- return sidecar;
1181
- },
1182
- andWhen: async (store, whenCB, testResource, pm) => {
1183
- try {
1184
- await whenCB(store, testResource, pm);
1185
- } catch (e) {
1186
- console.error("Error in andWhen:", e);
1187
- throw e;
1188
- }
1189
- }
1190
- };
1191
- var sidecar_testeranto_default = Node_default(
1192
- () => new PM_Node_Sidecar({}),
1193
- specification,
1194
- implementation,
1195
- testInterface
1196
- );
1197
- export {
1198
- sidecar_testeranto_default as default
1199
- };