testeranto 0.146.2 → 0.146.4

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 (197) hide show
  1. package/dist/common/src/Node.js +9 -6
  2. package/dist/common/src/PM/PM_WithEslintAndTsc.js +75 -58
  3. package/dist/common/src/PM/main.js +131 -79
  4. package/dist/common/src/PM/node.js +1 -14
  5. package/dist/common/src/PM/nodeSidecar.js +0 -1
  6. package/dist/common/src/Pure.js +17 -1
  7. package/dist/common/src/Pure.test.js +172 -0
  8. package/dist/common/src/build.js +0 -1
  9. package/dist/common/src/esbuildConfigs/consoleDetectorPlugin.js +22 -11
  10. package/dist/common/src/esbuildConfigs/nativeImportDetectorPlugin.js +24 -0
  11. package/dist/common/src/esbuildConfigs/pure.js +2 -1
  12. package/dist/common/src/esbuildConfigs/rebuildPlugin.js +1 -4
  13. package/dist/common/src/lib/BaseSuite.js +89 -0
  14. package/dist/common/src/lib/BaseSuite.test/node.test.js +9 -0
  15. package/dist/common/src/lib/BaseSuite.test/pure.test.js +9 -0
  16. package/dist/common/src/lib/BaseSuite.test/test.js +232 -0
  17. package/dist/common/src/lib/BaseSuite.test/web.test.js +9 -0
  18. package/dist/common/src/lib/abstractBase.js +1 -90
  19. package/dist/common/src/lib/abstractBase.test/MockGiven.js +17 -0
  20. package/dist/common/src/lib/abstractBase.test/MockThen.js +13 -0
  21. package/dist/common/src/lib/abstractBase.test/MockWhen.js +13 -0
  22. package/dist/common/src/lib/abstractBase.test/implementation.js +42 -0
  23. package/dist/common/src/lib/abstractBase.test/index.js +17 -0
  24. package/dist/common/src/lib/abstractBase.test/interface.js +12 -0
  25. package/dist/common/src/lib/abstractBase.test/specification.js +19 -0
  26. package/dist/common/src/lib/abstractBase.test/types.js +2 -0
  27. package/dist/common/src/lib/baseBuilder.test/TestBaseBuilder.js +36 -0
  28. package/dist/common/src/lib/baseBuilder.test/baseBuilder.test.implementation.js +97 -0
  29. package/dist/common/src/lib/baseBuilder.test/baseBuilder.test.interface.js +17 -0
  30. package/dist/common/src/lib/baseBuilder.test/baseBuilder.test.node.js +11 -0
  31. package/dist/common/src/lib/baseBuilder.test/baseBuilder.test.pure.js +11 -0
  32. package/dist/common/src/lib/baseBuilder.test/baseBuilder.test.specification.js +13 -0
  33. package/dist/common/src/lib/baseBuilder.test/baseBuilder.test.types.js +2 -0
  34. package/dist/common/src/lib/baseBuilder.test/baseBuilder.test.web.js +11 -0
  35. package/dist/common/src/lib/basebuilder.js +2 -1
  36. package/dist/common/src/lib/classBuilder.test/TestClassBuilder.js +41 -0
  37. package/dist/common/src/lib/classBuilder.test/classBuilder.test.implementation.js +182 -0
  38. package/dist/common/src/lib/classBuilder.test/classBuilder.test.interface.js +17 -0
  39. package/dist/common/src/lib/classBuilder.test/classBuilder.test.js +11 -0
  40. package/dist/common/src/lib/classBuilder.test/classBuilder.test.specification.js +41 -0
  41. package/dist/common/src/lib/classBuilder.test/classBuilder.test.types.js +2 -0
  42. package/dist/common/src/lib/core.js +4 -13
  43. package/dist/common/src/lib/core.test/MockCore.js +25 -0
  44. package/dist/common/src/lib/core.test/core.test.implementation.js +102 -0
  45. package/dist/common/src/lib/core.test/core.test.interface.js +18 -0
  46. package/dist/common/src/lib/core.test/core.test.js +17 -0
  47. package/dist/common/src/lib/core.test/core.test.specification.js +33 -0
  48. package/dist/common/src/lib/core.test/core.test.types.js +2 -0
  49. package/dist/common/src/lib/pmProxy.js +9 -166
  50. package/dist/common/src/lib/pmProxy.test/implementation.js +76 -0
  51. package/dist/common/src/lib/pmProxy.test/index.js +15 -0
  52. package/dist/common/src/lib/pmProxy.test/interface.js +37 -0
  53. package/dist/common/src/lib/pmProxy.test/mockPM.js +34 -0
  54. package/dist/common/src/lib/pmProxy.test/mockPMBase.js +115 -0
  55. package/dist/common/src/lib/pmProxy.test/specification.js +39 -0
  56. package/dist/common/src/lib/pmProxy.test/types.js +2 -0
  57. package/dist/common/src/run.js +6 -6
  58. package/dist/common/testeranto.config.js +33 -18
  59. package/dist/common/tsconfig.common.tsbuildinfo +1 -1
  60. package/dist/module/src/Node.js +9 -6
  61. package/dist/module/src/PM/PM_WithEslintAndTsc.js +75 -58
  62. package/dist/module/src/PM/main.js +131 -79
  63. package/dist/module/src/PM/node.js +1 -14
  64. package/dist/module/src/PM/nodeSidecar.js +0 -1
  65. package/dist/module/src/Pure.js +17 -1
  66. package/dist/module/src/Pure.test.js +167 -0
  67. package/dist/module/src/build.js +0 -1
  68. package/dist/module/src/esbuildConfigs/consoleDetectorPlugin.js +19 -11
  69. package/dist/module/src/esbuildConfigs/nativeImportDetectorPlugin.js +21 -0
  70. package/dist/module/src/esbuildConfigs/pure.js +2 -1
  71. package/dist/module/src/esbuildConfigs/rebuildPlugin.js +1 -4
  72. package/dist/module/src/lib/BaseSuite.js +85 -0
  73. package/dist/module/src/lib/BaseSuite.test/node.test.js +4 -0
  74. package/dist/module/src/lib/BaseSuite.test/pure.test.js +4 -0
  75. package/dist/module/src/lib/BaseSuite.test/test.js +227 -0
  76. package/dist/module/src/lib/BaseSuite.test/web.test.js +4 -0
  77. package/dist/module/src/lib/abstractBase.js +1 -89
  78. package/dist/module/src/lib/abstractBase.test/MockGiven.js +13 -0
  79. package/dist/module/src/lib/abstractBase.test/MockThen.js +9 -0
  80. package/dist/module/src/lib/abstractBase.test/MockWhen.js +9 -0
  81. package/dist/module/src/lib/abstractBase.test/implementation.js +39 -0
  82. package/dist/module/src/lib/abstractBase.test/index.js +12 -0
  83. package/dist/module/src/lib/abstractBase.test/interface.js +9 -0
  84. package/dist/module/src/lib/abstractBase.test/specification.js +15 -0
  85. package/dist/module/src/lib/abstractBase.test/types.js +1 -0
  86. package/dist/module/src/lib/baseBuilder.test/TestBaseBuilder.js +32 -0
  87. package/dist/module/src/lib/baseBuilder.test/baseBuilder.test.implementation.js +94 -0
  88. package/dist/module/src/lib/baseBuilder.test/baseBuilder.test.interface.js +14 -0
  89. package/dist/module/src/lib/baseBuilder.test/baseBuilder.test.node.js +6 -0
  90. package/dist/module/src/lib/baseBuilder.test/baseBuilder.test.pure.js +6 -0
  91. package/dist/module/src/lib/baseBuilder.test/baseBuilder.test.specification.js +9 -0
  92. package/dist/module/src/lib/baseBuilder.test/baseBuilder.test.types.js +1 -0
  93. package/dist/module/src/lib/baseBuilder.test/baseBuilder.test.web.js +6 -0
  94. package/dist/module/src/lib/basebuilder.js +2 -1
  95. package/dist/module/src/lib/classBuilder.test/TestClassBuilder.js +37 -0
  96. package/dist/module/src/lib/classBuilder.test/classBuilder.test.implementation.js +179 -0
  97. package/dist/module/src/lib/classBuilder.test/classBuilder.test.interface.js +14 -0
  98. package/dist/module/src/lib/classBuilder.test/classBuilder.test.js +6 -0
  99. package/dist/module/src/lib/classBuilder.test/classBuilder.test.specification.js +37 -0
  100. package/dist/module/src/lib/classBuilder.test/classBuilder.test.types.js +1 -0
  101. package/dist/module/src/lib/core.js +3 -12
  102. package/dist/module/src/lib/core.test/MockCore.js +18 -0
  103. package/dist/module/src/lib/core.test/core.test.implementation.js +99 -0
  104. package/dist/module/src/lib/core.test/core.test.interface.js +15 -0
  105. package/dist/module/src/lib/core.test/core.test.js +12 -0
  106. package/dist/module/src/lib/core.test/core.test.specification.js +29 -0
  107. package/dist/module/src/lib/core.test/core.test.types.js +1 -0
  108. package/dist/module/src/lib/pmProxy.js +9 -166
  109. package/dist/module/src/lib/pmProxy.test/implementation.js +73 -0
  110. package/dist/module/src/lib/pmProxy.test/index.js +10 -0
  111. package/dist/module/src/lib/pmProxy.test/interface.js +34 -0
  112. package/dist/module/src/lib/pmProxy.test/mockPM.js +30 -0
  113. package/dist/module/src/lib/pmProxy.test/mockPMBase.js +111 -0
  114. package/dist/module/src/lib/pmProxy.test/specification.js +35 -0
  115. package/dist/module/src/lib/pmProxy.test/types.js +1 -0
  116. package/dist/module/src/run.js +6 -6
  117. package/dist/module/testeranto.config.js +33 -18
  118. package/dist/module/tsconfig.module.tsbuildinfo +1 -1
  119. package/dist/prebuild/Project.js +16 -15
  120. package/dist/prebuild/TestReport.js +14 -12
  121. package/dist/prebuild/build.mjs +34 -34
  122. package/dist/prebuild/run.mjs +259 -173
  123. package/dist/tsconfig.tsbuildinfo +1 -1
  124. package/dist/types/src/PM/PM_WithEslintAndTsc.d.ts +2 -1
  125. package/dist/types/src/PM/main.d.ts +5 -2
  126. package/dist/types/src/Pure.d.ts +2 -2
  127. package/dist/types/src/Pure.test.d.ts +36 -0
  128. package/dist/types/src/Types.d.ts +7 -6
  129. package/dist/types/src/Web.d.ts +1 -1
  130. package/dist/types/src/esbuildConfigs/consoleDetectorPlugin.d.ts +1 -1
  131. package/dist/types/src/esbuildConfigs/nativeImportDetectorPlugin.d.ts +2 -0
  132. package/dist/types/src/lib/BaseSuite.d.ts +39 -0
  133. package/dist/types/src/lib/BaseSuite.test/node.test.d.ts +3 -0
  134. package/dist/types/src/lib/BaseSuite.test/pure.test.d.ts +3 -0
  135. package/dist/types/src/lib/BaseSuite.test/test.d.ts +42 -0
  136. package/dist/types/src/lib/BaseSuite.test/web.test.d.ts +3 -0
  137. package/dist/types/src/lib/abstractBase.d.ts +1 -36
  138. package/dist/types/src/lib/abstractBase.test/MockGiven.d.ts +7 -0
  139. package/dist/types/src/lib/abstractBase.test/MockThen.d.ts +6 -0
  140. package/dist/types/src/lib/abstractBase.test/MockWhen.d.ts +6 -0
  141. package/dist/types/src/lib/abstractBase.test/implementation.d.ts +3 -0
  142. package/dist/types/src/lib/abstractBase.test/index.d.ts +3 -0
  143. package/dist/types/src/lib/abstractBase.test/interface.d.ts +3 -0
  144. package/dist/types/src/lib/abstractBase.test/specification.d.ts +3 -0
  145. package/dist/types/src/lib/abstractBase.test/types.d.ts +39 -0
  146. package/dist/types/src/lib/baseBuilder.test/TestBaseBuilder.d.ts +15 -0
  147. package/dist/types/src/lib/baseBuilder.test/baseBuilder.test.implementation.d.ts +3 -0
  148. package/dist/types/src/lib/baseBuilder.test/baseBuilder.test.interface.d.ts +3 -0
  149. package/dist/types/src/lib/baseBuilder.test/baseBuilder.test.node.d.ts +3 -0
  150. package/dist/types/src/lib/baseBuilder.test/baseBuilder.test.pure.d.ts +3 -0
  151. package/dist/types/src/lib/baseBuilder.test/baseBuilder.test.specification.d.ts +3 -0
  152. package/dist/types/src/lib/baseBuilder.test/baseBuilder.test.types.d.ts +20 -0
  153. package/dist/types/src/lib/baseBuilder.test/baseBuilder.test.web.d.ts +3 -0
  154. package/dist/types/src/lib/classBuilder.test/TestClassBuilder.d.ts +21 -0
  155. package/dist/types/src/lib/classBuilder.test/classBuilder.test.d.ts +3 -0
  156. package/dist/types/src/lib/classBuilder.test/classBuilder.test.implementation.d.ts +3 -0
  157. package/dist/types/src/lib/classBuilder.test/classBuilder.test.interface.d.ts +3 -0
  158. package/dist/types/src/lib/classBuilder.test/classBuilder.test.specification.d.ts +3 -0
  159. package/dist/types/src/lib/classBuilder.test/classBuilder.test.types.d.ts +56 -0
  160. package/dist/types/src/lib/core.d.ts +1 -1
  161. package/dist/types/src/lib/core.test/MockCore.d.ts +10 -0
  162. package/dist/types/src/lib/core.test/core.test.d.ts +3 -0
  163. package/dist/types/src/lib/core.test/core.test.implementation.d.ts +3 -0
  164. package/dist/types/src/lib/core.test/core.test.interface.d.ts +3 -0
  165. package/dist/types/src/lib/core.test/core.test.specification.d.ts +3 -0
  166. package/dist/types/src/lib/core.test/core.test.types.d.ts +46 -0
  167. package/dist/types/src/lib/index.d.ts +2 -1
  168. package/dist/types/src/lib/pmProxy.d.ts +11 -6
  169. package/dist/types/src/lib/pmProxy.test/implementation.d.ts +3 -0
  170. package/dist/types/src/lib/pmProxy.test/index.d.ts +7 -0
  171. package/dist/types/src/lib/pmProxy.test/interface.d.ts +3 -0
  172. package/dist/types/src/lib/pmProxy.test/mockPM.d.ts +10 -0
  173. package/dist/types/src/lib/pmProxy.test/mockPMBase.d.ts +39 -0
  174. package/dist/types/src/lib/pmProxy.test/specification.d.ts +3 -0
  175. package/dist/types/src/lib/pmProxy.test/types.d.ts +42 -0
  176. package/dist/types/src/lib/types.d.ts +2 -1
  177. package/dist/types/tsconfig.types.tsbuildinfo +1 -1
  178. package/docs.html +35 -33
  179. package/index.html +23 -30
  180. package/package.json +3 -2
  181. package/testeranto/index.html +1 -1
  182. package/testeranto/reports/allTests/index.html +1 -1
  183. package/testeranto/reports/allTests/src/Pure.test/pure/index.html +1 -1
  184. package/testeranto/reports/allTests/src/Pure.test/pure/logs.txt +2 -2
  185. package/testeranto/reports/allTests/src/lib/BaseSuite.test/node.test/node/index.html +1 -1
  186. package/testeranto/reports/allTests/src/lib/BaseSuite.test/pure.test/pure/index.html +1 -1
  187. package/testeranto/reports/allTests/src/lib/BaseSuite.test/pure.test/pure/logs.txt +2 -2
  188. package/testeranto/reports/allTests/src/lib/BaseSuite.test/web.test/web/index.html +1 -1
  189. package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.node/node/index.html +1 -1
  190. package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.pure/pure/index.html +1 -1
  191. package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.web/web/index.html +1 -1
  192. package/testeranto/reports/allTests/src/lib/classBuilder.test/classBuilder.test/node/index.html +1 -1
  193. package/testeranto/reports/allTests/src/lib/core.test/core.test/node/index.html +1 -1
  194. package/testeranto/reports/allTests/src/lib/pmProxy.test/index/node/index.html +1 -1
  195. package/testeranto/reports/allTests/src/lib/pmProxy.test/index/node/logs.txt +3 -3
  196. package/testeranto.config.ts +1 -1
  197. package/tsc.log +36 -38
@@ -0,0 +1,167 @@
1
+ import PureTesteranto from "./Pure";
2
+ import { MockPMBase } from "./lib/pmProxy.test/mockPMBase";
3
+ // Implementation for PureTesteranto tests
4
+ const implementation = {
5
+ suites: {
6
+ Default: "PureTesteranto Test Suite",
7
+ },
8
+ givens: {
9
+ Default: () => ({
10
+ pm: new MockPMBase(),
11
+ config: {},
12
+ proxies: {
13
+ butThenProxy: (pm, path) => (Object.assign(Object.assign({}, pm), { writeFileSync: (p, c) => pm.writeFileSync(`${path}/butThen/${p}`, c) })),
14
+ andWhenProxy: (pm, path) => (Object.assign(Object.assign({}, pm), { writeFileSync: (p, c) => pm.writeFileSync(`${path}/andWhen/${p}`, c) })),
15
+ beforeEachProxy: (pm, suite) => (Object.assign(Object.assign({}, pm), { writeFileSync: (p, c) => pm.writeFileSync(`suite-${suite}/beforeEach/${p}`, c) }))
16
+ }
17
+ }),
18
+ },
19
+ whens: {
20
+ applyProxy: (proxyType) => (store) => {
21
+ switch (proxyType) {
22
+ case "invalidConfig":
23
+ throw new Error("Invalid configuration");
24
+ case "missingProxy":
25
+ return Object.assign(Object.assign({}, store), { pm: {} }); // Break proxy chain
26
+ case "largePayload":
27
+ return Object.assign(Object.assign({}, store), { largePayload: true, pm: Object.assign(Object.assign({}, store.pm), { writeFileSync: (p, c) => {
28
+ if (c.length > 1e6) {
29
+ return true;
30
+ }
31
+ throw new Error("Payload too small");
32
+ } }) });
33
+ default:
34
+ return store;
35
+ }
36
+ },
37
+ },
38
+ thens: {
39
+ verifyProxy: (expectedPath) => (store) => {
40
+ var _a;
41
+ const testPath = "expected";
42
+ const result = store.pm.writeFileSync(testPath, "content");
43
+ const actualPath = (_a = store.pm.getLastCall("writeFileSync")) === null || _a === void 0 ? void 0 : _a.path;
44
+ if (actualPath !== expectedPath) {
45
+ throw new Error(`Expected path ${expectedPath}, got ${actualPath}`);
46
+ }
47
+ return store;
48
+ },
49
+ verifyNoProxy: () => (store) => {
50
+ if (store.pm.getCallCount("writeFileSync") > 0) {
51
+ throw new Error("Proxy was unexpectedly applied");
52
+ }
53
+ return store;
54
+ },
55
+ verifyError: (expectedError) => (store) => {
56
+ try {
57
+ store.pm.writeFileSync("test", "content");
58
+ throw new Error("Expected error but none was thrown");
59
+ }
60
+ catch (error) {
61
+ if (!error.message.includes(expectedError)) {
62
+ throw new Error(`Expected error "${expectedError}", got "${error.message}"`);
63
+ }
64
+ }
65
+ return store;
66
+ },
67
+ verifyResourceConfig: () => (store) => {
68
+ if (!store.pm.testResourceConfiguration) {
69
+ throw new Error("Missing test resource configuration");
70
+ }
71
+ return store;
72
+ },
73
+ verifyLargePayload: () => (store) => {
74
+ const largeContent = "x".repeat(2e6); // 2MB payload
75
+ const result = store.pm.writeFileSync("large.txt", largeContent);
76
+ if (!result) {
77
+ throw new Error("Failed to handle large payload");
78
+ }
79
+ return store;
80
+ },
81
+ verifyTypeSafety: () => (store) => {
82
+ // TypeScript will catch these at compile time
83
+ return store;
84
+ },
85
+ },
86
+ checks: {
87
+ Default: () => ({}),
88
+ },
89
+ };
90
+ // Specification for PureTesteranto tests
91
+ const specification = (Suite, Given, When, Then, Check) => [
92
+ Suite.Default("Core Functionality", {
93
+ initializationTest: Given.Default(["Should initialize with default configuration"], [], [Then.verifyNoProxy()]),
94
+ resourceConfigTest: Given.Default(["Should handle test resource configuration"], [When.applyProxy("resourceConfig")], [Then.verifyResourceConfig()]),
95
+ }),
96
+ Suite.Default("Proxy Integration", {
97
+ butThenProxyTest: Given.Default(["Should integrate with butThenProxy"], [When.applyProxy("butThenProxy")], [Then.verifyProxy("test/path/butThen/expected")]),
98
+ andWhenProxyTest: Given.Default(["Should integrate with andWhenProxy"], [When.applyProxy("andWhenProxy")], [Then.verifyProxy("test/path/andWhen/expected")]),
99
+ beforeEachProxyTest: Given.Default(["Should integrate with beforeEachProxy"], [When.applyProxy("beforeEachProxy")], [Then.verifyProxy("suite-1/beforeEach/expected")]),
100
+ }),
101
+ Suite.Default("Error Handling", {
102
+ invalidConfigTest: Given.Default(["Should handle invalid configuration"], [When.applyProxy("invalidConfig")], [Then.verifyError("Invalid configuration")]),
103
+ missingProxyTest: Given.Default(["Should handle missing proxy"], [When.applyProxy("missingProxy")], [Then.verifyError("Proxy not found")]),
104
+ }),
105
+ Suite.Default("Performance", {
106
+ multipleProxiesTest: Given.Default(["Should handle multiple proxies efficiently"], [
107
+ When.applyProxy("butThenProxy"),
108
+ When.applyProxy("andWhenProxy"),
109
+ When.applyProxy("beforeEachProxy")
110
+ ], [
111
+ Then.verifyProxy("test/path/butThen/expected"),
112
+ Then.verifyProxy("test/path/andWhen/expected"),
113
+ Then.verifyProxy("suite-1/beforeEach/expected")
114
+ ]),
115
+ largePayloadTest: Given.Default(["Should handle large payloads"], [When.applyProxy("largePayload")], [Then.verifyLargePayload()]),
116
+ }),
117
+ Suite.Default("Cross-Component Verification", {
118
+ proxyChainTest: Given.Default(["Proxies should chain correctly"], [
119
+ When.applyProxy("butThenProxy"),
120
+ When.applyProxy("andWhenProxy")
121
+ ], [
122
+ Then.verifyProxy("test/path/andWhen/butThen/expected")
123
+ ]),
124
+ errorPropagationTest: Given.Default(["Errors should propagate across components"], [When.applyProxy("invalidConfig")], [Then.verifyError("Invalid configuration")]),
125
+ resourceSharingTest: Given.Default(["Resources should be shared correctly"], [When.applyProxy("resourceConfig")], [Then.verifyResourceConfig()])
126
+ }),
127
+ Suite.Default("Type Safety", {
128
+ strictTypeTest: Given.Default(["Should enforce type safety"], [When.applyProxy("typeSafe")], [Then.verifyTypeSafety()]),
129
+ invalidTypeTest: Given.Default(["Should reject invalid types"], [When.applyProxy("invalidType")], [Then.verifyError("Type mismatch")]),
130
+ }),
131
+ Suite.Default("Integration Tests", {
132
+ // Verify builders work together
133
+ builderIntegration: Given.Default(["BaseBuilder and ClassBuilder should integrate properly"], [], [
134
+ Then.initializedProperly(),
135
+ Then.specsGenerated(),
136
+ Then.jobsCreated(),
137
+ Then.artifactsTracked()
138
+ ]),
139
+ // Verify PM proxy integration
140
+ pmProxyIntegration: Given.Default(["PM proxies should work with test runners"], [When.applyProxy("butThenProxy")], [Then.verifyProxy("test/path/butThen/expected")]),
141
+ // Verify full test lifecycle
142
+ fullLifecycle: Given.Default(["Should complete full test lifecycle"], [
143
+ When.addArtifact(Promise.resolve("test")),
144
+ When.setTestJobs([]),
145
+ When.modifySpecs((specs) => [...specs])
146
+ ], [
147
+ Then.testRunSuccessful(),
148
+ Then.artifactsTracked(),
149
+ Then.specsModified(0)
150
+ ])
151
+ })
152
+ ];
153
+ // Test interface for PureTesteranto
154
+ const testInterface = {
155
+ beforeEach: async (subject, initializer) => {
156
+ return { pm: initializer() };
157
+ },
158
+ andWhen: async (store, whenCB) => whenCB(store),
159
+ butThen: async (store, thenCB) => thenCB(store),
160
+ afterEach: async (store) => store,
161
+ afterAll: async () => { },
162
+ beforeAll: async (input, testResource) => ({}),
163
+ assertThis: (x) => x,
164
+ };
165
+ // Export the test suite
166
+ export default PureTesteranto(null, // No initial input
167
+ specification, implementation, testInterface);
@@ -151,7 +151,6 @@ import(process.cwd() + "/" + "testeranto.config.ts").then(async (module) => {
151
151
  // ],
152
152
  ];
153
153
  x.forEach(async ([runtime, keys]) => {
154
- console.log(runtime, keys);
155
154
  keys.forEach(async (k) => {
156
155
  const folder = `testeranto/reports/${testName}/${k
157
156
  .split(".")
@@ -1,24 +1,32 @@
1
+ import fs from "fs";
1
2
  export const consoleDetectorPlugin = {
2
- name: 'console-detector',
3
+ name: "console-detector",
3
4
  setup(build) {
4
5
  build.onLoad({ filter: /\.(js|ts)$/ }, async (args) => {
5
- const contents = await require('fs').promises.readFile(args.path, 'utf8');
6
+ const contents = await fs.promises.readFile(args.path, "utf8");
6
7
  const consolePattern = /console\.(log|error|warn|info|debug|trace|dir|dirxml|table|group|groupEnd|clear|count|countReset|assert|profile|profileEnd|time|timeLog|timeEnd|timeStamp|context|memory)/g;
7
8
  const matches = contents.match(consolePattern);
8
9
  if (matches) {
9
10
  const uniqueMethods = [...new Set(matches)];
10
11
  return {
11
- warnings: uniqueMethods.map(method => ({
12
- text: `Detected ${method} call - Pure runtime does not allow IO operations. Use Node runtime instead.`,
13
- location: {
14
- file: args.path,
15
- line: contents.split('\n').findIndex(line => line.includes(method)) + 1,
16
- column: 0
17
- }
18
- }))
12
+ warnings: uniqueMethods.map((method) => ({
13
+ text: `call of "${method}" was detected, which is not supported in the pure runtime.`,
14
+ // location: {
15
+ // file: args.path,
16
+ // line:
17
+ // contents
18
+ // .split("\n")
19
+ // .findIndex((line) => line.includes(method)) + 1,
20
+ // column: 0,
21
+ // },
22
+ })),
19
23
  };
20
24
  }
21
25
  return null;
22
26
  });
23
- }
27
+ build.onEnd((buildResult) => {
28
+ if (buildResult.warnings.find((br) => br.pluginName === "console-detector"))
29
+ console.warn(`Warning: An unsupported method call was detected in a source file used to build for the pure runtime. It is possible that this method call is in a comment block. If you really want to use this function, change this test to the "node" runtime.`);
30
+ });
31
+ },
24
32
  };
@@ -0,0 +1,21 @@
1
+ import { isBuiltin } from "node:module";
2
+ export const nativeImportDetectorPlugin = {
3
+ name: "native-node-import-filter",
4
+ setup(build) {
5
+ build.onResolve({ filter: /fs/ }, (args) => {
6
+ if (isBuiltin(args.path)) {
7
+ return {
8
+ warnings: [
9
+ {
10
+ text: `cannot use native node package "${args.path}" in a "pure" test. If you really want to use this package, convert this test from "pure" to "node"`,
11
+ },
12
+ ],
13
+ };
14
+ // throw new Error(
15
+ // `cannot use native node package "${args.path}" in a "pure" test. If you really want to use this package, convert this test from "pure" to "node"`
16
+ // );
17
+ }
18
+ return { path: args.path };
19
+ });
20
+ },
21
+ };
@@ -18,12 +18,13 @@ export default (config, entryPoints, testName) => {
18
18
  featuresPlugin,
19
19
  inputFilesPluginFactory,
20
20
  consoleDetectorPlugin,
21
+ // nativeImportDetectorPlugin,
21
22
  {
22
23
  name: "native-node-import-filter",
23
24
  setup(build) {
24
25
  build.onResolve({ filter: /fs/ }, (args) => {
25
26
  if (isBuiltin(args.path)) {
26
- throw new Error(`cannot use native node package "${args.path}" in a "pure" test. If you really want to use this package, convert this test from "pure" to "node"`);
27
+ throw new Error(`You attempted to import a node module "${args.path}" into a "pure" test, which is not allowed. If you really want to use this package, convert this test from "pure" to "node"`);
27
28
  }
28
29
  return { path: args.path };
29
30
  });
@@ -3,11 +3,8 @@ export default (r) => {
3
3
  return {
4
4
  name: "rebuild-notify",
5
5
  setup: (build) => {
6
- build.onStart(() => {
7
- console.log(`> web build starting...`);
8
- });
9
6
  build.onEnd((result) => {
10
- console.log(`> web build ended with ${result.errors.length} errors`);
7
+ console.log(`${r} > build ended with ${result.errors.length} errors`);
11
8
  if (result.errors.length > 0) {
12
9
  fs.writeFileSync(`./testeranto/reports${r}_build_errors`, JSON.stringify(result, null, 2));
13
10
  }
@@ -0,0 +1,85 @@
1
+ import { beforeAllProxy, afterAllProxy } from "./pmProxy";
2
+ export class BaseSuite {
3
+ constructor(name, index, givens = {}, checks = []) {
4
+ this.name = name;
5
+ this.index = index;
6
+ this.givens = givens;
7
+ this.checks = checks;
8
+ this.fails = 0;
9
+ }
10
+ features() {
11
+ const features = Object.keys(this.givens)
12
+ .map((k) => this.givens[k].features)
13
+ .flat()
14
+ .filter((value, index, array) => {
15
+ return array.indexOf(value) === index;
16
+ });
17
+ return features || [];
18
+ }
19
+ toObj() {
20
+ const givens = Object.keys(this.givens).map((k) => this.givens[k].toObj());
21
+ const checks = Object.keys(this.checks).map((k) => this.checks[k].toObj());
22
+ return {
23
+ name: this.name,
24
+ givens,
25
+ checks,
26
+ fails: this.fails,
27
+ failed: this.failed,
28
+ features: this.features(),
29
+ };
30
+ }
31
+ setup(s, artifactory, tr, pm) {
32
+ return new Promise((res) => res(s));
33
+ }
34
+ assertThat(t) {
35
+ return !!t;
36
+ }
37
+ afterAll(store, artifactory, pm) {
38
+ return store;
39
+ }
40
+ async run(input, testResourceConfiguration, artifactory, tLog, pm) {
41
+ this.testResourceConfiguration = testResourceConfiguration;
42
+ // tLog("test resources: ", JSON.stringify(testResourceConfiguration));
43
+ const suiteArtifactory = (fPath, value) => artifactory(`suite-${this.index}-${this.name}/${fPath}`, value);
44
+ // console.log("\nSuite:", this.index, this.name);
45
+ tLog("\nSuite:", this.index, this.name);
46
+ const sNdx = this.index;
47
+ // const sName = this.name;
48
+ const subject = await this.setup(input, suiteArtifactory, testResourceConfiguration, beforeAllProxy(pm, sNdx.toString()));
49
+ for (const [gKey, g] of Object.entries(this.givens)) {
50
+ const giver = this.givens[gKey];
51
+ this.store = await giver
52
+ .give(subject, gKey, testResourceConfiguration, this.assertThat, suiteArtifactory, tLog, pm, sNdx)
53
+ .catch((e) => {
54
+ this.failed = true;
55
+ this.fails = this.fails + 1;
56
+ console.error("Given error 1:", e);
57
+ throw e;
58
+ });
59
+ }
60
+ for (const [ndx, thater] of this.checks.entries()) {
61
+ await thater.check(subject, thater.name, testResourceConfiguration, this.assertThat, suiteArtifactory, tLog, pm);
62
+ }
63
+ try {
64
+ this.afterAll(this.store, artifactory, afterAllProxy(pm, sNdx.toString()));
65
+ }
66
+ catch (e) {
67
+ console.error(e);
68
+ // this.fails.push(this);
69
+ // return this;
70
+ }
71
+ // @TODO fix me
72
+ // for (const k of Object.keys(this.givens)) {
73
+ // const giver = this.givens[k];
74
+ // try {
75
+ // giver.afterAll(this.store, artifactory, pm);
76
+ // } catch (e) {
77
+ // console.error(e);
78
+ // this.fails.push(giver);
79
+ // return this;
80
+ // }
81
+ // }
82
+ ////////////////
83
+ return this;
84
+ }
85
+ }
@@ -0,0 +1,4 @@
1
+ import Testeranto from "../../Node";
2
+ import { BaseSuite } from "../BaseSuite";
3
+ import { implementation, specification, testInterface } from "./test";
4
+ export default Testeranto(BaseSuite, specification, implementation, testInterface);
@@ -0,0 +1,4 @@
1
+ import Testeranto from "../../Pure";
2
+ import { BaseSuite } from "../BaseSuite";
3
+ import { implementation, specification, testInterface } from "./test";
4
+ export default Testeranto(BaseSuite, specification, implementation, testInterface);
@@ -0,0 +1,227 @@
1
+ import { BaseGiven, BaseWhen, BaseThen, BaseCheck } from "../abstractBase";
2
+ import { BaseSuite } from "../BaseSuite";
3
+ // 2. Mock implementations with proper typing
4
+ export class MockGiven extends BaseGiven {
5
+ constructor(name, features, whens, thens) {
6
+ super(name, features, whens, thens, async () => ({ testStore: true }), // givenCB
7
+ {} // initialValues
8
+ );
9
+ }
10
+ async givenThat(subject, testResourceConfiguration, artifactory, givenCB, initialValues, pm) {
11
+ return { testStore: true };
12
+ }
13
+ uberCatcher(e) {
14
+ console.error("Given error 2:", e);
15
+ }
16
+ }
17
+ class MockWhen extends BaseWhen {
18
+ async andWhen(store, whenCB, testResource, pm) {
19
+ return Object.assign(Object.assign({}, store), { testStore: true });
20
+ }
21
+ }
22
+ class MockThen extends BaseThen {
23
+ async butThen(store, thenCB, testResourceConfiguration, pm) {
24
+ return { testSelection: true };
25
+ }
26
+ }
27
+ class MockCheck extends BaseCheck {
28
+ async checkThat(subject, testResourceConfiguration, artifactory, initializer, initialValues, pm) {
29
+ return { testStore: true };
30
+ }
31
+ }
32
+ class TestableSuite extends BaseSuite {
33
+ constructor(name, index) {
34
+ super(name, index, {
35
+ testGiven: new MockGiven("testGiven", ["testFeature"], [
36
+ new MockWhen("testWhen", () => Promise.resolve({ testStore: true })),
37
+ ], [
38
+ new MockThen("testThen", async () => Promise.resolve({ testSelection: true })),
39
+ ]),
40
+ }, [
41
+ new MockCheck("testCheck", ["testFeature"], () => Promise.resolve({ testStore: true }), null, () => { }),
42
+ ]);
43
+ }
44
+ }
45
+ // 3. Enhanced Test Specification with more test cases
46
+ export const specification = (Suite, Given, When, Then, Check) => [
47
+ Suite.Default("BaseSuite Core Functionality Tests", {
48
+ // Test initialization and basic properties
49
+ initialization: Given.Default(["BaseSuite should initialize with correct name and index"], [], [
50
+ Then.SuiteNameMatches("testSuite"),
51
+ Then.SuiteIndexMatches(0),
52
+ Then.FeaturesIncludes("testFeature"),
53
+ ]),
54
+ // Test execution flow
55
+ execution: Given.Default(["BaseSuite should execute all phases successfully"], [When.RunSuite()], [Then.StoreValid(), Then.NoErrorsOccurred(), Then.AllChecksCompleted()]),
56
+ // Test multiple features
57
+ multipleFeatures: Given.Default(["BaseSuite should handle multiple features"], [When.AddFeature("additionalFeature")], [
58
+ Then.FeaturesIncludes("testFeature"),
59
+ Then.FeaturesIncludes("additionalFeature"),
60
+ Then.FeatureCountMatches(2),
61
+ ]),
62
+ // Test error handling
63
+ errorHandling: Given.Default(["BaseSuite should handle errors gracefully"], [When.RunSuiteWithError()], [
64
+ Then.ErrorCountMatches(1),
65
+ // Then.FailedFlagSet(),
66
+ ]),
67
+ }, [
68
+ // Additional validation checks
69
+ // Check.Default(
70
+ // ["Verify suite state after all tests"],
71
+ // [],
72
+ // [
73
+ // Then.AllTestsCompleted(),
74
+ // Then.CleanExit()
75
+ // ]
76
+ // )
77
+ ]),
78
+ Suite.Default("Comprehensive Integration", {
79
+ fullStackTest: Given.Default(["All components should work together"], [
80
+ When.addArtifact(Promise.resolve("test")),
81
+ When.modifySpecs((specs) => [...specs, "extra"]),
82
+ When.modifyJobs((jobs) => [...jobs, {}]),
83
+ ], [
84
+ Then.specsModified(1),
85
+ Then.jobsModified(1),
86
+ Then.artifactsTracked(),
87
+ Then.testRunSuccessful(),
88
+ ]),
89
+ }),
90
+ ];
91
+ // 4. Enhanced Test Implementation with more operations
92
+ export const implementation = {
93
+ suites: {
94
+ Default: "BaseSuite Comprehensive Test Suite",
95
+ },
96
+ givens: {
97
+ Default: () => new TestableSuite("testSuite", 0),
98
+ },
99
+ whens: {
100
+ RunSuite: () => async (suite) => {
101
+ const mockConfig = {
102
+ name: "test",
103
+ fs: "/tmp",
104
+ ports: [3000],
105
+ environment: {},
106
+ timeout: 5000,
107
+ retries: 3,
108
+ };
109
+ const mockArtifactory = (key, value) => { };
110
+ const mockTLog = (...args) => { };
111
+ const mockPM = {
112
+ server: null,
113
+ testResourceConfiguration: mockConfig,
114
+ start: async () => { },
115
+ stop: async () => { },
116
+ testArtiFactoryfileWriter: () => { },
117
+ $: () => { },
118
+ click: () => { },
119
+ closePage: () => { },
120
+ createWriteStream: async () => "",
121
+ };
122
+ return await suite.run(null, mockConfig, mockArtifactory, mockTLog, mockPM);
123
+ },
124
+ RunSuiteWithError: () => async (suite) => {
125
+ // Force an error by passing invalid config
126
+ try {
127
+ await suite.run(null, {}, // Invalid config
128
+ () => { }, () => { }, {});
129
+ }
130
+ catch (e) {
131
+ // Error is caught and counted by BaseSuite
132
+ }
133
+ return suite;
134
+ },
135
+ AddFeature: (feature) => (suite) => {
136
+ // Add a feature to the first given
137
+ const firstGivenKey = Object.keys(suite.givens)[0];
138
+ if (firstGivenKey) {
139
+ suite.givens[firstGivenKey].features.push(feature);
140
+ }
141
+ return suite;
142
+ },
143
+ },
144
+ thens: {
145
+ SuiteNameMatches: (expectedName) => (suite) => {
146
+ if (suite.name !== expectedName) {
147
+ throw new Error(`Expected suite name '${expectedName}', got '${suite.name}'`);
148
+ }
149
+ return suite;
150
+ },
151
+ SuiteIndexMatches: (expectedIndex) => (suite) => {
152
+ if (suite.index !== expectedIndex) {
153
+ throw new Error(`Expected suite index ${expectedIndex}, got ${suite.index}`);
154
+ }
155
+ return suite;
156
+ },
157
+ FeaturesIncludes: (feature) => (suite) => {
158
+ if (!suite.features().includes(feature)) {
159
+ throw new Error(`Expected features to include ${feature}`);
160
+ }
161
+ return suite;
162
+ },
163
+ FeatureCountMatches: (expectedCount) => (suite) => {
164
+ const actualCount = suite.features().length;
165
+ if (actualCount !== expectedCount) {
166
+ throw new Error(`Expected ${expectedCount} features, got ${actualCount}`);
167
+ }
168
+ return suite;
169
+ },
170
+ StoreValid: () => (suite) => {
171
+ var _a;
172
+ if (!((_a = suite.store) === null || _a === void 0 ? void 0 : _a.testStore)) {
173
+ throw new Error("Expected valid store after execution");
174
+ }
175
+ return suite;
176
+ },
177
+ NoErrorsOccurred: () => (suite) => {
178
+ if (suite.failed || suite.fails > 0) {
179
+ throw new Error("Expected no errors to occur during execution");
180
+ }
181
+ return suite;
182
+ },
183
+ ErrorCountMatches: (expectedCount) => (suite) => {
184
+ if (suite.fails !== expectedCount) {
185
+ throw new Error(`Expected ${expectedCount} errors, got ${suite.fails}`);
186
+ }
187
+ return suite;
188
+ },
189
+ FailedFlagSet: () => (suite) => {
190
+ if (!suite.failed) {
191
+ throw new Error("Expected failed flag to be set after error");
192
+ }
193
+ return suite;
194
+ },
195
+ AllChecksCompleted: () => (suite) => {
196
+ if (suite.checks.some((check) => !check.key)) {
197
+ throw new Error("Expected all checks to be completed");
198
+ }
199
+ return suite;
200
+ },
201
+ AllTestsCompleted: () => (suite) => {
202
+ if (!suite.store) {
203
+ throw new Error("Expected all tests to be completed");
204
+ }
205
+ return suite;
206
+ },
207
+ CleanExit: () => (suite) => {
208
+ if (suite.failed && suite.fails === 0) {
209
+ throw new Error("Expected clean exit state");
210
+ }
211
+ return suite;
212
+ },
213
+ },
214
+ checks: {
215
+ Default: () => new TestableSuite("testCheck", 1),
216
+ },
217
+ };
218
+ // 5. Fully typed Test Interface
219
+ export const testInterface = {
220
+ beforeEach: async (subject, initializer) => initializer(),
221
+ andWhen: async (store, whenCB, testResource, pm) => whenCB(store, pm),
222
+ butThen: async (store, thenCB, testResource, pm) => thenCB(store, pm),
223
+ afterEach: (store) => store,
224
+ afterAll: (store, pm) => { },
225
+ assertThis: (result) => !!result,
226
+ beforeAll: async (input, testResource, pm) => input,
227
+ };
@@ -0,0 +1,4 @@
1
+ import Testeranto from "../../Web";
2
+ import { BaseSuite } from "../BaseSuite";
3
+ import { implementation, specification, testInterface } from "./test";
4
+ export default Testeranto(BaseSuite, specification, implementation, testInterface);